Database MCQ Number 00867

Database MCQ Set 1

1. Which is the subset of SQL commands used to manipulate Oracle Database structures, including tables?
a) Data Definition Language(DDL)
b) Data Manipulation Language(DML)
c) DML and DDL
d) None of the Mentioned

Answer

Answer: a [Reason:] The DDL is used to manage table and index structure.CREATE, ALTER, RENAME, DROP and TRUNCATE statements are the names of few data definition elements.

2. Which of the following is/are the DDL statements?
A) Create
B) Drop
C) Alter
D) All of the Mentioned

Answer

Answer: d [Reason:] All the mentioned commands are the part of DDL statements.

3. In SQL, which command(s) is(are) used to change a table’s storage characteristics?
a) ALTER TABLE
b) MODIFY TABLE
c) CHANGE TABLE
d) All of the Mentioned

Answer

Answer: a [Reason:] To change the structure of the table we use ALTER TABLE Syntax:
ALTER TABLE “table_name” ADD “column_name” datatype
OR
ALTER TABLE “table_name” DROP COLUMN “column_name”.

4. In SQL, which of the following is not a data definition language commands?
a) RENAME
b) REVOKE
c) GRANT
d) UPDATE

Answer

Answer: a [Reason:] With RENAME statement you can rename a table.RENAME, REVOKE and GRANT are DDL commands and UPDATE is DML command.

5. ________clause is an additional filter that is applied to the result.
a) Select
b) Group-by
c) Having
d) Order by

Answer

Answer: c [Reason:] The HAVING clause was added to SQL because the WHERE keyword could not be used with aggregate functions.

6. _____ defines rules regarding the values allowed in columns and is the standard mechanism for enforcing database integrity.
a) Column
b) Constraint
c) Index
d) Trigger

Answer

Answer: b [Reason:] SQL constraints are used to specify rules for the data in a table.If there is any violation between the constraint and the data action, the action is aborted by the constraint.

7. SQL has how many main commands for DDL:
a) 1
b) 2
c) 3
d) 4

Answer

Answer: c [Reason:] Create, Delete, Alter these are 3 main command.

8. Which command defines its columns, integrity constraint in create table:
a) Create command
b) Drop table command
c) Alter table command
d) All of the Mentioned

Answer

Answer: a [Reason:] The CREATE TABLE statement is used to create a table in a database.Tables are organized into rows and columns.

9. Which command is used for removing a table and all its data from the database:
a) Create command
b) Drop table command
c) Alter table command
d) All of the Mentioned

Answer

Answer: b [Reason:] The DROP INDEX statement is used to delete an index in a table.

10. Which command allows the removal of all rows from a table but flushes a table more efficiently since no rollback information is retained:
a) TRUNCATE command
b) Create command
c) Drop table command
d) Alter table command

Answer

Answer: a [Reason:] The SQL TRUNCATE TABLE command is used to delete complete data from an existing table.You can also use DROP TABLE command to delete complete table but it would remove complete table structure form the database and you would need to re-create this table once again if you wish you store some data.

Database MCQ Set 2

1. The language used application programs to request data from the DBMS is referred to as ____
a) DML
b) DDL
c) Query language
d) All of the Mentioned

Answer

Answer: a [Reason:] Data Manipulation Language (DML) statements are used for managing data in database. DML commands are not auto-committed. It means changes made by DML command are not permanent to database, it can be rolled back.

2. In SQL, which of the following is not a data Manipulation Language Commands?
a) Delete
b) Truncate
c) Update
d) Create

Answer

Answer: b [Reason:] The SQL TRUNCATE TABLE command is used to delete complete data from an existing table.You can also use DROP TABLE command to delete complete table but it would remove complete table structure form the database and you would need to re-create this table once again if you wish you store some data.

3. Which of the following is not a type of SQL statement?
a) Data Manipulation Language (DML)
b) Data Definition Language (DDL)
c) Data Control Language (DCL)
d) Data Communication Language (DCL)

Answer

Answer: d [Reason:] Data Communication Language (DCL) is not a type of SQL statement.

4. Which of the following is not included in DML (Data Manipulation Language)
a) INSERT
b) UPDATE
c) DELETE
d) CREATE

Answer

Answer: d [Reason:] The CREATE TABLE statement is used to create a table in a database.Tables are organized into rows and columns; and each table must have a name.

5. TRUNCATE statement in SQL is a –
a) DML statement
b) DDL statement
c) DCL statement
d) TCL statement

Answer

Answer: b [Reason:] The SQL TRUNCATE TABLE command is used to delete complete data from an existing table.so its a DDL statement.

6. In SQL, which command is used to add new rows to a table?
a) Alter Table
b) Add row
c) Insert
d) Append

Answer

Answer: c [Reason:] Alter Table will change the structure of the table.

7. Stack is also called ____
a) First In First Out (LIFO)
b) Last In First Out (FIFO)
c) First In Last Out (FILO)
d) First Come First Served (FCFS)

Answer

Answer: c [Reason:] Stack works on the First In Last Out.

8. A table that displays data redundancies yields ______ anomalies.
a) Update
b) Insertion
c) Deletion
d) All of the Mentioned

Answer

Answer: d [Reason:] Table that displays data redundancies yields update, insertion, deletion anomalies.

9. A type of query that is placed within a WHERE or HAVING clause of another query is called
a) Master query
b) Sub query
c) Super query
d) Multi-query

Answer

Answer: b [Reason:] Sub-query that is placed within a WHERE or HAVING clause of another query.

10. The three language components of a database management system (DBMS) like DDL, DCL, DML.
Two different types of people (users and practitioners) are concerned with them. Which of them do users of a DBMS usually deal with?
a) DDL
b) DML
c) DDL and DCL
d) DCL and DML

Answer

Answer: b [Reason:] The users and practitioners are concerned with only Data manipulation language component of DBMS.

Database MCQ Set 3

1. What is the full form of SQL?
a) Structured Query Language
b) Structured Query List
c) Simple Query Language
d) None of the Mentioned

Answer

Answer: a [Reason:] SQL (Structured Query Language) is a special-purpose programming language designed for managing data held in a relational database management system.Originally based upon relational algebra and tuple relational calculus, SQL consists of a data definition language and a data manipulation language. The scope of SQL includes data insert, query, update and delete, schema creation and modification, and data access control.

2. Which is the subset of SQL commands used to manipulate Oracle Database structures, including tables?
a) Data Definition Language(DDL)
b) Data Manipulation Language(DML)
c) DDL and DML
d) None of the Mentioned

Answer

Answer: a [Reason:] The Data Definition Language is used to manage table and index structure.CREATE, ALTER, RENAME, DROP and TRUNCATE statements are the names of few data definition elements.

3. In SQL, which command is used to SELECT only one copy of each set of duplicable rows
a) SELECT DISTINCT
b) SELECT UNIQUE
c) SELECT DIFFERENT
d) All of the Mentioned

Answer

Answer: a [Reason:] The keyword allows us to grab all information from a column (or columns) on a table. This, of course, necessarily means that there will be redundancies. What if we only want to select each distinct element? This is easy way to accomplish in SQL. All we need to do is that to add after The syntax is:SELECT DISTINCT column_name FROM table_name;.

4. A command that lets you change one or more fields in a record is
a) Insert
b) Modify
c) Look-up
d) All of the Mentioned

Answer

Answer: b [Reason:] Sometimes we need to change the data type of a column. To do this, we use the ALTER TABLE Modify Column ALTER TABLE table_name, MODIFY column_name “New Data Type”.

5. Which of the SQL statements is correct?
a) SELECT Username AND Password FROM Users
b) SELECT Username, Password FROM Users
c) SELECT Username, Password WHERE Username = ‘user1’
d) None of the Mentioned

Answer

Answer: b [Reason:] Correct order of SELECT, FROM and WHERE clause is as follow:
SELECT column_name1, column_name2 FROM table_name WHERE condition So, only SELECT Username, Password FROM Users follows the above syntax.

6. The SQL statement
SELECT SUBSTR(‘123456789’, INSTR(‘abcabcabc’, ‘b’), 4) FROM DUAL;
a) 6789
b) 2345
c) 1234
d) 456789

Answer

Answer: b [Reason:] INSTR function in SQL is used to find the starting location of a pattern in a string. The syntax for the INSTR function is as follows:INSTR(str,pattern):Find the starting location of pattern in string str and SUBSTR Function:- The Substring function in SQL is used to grab a portion of the stored data.

7. Table Employee has 10 records. It has a non-NULL SALARY column which is also UNIQUE.
The SQL statement

SELECT COUNT(*) FROM Employee WHERE  SALARY > ANY (SELECT SALARY FROM EMPLOYEE);

prints
a) 10
b) 9
c) 5
d) 0

Answer

Answer: b [Reason:] Any compares a value with each of the values in a list or results from a query and evaluates to true if the result of an inner query contains at least one row. ANY must be preceded by comparison operators(=, >, <, <=, >=, <>).Employee table has 10 records and each value in non-NULL SALARY column is unique i.e different. So, in that 10 records one of the record will be minimum which cannot be greater than any nine value of the salary column. Hence the condition WHERE SALARY > ANY (SELECT SALARY FROM employee) will be true nine times. So, the COUNT(*) outputs 9.

8. Find the temperature in increasing order of all cities
a) SELECT city FROM weather ORDER BY temperature;
b) SELECT city, temperature FROM weather;
c) SELECT city, temperature FROM weather ORDER BY temperature;
d) SELECT city, temperature FROM weather ORDER BY city;

Answer

Answer: c [Reason:]

SELECT column_name, aggregate_function(column_name)
	FROM table_name
	WHERE column_name operator value
	GROUP BY column_name
	HAVING aggregate_function(column_name) operator value
	ORDER BY ; 

So base on [SELECT city, temperature FROM weather ORDER BY temperature;] this will be the correct answer.

9. Which of the following is illegal?
a) SELECT SYSDATE – SYSDATE FROM DUAL;
b) SELECT SYSDATE – (SYSDATE – 2) FROM DUAL;
c) SELECT SYSDATE – (SYSDATE + 2) FROM DUAL;
d) None of the Mentioned

Answer

Answer: d [Reason:] SELECT SYSDATE – SYSDATE FROM DUAL; outputs 0 SELECT SYSDATE – (SYSDATE – 2) FROM DUAL; outputs 2
SELECT SYSDATE – (SYSDATE + 2) FROM DUAL; outputs -2.

10. Let the statement : SELECT column1 FROM myTable; return 10 rows.
The statement : SELECT ALL column1 FROM myTable; will return
a) less than 10 rows
b) more than 10 rows
c) exactly 10 rows
d) none of the Mentioned

Answer

Answer: c [Reason:] All are optional. Its presence or absence doesn’t change the output. Unlike DISTINCT, it allows duplicates in the output.

Database MCQ Set 4

1. Which of the following wizard provides creation logins on the destination server ?
a) Copy Database
b) Move Database
c) Detach database
d) Attach database

Answer

Answer: a [Reason:] The Copy Database Wizard lets you move or copy databases and their objects easily from one server to another.

2. Point out the correct statement :
a) After a database has been upgraded, it cannot be downgraded to a previous version.
b) The Copy Database Wizard is available in the Express edition
c) The Copy Database Wizard cannot be used to copy System databases
d) None of the mentioned

Answer

Answer: c [Reason:] System databases cannot be transferred using Copy database wizard.

3. How many ways are provided by SQL Server to copy a database ?
a) 2
b) 3
c) 4
d) 5

Answer

Answer: b [Reason:] SQL Server provides mainly three ways to copy a database.

4. Which is not the preferred way of copying a database ?
a) Using the Copy Database Wizard
b) Restoring a database backup
c) Using the Generate Scripts Wizard to publish databases
d) None of the mentioned

Answer

Answer: c [Reason:] Generate script wizard produces unnecessary computation internally to copy a database.

5. Point out the wrong statement related to the use of Copy database wizard:
a) Pick a source and destination server
b) System stored procedures
c) Schedule when to move or copy the databases
d) None of the mentioned

Answer

Answer: b [Reason:] Copy database wizard copies additional supporting objects, jobs, user-defined stored procedures, and error messages.

6. Which of the following returns a list of the database and log files ?
a) RESTORE FILELISTON
b) RESTORE FILELIST
c) RESTORE FILELISTONLY
d) All of the mentioned

Answer

Answer: c [Reason:] A client can use RESTORE FILELISTONLY to obtain a list of the files contained in a backup set. This information is returned as a result set containing one row for each file.

7. Which of the following transfer method makes the database unavailable to users during the transfer ?
a) Detach and attach method
b) SQL Management Object method
c) Restore method
d) None of the mentioned

Answer

Answer: a [Reason:] Detach the database from the source server, copy the database files to the destination server, and attach the database at the destination server.

8. Which of the following stored prcoedure is used for detachment of database ?
a) sp_replicationdboption
b) sp_replicationdb
c) sp_replicationoption
d) All of the mentioned

Answer

Answer: a [Reason:] If you cannot use sp_replicationdboption, you can remove replication by running sp_removedbreplication.

9. Which of the following code snippet will detach AdventureWorks2012 database ?
a)

USE master;
GO
EXEC xp_detach_db @dbname = N'AdventureWorks2012';
GO

b)

USE master;
GO
EXEC sp_detach @dbname = N'AdventureWorks2012';
GO

c)

USE master;
GO
EXEC sp_detach_db @dbname = N'AdventureWorks2012';
GO

d)

USE master;
GO
EXEC sp_det_db @dbname = N'AdventureWorks2012';
GO
Answer

Answer: c [Reason:] sp_detach_db detaches a database that is currently not in use from a server instance.

10. Which of the code is valid for attaching the database ?
a)

USE master;
GO
CREATE DATABASE MyAdventureWorks 
    ON (FILENAME = 'C:MySQLServerAdventureWorks2012_Data.mdf'),
    (FILENAME = 'C:MySQLServerAdventureWorks2012_Log.ldf')
    FOR ATTACH;
GO

b)

USE master;
GO
CREATE DATABASE MyAdventureWorks 
    ON (FILENAME = 'C:MySQLServerAdventureWorks2012_Data.mdf'),
    (FILENAME = 'C:MySQLServerAdventureWorks2012_Log.ldf')
    TO ATTACH;
GO

c)

USE master;
GO
CREATE DATABASE MyAdventureWorks 
    ON (FILENAME = 'C:MySQLServerAdventureWorks2012_Data.mdf'),
    (FILENAME = 'C:MySQLServerAdventureWorks2012_Log.ldf')
    FOR ATTACH_DB;
GO

d) None of the mentioned

Answer

Answer: a [Reason:] Attach the moved database and, optionally, its log by executing the following Transact-SQL statements.

Database MCQ Set 5

1. The SQL Server Maintenance Solution comprises scripts for running ____ maintenance on all editions of Microsoft SQL Server.
a) backups
b) integrity checks
c) index
d) all of the mentioned

Answer

Answer: d [Reason:] The solution is based on stored procedures, the sqlcmd utility, and SQL Server Agent jobs.

2. Point out the correct statement related to database maintenance :
a) Performing SQL Server Maintenance with Maintenance Window
b) Performing SQL Server Maintenance with No Maintenance Window
c) Performing SQL Server Maintenance with Scrip Maintenance Window
d) None of the mentioned

Answer

Answer: b [Reason:] When the production SQL Server is running on a 24X7 basis or the maintenance window is not long enough to support the maintenance.

3. Which of the following is used to determine the fragmentation for tables and indexes ?
a) DBCC SHOWCONTIG
b) DBCC CHECKDB
c) DBCC CHECKCATALOG
d) None of the mentioned

Answer

Answer: a [Reason:] In SQL Server 2005 DBCC SHOWCONTIG remains a viable short term option to determine the database fragmentation.

4. Which of the following is used to Validate the database objects ?
a) DBCC SHOWCONTIG
b) DBCC CHECKDB
c) DBCC CATALOG
d) None of the mentioned

Answer

Answer: b [Reason:] DBCC CHECKDB is supported on databases that contain memory-optimized tables but validation only occurs on disk-based tables.

5. Point out the wrong statement :
a) The command DBCC CHECKDB checks the logical and physical integrity of all the objects in the specified database
b) The command DBCC CHECK checks the logical and physical integrity of all the objects in the specified database
c) The command CHECKDB checks the logical and physical integrity of all the objects in the specified database
d) None of the mentioned

Answer

Answer: a [Reason:] DBCC CHECKDB has some performance quirks based on the schema of the database being checked.

6. Which of the following command defragments clustered and secondary indexes of the specified table ?
a) DBCC SHOWCONTIG
b) DBCC CHECKDB
c) DBCC CATALOG
d) DBCC INDEXDEFRAG

Answer

Answer: d [Reason:] DBCC INDEXDEFRAG is an online operation, so it does not hold long-term locks that can block running queries or updates.

7. ________ runs UPDATE STATISTICS against all user-defined tables in the current database.
a) sp_updatestats
b) DBCC CHECKDB
c) DBCC CATALOG
d) DBCC INDEXDEFRAG

Answer

Answer: a [Reason:] sp_updatestats updates all statistics for all tables in the database.

8. Purpose of DBCC DBREINDEX command is to :
a) Rebuilds one or more indexes for a table in the specified database
b) Rebuilds only one index for a table in the specified database
c) Displays fragmentation information for the data and indexes of the specified table
d) All of the mentioned

Answer

Answer: a [Reason:] The DBCC DBREINDEX command will not automatically rebuild all of the indexes on all the tables in a database; it can only work on one table at a time.

9. What types of database maintenance should be executed ?
a) Update SQL Server’s usage
b) Validate the database objects and system catalogs are free of corruption
c) Determine the fragmentation for tables and indexes
d) All of the mentioned

Answer

Answer: d [Reason:] The SQL Server Maintenance Solution comprises scripts for running backups, integrity checks, and index and statistics maintenance on all editions of Microsoft SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, and SQL Server 2014.

10. Create a Database Maintenance Plan that creates a ________ backup within SQL Server.
a) Partial
b) Snapshot
c) Full
d) None of the mentioned

Answer

Answer: c [Reason:] Creating full backup is minimum recommendation for good database maintenance.

ed010d383e1f191bdb025d5985cc03fc?s=120&d=mm&r=g

DistPub Team

Distance Publisher (DistPub.com) provide project writing help from year 2007 and provide writing and editing help to hundreds student every year.