0% found this document useful (0 votes)
53 views

Top SQL MCQ

The document is a set of 20 multiple choice questions about SQL (Structured Query Language). It covers topics such as what SQL is used for, what it stands for, the components of the SQL query process, common SQL commands like SELECT, INSERT, UPDATE, DELETE and their functions, differences between SQL and NoSQL databases, advantages and disadvantages of SQL. The questions test fundamental SQL concepts and each question is accompanied by a short explanation of the answer.

Uploaded by

Scientific Way
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

Top SQL MCQ

The document is a set of 20 multiple choice questions about SQL (Structured Query Language). It covers topics such as what SQL is used for, what it stands for, the components of the SQL query process, common SQL commands like SELECT, INSERT, UPDATE, DELETE and their functions, differences between SQL and NoSQL databases, advantages and disadvantages of SQL. The questions test fundamental SQL concepts and each question is accompanied by a short explanation of the answer.

Uploaded by

Scientific Way
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 85

MCQ | SQL – Basics (Set 1)

1. What does SQL is used to perform operations on?

A. Update Records
B. Insert Records
C. Both A and B
D. None of the above

Answer: C) Both A and B

Explanation:

SQL (Structured Query Language) is used to update, insert, delete, create, modify, and
maintain the records stored in the database.

2. What does SQL stand for?

A. SQL stands for Sample Query Language


B. SQL stands for Structured Query List
C. SQL stands for Structured Query Language
D. SQL stands for Sample Query List

Answer: C) SQL stands for Structured Query Language

Explanation:

SQL is the short form of Structured Query Language.

3. What does this SQL database language design to?

A. Maintain the data in hierarchal database management systems.


B. Maintain the data in relational database management systems.
C. Maintain the data in network database management systems.
D. Maintain the data in object-oriented database management systems.

Answer: B) Maintain the data in relational database management systems


Explanation:

SQL database language is designed to maintain the data in relational database management
systems.

4. SQL became the standard of?

A. ASCII
B. ANSI
C. ISO
D. Both B and C

Answer: D) Both B and C

Explanation:

SQL became the standard of ANSI and ISO in the year 1986 and 1987 respectively.

5. Which statement is not true about SQL?

A. Using SQL in relational databases is all about inserting, updating, and deleting data.
B. Sample data can also be described with the aid of this tool.
C. It helps develop relational database functions, events, and views.
D. A SQL user can also set restrictions and permissions for a table column, a view, and a
stored procedure.

Answer: B) Sample data can also be described with the aid of this tool

Explanation:

Structured data can also be described with the aid of this tool.

6. SQL contains which component in its process?

A. Optimization Engines
B. SQL Query Engines
C. Query Dispatchers
D. All of the above

Answer: D) All of the above

Explanation:
The SQL query process consists of components such as Optimization Engines, SQL Query
Engines, and Query Dispatchers, etc.

7. Determine the correct SQL command?

A. CREATE
B. UPDATE
C. DELETE
D. All of the above

Answer: D) All of the above

Explanation:

Commonly used SQL commands are CREATE, UPDATE, and DELETE, etc.

8. What is the work of CREATE command?

A. Using this command, you can remove or erase recorded information from a database
table.
B. It enables you to create new databases, tables, table views, and other objects using
this command.
C. Inserting records or data into the database tables is accomplished with this command.
In addition to inserting records in single rows, we can insert records in multiple rows
as well.
D. A single or multiple rows can be accessed using this command from one or more
tables of a database. Using the WHERE clause with this command is also possible.

Answer: B) It enables you to create new databases, tables, table views, and other objects
using this command

Explanation:

INSERT command enables you to create new databases, tables, table views, and other
objects.

9. What is the work of UPDATE command?

A. A single or multiple rows can be accessed using this command from one or more
tables of a database. Using the WHERE clause with this command is also possible.
B. Using this command, you can remove or erase recorded information from a database
table.
C. Database data can be updated or changed using this command.
D. It enables you to create new databases, tables, table views, and other objects using
this command.

Answer: C) Database data can be updated or changed using this command

Explanation:

Using UPDATE command, Database data can be updated or changed.

10. What is the work of DELETE command?

A. A single or multiple rows can be accessed using this command from one or more
tables of a database. Using the WHERE clause with this command is also possible.
B. Database data can be updated or changed using this command.
C. Database objects such as tables, table views, and other objects can be deleted using
this command.
D. Using this command, you can remove or erase recorded information from a database
table.

Answer: D) Using this command, you can remove or erase recorded information from a
database table

Explanation:

Using DELETE command, you can remove or erase recorded information from a database
table.

11. What is the work of SELECT command?

A. Database objects such as tables, table views, and other objects can be deleted using
this command.
B. Database objects such as tables, table views, and other objects can be deleted using
this command.
C. One or more rows from one or more tables of the database can be accessed with this
command. Using the WHERE clause with this command is also possible.
D. It enables you to create new databases, tables, table views, and other objects using
this command.

Answer: C) One or more rows from one or more tables of the database can be accessed with
this command. Using the WHERE clause with this command is also possible
Explanation:

Using the SELECT command, one or more rows from one or more tables of the database can
be accessed. Using the WHERE clause with this command is also possible.

12. What is the work of DROP command?

A. Using this command, you can remove or erase recorded information from a database
table.
B. Database objects such as tables, table views, and other objects can be deleted using
this command.
C. One or more rows from one or more tables of the database can be accessed with this
command. Using the WHERE clause with this command is also possible.
D. It enables you to create new databases, tables, table views, and other objects using
this command.

Answer: B) Database objects such as tables, table views, and other objects can be deleted
using this command

Explanation:

Using the DROP command, Database objects such as tables, table views, and other objects
can be deleted.

13. What is the work of INSERT command?

A. Inserting records or data into the database tables is accomplished with this command.
In addition to inserting records in single rows, we can insert records in multiple rows
as well.
B. Database objects such as tables, table views, and other objects can be deleted using
this command.
C. One or more rows from one or more tables of the database can be accessed with this
command. Using the WHERE clause with this command is also possible.
D. It enables you to create new databases, tables, table views, and other objects using
this command.

Answer: A) Inserting records or data into the database tables is accomplished with this
command. In addition to inserting records in single rows, we can insert records in multiple
rows as well

Explanation: Using the INSERT command, inserting records or data into the database tables
is accomplished. In addition to inserting records in single rows, we can insert records in
multiple rows as well.
14. Which statement is not true?

A. SQL is rational whereas No-SQL is non-rational.


B. SQL follows BASE Model whereas No-SQL follows ACID Model.
C. SQL database are vertically scalable whereas No-SQL database are horizontally
scalable.
D. No-SQL databases are preferable to store hierarchical data in comparison SQL
databases.

Answer: B) SQL follows BASE Model whereas No-SQL follows ACID Model

Explanation:

SQL follows ACID Model whereas No-SQL follows BASE Model.

15. Which statement is true about the SQL?

A. SQL databases are vertically scalable.


B. SQL follows BASE Model.
C. SQL database cannot handle complex queries.
D. SQL database does not require object-relational mapping.

Answer: A) SQL databases are vertically scalable

Explanation:

SQL is vertically scalable. SQL follows the ACID Model. SQL database can easily handle
complex queries. SQL database does require object-relational mapping.

16. Which statement is true about the No-SQL?

A. No-SQL follows ACID Model.


B. No-SQL does require object-relational mapping.
C. Dynamic schemas for unstructured data are used in No-SQL databases.
D. No-SQL databases are not preferable for storage of hierarchal data.

Answer: C) Dynamic schemas for unstructured data are used in No-SQL databases

Explanation: Dynamic schemas for unstructured data are used in No-SQL databases. No-SQL
follows BASE Model. No-SQL does not require object-relational mapping. No-SQL databases
are preferable for the storage of hierarchal data.
17. SQL has the advantage of?

A. SQL require a lot of programming.


B. SQL provides High-Speed Query Processing.
C. SQL follows the standard languages of ANSI and ISO.
D. SQL is easily portable.

Answer: A) SQL require a lot of programming

Explanation:

SQL does not required programming.

18. SQL has the disadvantage of?

A. SQL is cheap.
B. SQL interface is simple.
C. Both A and B.
D. None of the above.

Answer: D) None of the above

Explanation:

SQL has the disadvantage that it is costly and its interface is complex.

19. What is meant by Partial Database Control?

A. Business rules are hidden.


B. Users or professionals can't have the full control over the database.
C. Both A and B
D. None of the above

Answer: C) Both A and B

Explanation:

SQL has the disadvantage of Partial Database Control which means that the business rules are
hidden and the users or professionals can't have full control over the database.
20. What is meant by 'SQL is an interactive language'?

A. Learning and understanding SQL is easy


B. It can also be used for communicating with the database.
C. In a few seconds, complex queries can also be answered using this language.
D. All of the above

Answer: D) All of the above

Explanation:

SQL is an interactive language – it means that learning and understanding SQL is easy, it can
also be used for communicating with the database and In a few seconds, complex queries can
also be answered using this language.

MCQ | SQL – Basics (Set 2)

1. Syntax of the Structured Query Language is ____?

A. Case-sensitive
B. Not case-sensitive

Answer: B) Not case-sensitive

Explanation:

Syntax of the Structured Query Language is not case-sensitive.

2. Which of the following statement is false?

A. There is no difference between a lower case and upper case keyword in SQL.
B. It is easier to read SQL queries when the keywords are in lowercase.
C. An SQL statement's syntax is determined by its text line.
D. One or more SQL statements can be placed on a single line of text.

Answer: B) It is easier to read SQL queries when the keywords are in lowercase

Explanation:

It is easier to read SQL queries when the keywords are in uppercase


3. Which of the following statement is true?

A. SQL statements are used for most operations in a database.


B. Relational algebra and tuple relationship calculus are needed for SQL syntax.
C. All of the above
D. None of the above

Answer: C) All of the above

Explanation:

SQL statements are used for most operations in a database and Relational algebra and tuple
relationship calculus are needed for SQL syntax.

4. Which of the following is not an SQL Statement?

A. SELECT Statement
B. UPDATE Statement
C. TRUNCATE TABLE Statement
D. FROM Statement

Answer: D) FROM Statement

Explanation:

SQL Statements are SELECT, UPDATE, TRUNCATE TABLE.

5. What does the SELECT Statement do?

A. Data is read from the SQL database by this statement and displayed to the database
user.
B. The stored data in the SQL database is changed or modified by this SQL statement.
C. By deleting the stored data, this SQL statement deletes the database.
D. A new table in SQL is created using this SQL statement.

Answer: A) Data is read from the SQL database by this statement and displayed to the
database user

Explanation:

Using SELECT Statement, Data is read from the SQL database and displayed to the database
user.

6. What does the UPDATE Statement do?

A. By deleting the stored data, this SQL statement deletes the database.
B. A new table in SQL is created using this SQL statement.
C. The stored data in the SQL database is changed or modified by this SQL statement.
D. Columns in the SQL database can be created, deleted, or modified with this SQL
statement.

Answer: C) The stored data in the SQL database is changed or modified by this SQL statement

Explanation:

The stored data in the SQL database is changed or modified by UPDATE SQL statement.

7. What does the DELETE Statement do?

A. A new table in SQL is created using this SQL statement.


B. By deleting the stored data, this SQL statement deletes the database.
C. Columns in the SQL database can be created, deleted, or modified with this SQL
statement.
D. By executing this SQL statement, you remove the table and all the information that it
contains, including the structure, views, permissions, and triggers.

Answer: B) By deleting the stored data, this SQL statement deletes the database

Explanation:

By deleting the stored data, DELETE SQL statement deletes the database.

8. What does the CREATE TABLE Statement do?

A. The stored data in the SQL database is changed or modified by this SQL statement.
B. By deleting the stored data, this SQL statement deletes the database.
C. A new table in SQL is created using this SQL statement.
D. Columns in the SQL database can be created, deleted, or modified with this SQL
statement.

Answer: C) A new table in SQL is created using this SQL statement

Explanation:

A new table in SQL is created using CREATE TABLE SQL statement.

9. What does the ALTER TABLE Statement do?

A. By deleting the stored data, this SQL statement deletes the database.
B. Columns in the SQL database can be created, deleted, or modified with this SQL
statement.
C. A new table in SQL is created using this SQL statement.
D. The table, its structure, views, permissions, and triggers will also be deleted or
removed with this SQL statement.
Answer: B) Columns in the SQL database can be created, deleted, or modified with this SQL
statement

Explanation:

Columns in the SQL database can be created, deleted, or modified with ALTER TABLE SQL
statement.

10. What does the DROP TABLE Statement do?

A. The table, its structure, views, permissions, and triggers will also be deleted or
removed with this SQL statement.
B. A new table in SQL is created using this SQL statement.
C. Columns in the SQL database can be created, deleted, or modified with this SQL
statement.
D. A new database will be created through this SQL statement.

Answer: A) The table, its structure, views, permissions, and triggers will also be deleted or
removed with this SQL statement

Explanation:

The table, its structure, views, permissions, and triggers will also be deleted or removed with
DROP TABLE SQL statement.

11. What does the CREATE DATABASE Statement do?

A. Columns in the SQL database can be created, deleted, or modified with this SQL
statement.
B. The table, its structure, views, permissions, and triggers will also be deleted or
removed with this SQL statement.
C. In the database management system, this SQL statement deletes the existing
database, together with all the database tables and views.
D. A new database will be created through this SQL statement.

Answer: D) A new database will be created through this SQL statement

Explanation:

A new database will be created through CREATE DATABASE SQL statement.

12. What does the DROP DATABASE Statement do?

A. The table, its structure, views, permissions, and triggers will also be deleted or
removed with this SQL statement.
B. In the database management system, this SQL statement deletes the existing
database, together with all the database tables and views.
C. A new database will be created through this SQL statement.
D. In this SQL statement, the data or records are inserted into an existing database table.
One query statement can insert multiple records simultaneously using this statement.

Answer: B) In the database management system, this SQL statement deletes the existing
database, together with all the database tables and views

Explanation:

In the database management system, DROP DATABASE SQL statement deletes the existing
database, together with all the database tables and views.

13. What does the INSERT INTO Statement do?

A. In this SQL statement, the data or records are inserted into an existing database table.
One query statement can insert multiple records simultaneously using this statement.
B. A new database will be created through this SQL statement.
C. In the database management system, this SQL statement deletes the existing
database, together with all the database tables and views.
D. By executing this SQL statement, all records in the SQL database will be deleted.

Answer: A) In this SQL statement, the data or records are inserted into an existing database
table. One query statement can insert multiple records simultaneously using this statement

Explanation:

In INSERT INTO SQL statement, the data or records are inserted into an existing database
table. One query statement can insert multiple records simultaneously using this statement.

14. What does the TRUNCATE TABLE Statement do?

A. In the database management system, this SQL statement deletes the existing
database, together with all the database tables and views.
B. In this SQL statement, the data or records are inserted into an existing database table.
One query statement can insert multiple records simultaneously using this statement.
C. By executing this SQL statement, all records in the SQL database will be deleted.
D. The data specified in this table or view is reported in this SQL statement.

Answer: C) By executing this SQL statement, all records in the SQL database will be deleted

Explanation:

By executing TRUNCATE TABLE SQL statement, all records in the SQL database will be
deleted.
15. What does the DESCRIBE Statement do?

A. In this SQL statement, the data or records are inserted into an existing database table.
One query statement can insert multiple records simultaneously using this statement.
B. By executing this SQL statement, all records in the SQL database will be deleted.
C. Specify the columns of the table in this SQL statement to return distinct values.
D. The data specified in this table or view is reported in this SQL statement.

Answer: D) The data specified in this table or view is reported in this SQL statement

Explanation:

The data specified in this table or view is reported in DESCRIBE SQL statement.

16. What does the DISTINCT Clause do?

A. Specify the columns of the table in this SQL clause to return distinct values.
B. By executing this SQL statement, all records in the SQL database will be deleted.
C. The data specified in this table or view is reported in this SQL statement.
D. Changes made in the SQL database transaction are permanently saved using this SQL
statement.

Answer: A) Specify the columns of the table in this SQL clause to return distinct values

Explanation:

Specify the columns of the table in DISTINCT SQL clause to return distinct values.

17. What does the COMMIT Statement do?

A. The data specified in this table or view is reported in this SQL statement.
B. Changes made in the SQL database transaction are permanently saved using this SQL
statement.
C. Specify the columns of the table in this SQL statement to return distinct values.
D. By running this SQL statement, the transaction will be undone and the operations not
yet saved to the SQL database will be undone.

Answer: B) Changes made in the SQL database transaction are permanently saved using this
SQL statement

Explanation:

Changes made in the SQL database transaction are permanently saved using COMMIT SQL
statement.

18. What does the ROLLBACK Statement do?

A. Specify the columns of the table in this SQL statement to return distinct values.
B. Changes made in the SQL database transaction are permanently saved using this SQL
statement.
C. By running this SQL statement, the transaction will be undone and the operations not
yet saved to the SQL database will be undone.
D. An index is created in a SQL database table with this SQL statement.

Answer: C) By running this SQL statement, the transaction will be undone and the operations
not yet saved to the SQL database will be undone

Explanation:

By running ROLLBACK SQL statement, the transaction will be undone and the operations not
yet saved to the SQL database will be undone.

19. What does the CREATE INDEX Statement do?

A. An index is created in a SQL database table with this SQL statement.


B. Changes made in the SQL database transaction are permanently saved using this SQL
statement.
C. By running this SQL statement, the transaction will be undone and the operations not
yet saved to the SQL database will be undone.
D. The SQL database table's index is deleted using this SQL statement.

Answer: A) An index is created in a SQL database table with this SQL statement

Explanation:

An index is created in a SQL database table with CREATE INDEX SQL statement.

20. What does the DROP INDEX Statement do?

A. By running this SQL statement, the transaction will be undone and the operations not
yet saved to the SQL database will be undone.
B. The SQL database table's index is deleted using this SQL statement.
C. An index is created in a SQL database table with this SQL statement.
D. An existing SQL database is selected with this SQL statement. A database must be
selected from several existing databases before you can perform operations on the
table.

Answer: B) The SQL database table's index is deleted using this SQL statement

Explanation:

The SQL database table's index is deleted using DROP INDEX SQL statement.
MCQ | SQL – Data Types

1. In the database table, data types describe the kind of ___ that it can contain.

A. Table
B. Data
C. Number
D. None of the above

Answer: B) Data

Explanation:

In the database table, data types describe the kind of Data that they can contain.

2. In how many categories data types has been classified?

A. 2
B. 3
C. 4
D. 5

Answer: B) 3

Explanation:

Data types are classified into 3 categories,

• String Data types


• Numeric Data types
• Date and time Data types

3. Name of the data type categories are,

A. String Data types


B. Numeric Data types
C. Date and time Data types
D. All of the above

Answer: D) All of the above

Explanation:

Data types are classified into 3 categories named as String, numeric, and date and time
category.
4. Which of the following is not MySQL String Data Type?

A. TEXT(Size)
B. TINYTEXT
C. MEDIUMTEXT
D. LARGETEXT

Answer: D) LARGETEXT

Explanation:

MySQL String Data Types are TEXT(Size), TINYTEXT, MEDIUMTEXT, and LONGTEXT.

5. Which of the following is not MySQL Numeric Data Type?

A. BIT(Size)
B. CHAR(Size)
C. INTEGER(Size)
D. INT(Size)

Answer: B) CHAR(Size)

Explanation:

MySQL Numeric Data Types are BIT(Size), INT(Size), and INTEGER(Size).

6. Which of the following are not MySQL Date and Time Data Type?

A. DATE
B. TIME(fsp)
C. YEAR
D. None of the above

Answer: D) None of the above

Explanation:

MySQL Date and Time Data Types are DATE, TIME(fsp), and YEAR.

7. Which of the following is SQL Server String Data Type?

A. ntext
B. binary(n)
C. varbinary
D. All of the above

Answer: D) All of the above

Explanation:

SQL Server String Data Types are ntext, binary(n), and varbinary.

8. Which of the following is SQL Server Numeric Data Type?

A. image
B. nchar
C. money
D. cursor

Answer: C) money

Explanation:

money is the SQL Server Numeric Data Type.

9. Which of the following is SQL Server Date and Time Data Type?

A. timestamp
B. sql_variant
C. real
D. text

Answer: a) timestamp

Explanation:

timestamp is SQL Server Date and Time Data Type.

10. TINYTEXT can hold the maximum length of ___ characters?

A. 254
B. 255
C. 256
D. 257
Answer: B) 255

Explanation:

TINYTEXT can hold the maximum length of 255 characters.

11. What is the full form of BLOB?

A. Binary Long Objects


B. Binary Least Objects
C. Binary Large Objects
D. Binary Large Orientation

Answer: C) Binary Large Objects

Explanation:

Full form of BLOB is "Binary Large Objects".

12. How MySQL determines which one to use, FLOAT or DOUBLE, using the p parameter?

A. If p comes between 0 to 25, data type becomes FLOAT(). If p comes between 26 to


54, data type becomes DOUBLE().
B. If p comes between 26 to 54, data type becomes FLOAT(). If p comes between 0 to
25, data type becomes DOUBLE().
C. If p comes between 25 to 53, data type becomes FLOAT(). If p comes between 0 to
24, data type becomes DOUBLE().
D. If p comes between 0 to 24, data type becomes FLOAT(). If p comes between 25 to
53, data type becomes DOUBLE().

Answer: D) If p comes between 0 to 24, data type becomes FLOAT(). If p comes between 25
to 53, data type becomes DOUBLE()

Explanation:

MySQL determines to use FLOAT or DOUBLE using the p parameter. If p comes between 0 to
24, the data type becomes FLOAT(). If p comes between 25 to 53, the data type
becomes DOUBLE().

13. What does BOOL mean in MySQL Numeric Data Types?

A. A Boolean value is specified by this variable. When a value is nonzero, it is considered


false, and zero is considered true.
B. A Boolean value is specified by this variable. When a value is nonzero, it is considered
true, and zero is considered false.
C. A Boolean value is specified by this variable. When a value is nonzero, it is considered
true, and zero is also considered true.
D. A Boolean value is specified by this variable. When a value is nonzero, it is considered
false, and zero is also considered false.

Answer: B) A Boolean value is specified by this variable. When a value is nonzero, it is


considered true, and zero is considered false.

Explanation:

A Boolean value is specified by this variable. When a value is nonzero, it is considered true,
and zero is considered false.

14. What can be the maximum size of char(n) in SQL Server String Data Type?

A. 7000
B. 8000
C. 9000
D. 10000

Answer: B) 8000

Explanation:

A maximum of 8000 characters is the size of char(n) in SQL Server String Data Types.

15. What is the difference between nchar and nvarchar?

A. nchar is fixed and nvarchar is variable.


B. nchar is variable and nvarchar is fixed.
C. nchar has the maximum size of 4000 characters and nvarchar has the maximum size
of 8000 characters.
D. nchar has the maximum size of 800 characters and nvarchar has the maximum size of
4000 characters.

Answer: A) nchar is fixed and nvarchar is variable.

Explanation:

nchar is fixed and nvarchar is variable width Unicode string data type.

16. What is the difference between nvarchar and ntext?

A. nvarchar is fixed and ntext is variable.


B. nvarchar is variable and ntext is fixed.
C. nvarchar can be of the maximum size upto 4000 characters and ntext can be of the
maximum size upto 2GB of the text data.
D. nvarchar can be of the maximum size upto 4000 characters and ntext can be of the
maximum size upto 1GB of the text data.

Answer: C) nvarchar can be of the maximum size upto 4000 characters and ntext can be of
the maximum size upto 2GB of the text data

Explanation:

nvarchar can be of the maximum size upto 4000 characters and ntext can be of the maximum
size upto 2GB of the text data.

17. Bit is an integer that can be –

A. 0
B. 1
C. Null
D. All of the above

Answer: D) All of the above

Explanation:

Bit is an integer that can be 0, 1 or Null.

18. What is the full form of GUID?

A. Guided Unique Identifier


B. Guided Unique Interpreter
C. Globally Unique Identifier
D. Globally Unique Interpreter

Answer: C) Globally Unique Identifier

Explanation:

Full form of GUID is "Globally Unique Identifier".

19. What is the similarity between CLOB and NCLOB Oracle Large Object Data Types?

A. Both CLOB and NCLOB are used for multibyte national character set data.
B. Both CLOB and NCLOB can range upto 2^32-1 bytes or 4 GB.
C. Both CLOB and NCLOB can range upto 2^32-1 bytes or 8GB.
D. Both CLOB and NCLOB are used for singlebyte and multibyte national character set
data.

Answer: B) Both CLOB and NCLOB can range upto 2^32-1 bytes or 4 GB
Explanation:

Both CLOB and NCLOB can range upto 2^32-1 bytes or 4 GB.

20. What is the difference between VARCHAR and VARCHAR2?

A. VARCHAR can store upto 4000 bytes and VARCHAR2 can store upto 8000 bytes.
B. VARCHAR can store upto 2000 bytes and VARCHAR2 can store upto 4000 bytes.
C. Both VARCHAR and VARCHAR2 are similar but use of VARCHAR2 is mostly
recommended.
D. There is no similarity between VARCHAR and VARCHAR2.

Answer: C) Both VARCHAR and VARCHAR2 are similar but use of VARCHAR2 is mostly
recommended

Explanation:

Both VARCHAR and VARCHAR2 are similar but use of VARCHAR2 is mostly recommended.

MCQ | SQL – Operators

1. Using a WHERE clause in a SQL query is used to specify SQL reserved words and characters,
known as ____?

A. Operators
B. Data Types
C. Numbers
D. Syntax

Answer: A) Operators

Explanation:

Using a WHERE clause in a SQL query is used to specify SQL reserved words and characters,
known as Operators.

2. SQL Operator can be,

A. Unary
B. Binary
C. Both A and B
D. None of the above

Answer: C) Both A and B

Explanation:

SQL Operator can be Unary and Binary.


3. Number of operands used by Unary Operator is?

A. 1
B. 2
C. 3
D. 4

Answer: A) 1

Explanation:

Number of operators used by Unary Operand is 1.

4. Numbers of operand used by Binary Operators are?

A. 1
B. 2
C. 3
D. 4

Answer: B) 2

Explanation:

Numbers of operand used by Binary Operand are 2.

5. Which one of the syntaxes given below is of Binary Operator?

A. Operator SQL _Operand


B. Operand2 SQL _Operator Operand1
C. Operand1 SQL _Operator Operand1
D. Operand1 SQL _Operator Operand2

Answer: D) Operand1 SQL _Operator Operand2

Explanation:

Operand1 SQL _Operator Operand2 is the syntax of Binary Operator.

6. When an expression includes ___ SQL operator(s), the sequence in which they are
evaluated is known as the SQL operator's precedence.

A. 0
B. 1
C. Multiple
D. NULL

Answer: C) Multiple
Explanation:

When an expression includes Multiple SQL operators, the sequence in which they are
evaluated is known as the SQL operator's precedence.

7. Which of the statement is true?

A. The precedence-low operators are evaluated last in SQL.


B. The precedence-high operators are evaluated first in SQL.
C. Both A and B
D. None of the above

Answer: C) Both A and B

Explanation:

The precedence-high operators are evaluated first in SQL and precedence-low operators are
evaluated last in SQL.

8. Select the correct order of precedence among the following?

A. OR > NOT > + > **


B. NOT > OR > ** > +
C. ** > + > OR > NOT
D. ** > + > NOT > OR

Answer: D) ** > + > NOT > OR

Explanation:

Exponentiation operator (**) > Identity operator (+) > Logical Negation Operator (NOT) >
Inclusion Operator (OR).

9. Which of the following statement is correct?

A. Comparison Operator has higher precedence than Conjuction Operator.


B. Identity Operator has higher precedence than Multiplication Operator.
C. Both A and B
D. None of the above

Answer: C) Both A and B

Explanation:

Comparison Operator has higher precedence than Conjunction Operator and Identity
Operator has higher precedence than Multiplication Operator.
10. Which of these are the types of operators?

A. Arithmetic
B. Comparison
C. Set
D. All of the above

Answer: D) All of the above

Explanation:

Arithmetic, Comparison, and Set, all are types of operators.

11. Which of the following is NOT the SQL Arithmetic Operator?

A. Addition
B. Subtraction
C. Unary
D. Modulus

Answer: C) Unary

Explanation:

Addition, Subtraction and Modulus are all the SQL Arithmetic Operators.

12. Which of the following statement is TRUE for SQL Additional Operator?

A. SELECT operand1-operand2;
B. SELECT operand1*operand2;
C. SELECT operand1+operand2;
D. SELECT operand1>operand2;

Answer: C) SELECT operand1+operand2;

Explanation:

SELECT operand1+operand2; is the correct statement for SQL Additional Operator.

13. The numerical values of two ___ of the ___ table can be easily subtracted using SQL
Subtraction Operator.

A. Rows, same
B. Columns, same
C. Rows, different
D. Columns, different

Answer: B) Columns, same


Explanation:

The numerical values of two columns of the same table can be easily subtracted using SQL
Subtraction Operator.

14. Which of the following statement is correct for SQL Multiplication Operator?

A. SELECT Operand1+Operand2;
B. SELECT Operand1*Operand2;
C. SELECT Operand1**Operand2;
D. SELECT Operand1<Operand2;

Answer: B) SELECT Operand1*Operand2;

Explanation:

SELECT Operand1*Operand2 statement is correct for SQL Multiplication Operator.

15. SQL Division operator divides the operand on the ____ side by the operand on the ____
side.

A. Left, Left
B. Right, Left
C. Left, Right
D. Right, Right

Answer: C) Left, Right

Explanation:

SQL Division operator divides the operand on the left side by the operand on the right side.

16. The SQL Modulus Operator returns the,

A. Quotient
B. Percentage
C. Sum
D. Reminder

Answer: D) Reminder

Explanation:

The SQL Modulus Operator returns the Reminder.


17. Which of the following is not the SQL Comparison Operator?

A. SQL Equal Operator (=)


B. SQL Less Than Operator (<)
C. SQL Greater Than Operator (>)
D. All of the above

Answer: D) All of the above

Explanation:

SQL Equal Operator (=), SQL Less Than Operator (<), and SQL Greater Than Operator (>) are
all SQL Comparison Operators.

18. Using which SQL Comparison Operator can we find the data that matches our query?

A. SQL Not Equal Operator (!=)


B. SQL Equal Operator (=)
C. SQL Greater Than Operator (>)
D. SQL Less Than Operator (<)

Answer: B) SQL Equal Operator (=)

Explanation:

Using SQL Equal Operator from SQL Comparison Operators, we can find the data that
matches our query.

19. Which of the following is a SQL Logical Operator?

A. SQL ALL Operator


B. SQL OR Operator
C. SQL LIKE Operator
D. All of the above

Answer: D) All of the above

Explanation:

SQL ALL, SQL OR and SQL LIKE are all SQL Logical Operators.

20. Which of the following is not a SQL Logical Operator?

A. SQL Equal Operator


B. SQL ANY Operator
C. SQL BETWEEN Operator
D. SQL IN Operator
Answer: A) SQL Equal Operator

Explanation:

SQL ANY, SQL BETWEEN, and SQL IN Operators are all SQL Logical Operators.

MCQ | SQL – Commands: DDL, DML, DCL, TCL, DQL

1. Types of SQL Commands are –

A. DDL
B. DML
C. DCL
D. All of the above

Answer: D) All of the above

Explanation:

Types of SQL Commands are DDL, DML, DCL & TCL.

2. Full form of DDL is –

A. Data Describe Language


B. Definition Data Language
C. Data Definition Language
D. Data Distinct Language

Answer: C) Data Definition Language

Explanation:

Full form of DDL is Data Definition Language.

3. Commands that comes under DDL is/are –

A. CREATE
B. DROP
C. TRUNCATE
D. All of the above

Answer: D) All of the above

Explanation:

Commands that come under DDL are CREATE, ALTER, DROP, TRUNCATE & RENAME.
4. Full form of DML is –

A. Data Multiplication Language


B. Data Manipulation Language
C. Data Modify Language
D. Data Mapping Language

Answer: B) Data Manipulation Language

Explanation:

Full form of DML is Data Manipulation Language.

5. Which of the following is/are TRUE about DDL command?

A. Our data is stored in a table that is described by the schema, thus DDL commands
deal with the schema.
B. With the DDL commands, any structural changes can be made to the table, including
creation, deletion, and alteration.
C. Both A. and B.
D. None of the above

Answer: C) Both A. and B.

Explanation:

In the case of DDL commands:

i. Our data is stored in a table that is described by the schema, thus DDL commands
deal with the schema.
ii. With the DDL commands, any structural changes can be made to the table, including
creation, deletion, and alteration.

6. Command that comes under DML is/are –

A. ROLLBACK
B. GRANT
C. UPDATE
D. All of the above

Answer: C) UPDATE

Explanation:

Commands that comes under DML are INSERT, SELECT, UPDATE & DELETE.
7. Select the correct statement.

A. With the DDL commands, any structural changes can be made to the table, including
creation, deletion, and alteration.
B. With the DML commands, any structural changes can be made to the table, including
creation, deletion, and alteration.
C. With the DCL commands, any structural changes can be made to the table, including
creation, deletion, and alteration.
D. With the TCL commands, any structural changes can be made to the table, including
creation, deletion, and alteration.

Answer: A) With the DDL commands, any structural changes can be made to the table,
including creation, deletion, and alteration

Explanation:

With the DDL commands, any structural changes can be made to the table, including
creation, deletion, and alteration.

8. Full form of DCL is -

A. Data Control Language


B. Data Commit Language
C. Data Common Language
D. Data Concatenate Language

Answer: A) Data Control Language

Explanation:

Full form of DCL is Data Control Language.

9. Command that comes under DCL is/are -

A. GRANT
B. REVOKE
C. Both A. and B.
D. None of the above

Answer: C) Both A. and B.

Explanation:

Commands that comes under DCL are GRAND & REVOKE.


10. Full form of TCL is -

A. Transaction Common Language


B. Transaction Commit Language
C. Transaction Concatenate Language
D. Transaction Control Language

Answer: D) Transaction Control Language

Explanation:

Full form of TCL is Transaction Control Language.

11. Commands that come under TCL is/are -

A. COMMIT
B. ROLLBACK
C. SAVEPOINT
D. All of the above

Answer: D) All of the above

Explanation:

Commands that comes under TCL are COMMIT, ROLLBACK & SAVEPOINT.

12. What is TRUE about SAVEPOINT?

A. Following the completion of a transaction, it must be executed to save all the


operations performed in the transaction.
B. A transaction can be rolled back to its last saved state.
C. A specific part of a transaction can be given a name
D. None of the above

Answer: C) A specific part of a transaction can be given a name

Explanation:

In the case of the SAVEPOINT command, a specific part of a transaction can be given a name.

13. Following the completion of a transaction, it must be executed to save all the operations
performed in the transaction. Here we are talking about which command?

A. REVOKE
B. COMMIT
C. ROLLBACK
D. SAVE
Answer: B) COMMIT

Explanation:

Following the completion of a transaction, the COMMIT command must be executed to save
all the operations performed in the transaction.

14. Difference between GRAND & REVOKE command is/are?

A. The GRANT command can be used to grant a user access to databases and tables
whereas The REVOKE command can be used to revoke all access privileges already
assigned to the user.
B. The REVOKE command can be used to grant a user access to databases and tables
whereas The GRANT command can be used to revoke all access privileges already
assigned to the user.
C. A transaction can be rolled back to its last saved state.
D. None of the above

Answer: A) The GRANT command can be used to grant a user access to databases and tables
whereas The REVOKE command can be used to revoke all access privileges already assigned
to the user

Explanation:

The GRANT command can be used to grant a user access to databases and tables whereas
The REVOKE command can be used to revoke all access privileges already assigned to the
user.

15. Which of the following statement(s) is/are TRUE about DCL?

A. The DCL commands in SQL allow us to control which users have access to the data
stored in SQL tables.
B. There will be certain privileges that each user has; consequently, the data can be
accessed by them.
C. The DCL commands in SQL allow us to grant privileges to a user on the SQL database
and its table(s), or revoke privileges that have already been granted.
D. All of the above

Answer: D) All of the above

Explanation:

About DCL Commands –

1. The DCL commands in SQL allow us to control which users have access to the data
stored in SQL tables.
2. There will be certain privileges that each user has; consequently, the data can be
accessed by them.
3. The DCL commands in SQL allow us to grant privileges to a user on the SQL database
and its table(s), or revoke privileges that have already been granted.

16. The table records can be retrieved using which command?

A. RETRIEVE
B. SELECT
C. CREATE
D. ALTER

Answer: B) SELECT

Explanation:

The table records can be retrieved using the SELECT command.

17. Which command will remove the records from the table, but not affect the structure of
the table?

A. REMOVE
B. DELETE
C. DROP
D. TRUNCATE

Answer: B) DELETE

Explanation:

The TRUNCATE command will remove the records from the table, but not affect the structure
of the table.

18. The records and structure of a table may be removed or deleted from the database using
which command?

A. REMOVE
B. DELETE
C. DROP
D. TRUNCATE

Answer: C) DROP

Explanation:

The records and structure of a table may be removed or deleted from the database using the
DROP command
19. Select the correct statement.

A. DDL consist of 4 commands


B. DCL consist of 2 commands
C. TCL consist of 5 commands
D. DML consist of 3 commands

Answer: B) DCL consist of 2 commands

Explanation:

i. DDL consist of 5 commands, i.e., CREATE, ALTER, DROP, TRUNCATE & RENAME.
ii. DML consist of 4 commands, i.e., SELECT, INSERT, UPDATE & DELETE.
iii. DCL consist of 2 commands, i.e., GRANT & REVOKE.
iv. TCL consist of 3 commands, i.e., COMMIT, ROLLBACK & SAVEPOINT.

20. Which of the following is TRUE about TCL?

A. Transactions can be saved to the database and rolled back with the help of TCL
commands in SQL.
B. There will be certain privileges that each user has; consequently, the data can be
accessed by them using TCL.
C. Our data is stored in a table that is described by the schema, thus TCL commands deal
with the schema.
D. SQL TCL commands can be used to perform any kind of retrieval or manipulation of
the data present in SQL tables.

Answer: A) Transactions can be saved to the database and rolled back with the help of TCL
commands in SQL

Explanation:

Transactions can be saved to the database and rolled back with the help of TCL commands in
SQL.

MCQ | SQL – Auto Increment, Like, Commit and Rollback

1. Which of the following is TRUE about SQL Auto Increment?

A. It increments the unique number automatically.


B. It decrements the unique number automatically.
C. It keeps the unique number constant
D. None of the above

Answer: A) It increments the unique number automatically


Explanation:

SQL Auto Increment increments the unique number automatically.

2. Which of the following is the feature(s) of SQL Auto Increment?

A. In some cases you may not have any unique identifying characteristics in data;
therefore, it makes sense to create a Primary Key.
B. Explicitly initializing and modifying the auto-increment value is possible at any time.
C. Record identifiers can easily be created that are unique to each record.
D. All of the above

Answer: D) All of the above

Explanation:

Features of SQL Auto Increment are:

i. In some cases you may not have any unique identifying characteristics in data;
therefore, it makes sense to create a Primary Key.
ii. Explicitly initializing and modifying the auto-increment value is possible at any time.
iii. Record identifiers can easily be created that are unique to each record.
iv. Automatic incrementing allows flexibility in handling gaps between records.
v. Syntax-speaking, auto-increment queries in SQL are straightforward.

3. Which keyword is used in SQL Server to implement the auto increment?

A. UNIQUE
B. IDENTITY
C. INCREMENT
D. ADD

Answer: B) IDENTITY

Explanation:

IDENTITY keyword is used in SQL Server to implement the auto-increment.

4. In SQL, Like is a __________operator.

A. Relational
B. Logical
C. Additional
D. Unique

Answer: B) Logical

Explanation:
In SQL, LIKE is an Additional operator.

5. SQL Like is NOT used with which of the following statement(s)?

A. DELETE
B. SELECT
C. UPDATE
D. ALTER

Answer: D) ALTER

Explanation:

SQL LIKE is used with DELETE, SELECT and UPDATE statements and not with ALTER
statements.

6. The character(s) which are used independently or in conjunction with SQL Like Operator:

A. %
B. _
C. Both A. and B.
D. None of the above

Answer: C) Both A. and B.

Explanation:

The characters which are used independently or in conjunction with SQL Like Operator are
'%' & '_'.

7. Which of the following is/are transaction control commands in SQL?

A. Commit
B. Rollback
C. Both A. and B.
D. None of the above

Answer: C) Both A. and B.

Explanation:

Commit and Rollback are transaction control commands in SQL.

8. A single unit of work for all commands executed consecutively is known as-

A. Transaction
B. Commit
C. Rollback
D. Control

Answer: A) Transaction

Explanation:

A single unit of work for all commands executed consecutively is known as Transaction.

9. To get the table's previous permanent status, use the ____ command.

A. Commit
B. Transaction
C. Rollback
D. None of the above

Answer: C) Rollback

Explanation:

To get the table's previous permanent status, use the rollback command.

10. In order to start the transaction, the command used is –

A. Mysql > START COMMIT;


B. Mysql > START TRANSACTION;
C. Mysql > START ROLLBACK;
D. None of the above

Answer: B) Mysql > START TRANSACTION;

Explanation:

To start the transaction, Mysql > START ROLLBACK; command is used.

MCQ | SQL – Database

1. SQL CREATE DATABASE is used to,

A. Create a table
B. Create a database
C. Create a column
D. Create a row

Answer: B) Create a database

Explanation:
SQL CREATE DATABASE is used to create a database.

2. A database does not need to be created in ____. A direct table creation option is provided
in ____.

A. MySQL
B. Oracle
C. Both A and B
D. None of the above

Answer: C) Both A and B

Explanation:

A database does not need to be created in Oracle. A direct table creation option is provided
in Oracle.

3. SQL ___ can be used to delete or drop existing databases in a SQL schema.

A. CREATE DATABASE
B. RENAME DATABASE
C. DROP DATABASE
D. SELECT DATABASE

Answer: C) DROP DATABASE

Explanation:

SQL DROP DATABASE can be used to delete or drop existing databases in a SQL schema.

4. Using the ___ statement, a database can be renamed.

A. SQL CREATE DATABASE


B. SQL RENAME DATABASE
C. SQL DROP DATABASE
D. SQL SELECT DATABASE

Answer: B) SQL RENAME DATABASE

Explanation:

Using the SQL RENAME DATABASE statement; a database can be renamed.

5. Which of the following statement is TRUE?

A. A DATABASE name can be renamed.


B. A TABLE name can be renamed.
C. Both A and B
D. None of the above

Answer: C) Both A and B

Explanation:

Both DATABASE and TABLE name can be renamed.

6. Which syntax is correct for Rename Database in MySQL?

A. RENAME old_database_name TO new_database_name;


B. RENAME DATABASE old_database_name TO new_database_name;
C. ALTER old_database_name MODIFY NAME = new_database_name;
D. ALTER DATABASE old_database_name MODIFY NAME = new_database_name;

Answer: B) RENAME DATABASE old_database_name TO new_database_name;

Explanation:

RENAME DATABASE old_database_name TO new_database_name; syntax is used to Rename


Database in MySQL.

7. Which syntax is correct for Rename Database in SQL?

A. RENAME old_database_name TO new_database_name;


B. RENAME DATABASE old_database_name TO new_database_name;
C. ALTER old_database_name MODIFY NAME = new_database_name;
D. ALTER DATABASE old_database_name MODIFY NAME = new_database_name;

Answer: D) ALTER DATABASE old_database_name MODIFY NAME = new_database_name;

Explanation:

ALTER DATABASE old_database_name MODIFY NAME = new_database_name; syntax is used


to Rename Database in SQL.

8. Which statement is used to select the database in SQL?

A. SELECT
B. USE
C. ALTER
D. CREATE

Answer: B) USE

Explanation:

USE statement is used to select the database in SQL.


9. Which statement is used to select the database in Oracle?

A. USE
B. SELECT
C. RENAME
D. None of the above

Answer: D) None of the above

Explanation:

In Oracle, the database does not need to be selected.

10. Which syntax is used to show all the databases?

A. USE DATABASES;
B. SELECT DATABASES;
C. SHOW DATABASES;
D. None of the above

Answer: C) SHOW DATABASES;

Explanation:

SHOW DATABASES; syntax is used to show all the databases.

MCQ | SQL – Table

1. In DBMS, table is known as _____ and row is known as _____.

A. Relation, Tuple
B. Tuple, Tuple
C. Tuple, Relation
D. Relation, Relation

Answer: A) Relation, Tuple

Explanation:

In DBMS, table is known as Relation and row is known as Tuple.

2. Select the statement which is TRUE?

A. In a table, there could be any number of rows and any number of columns.
B. In a table, there could be any number of rows and specified number of columns.
C. In a table, there could be any number of columns and specified number of rows.
D. In a table, there could be specified number of rows and specified number of columns.

Answer: B) In a table, there could be any number of rows and specified number of columns

Explanation:

In a table, there could be any number of rows and specified number of columns.

3. Select the statement which is TRUE?

A. In case a transaction is rolled back, the data allied with table variable also get rolled
back.
B. In case a transaction is rolled back, the data allied with table variable does not roll
back.
C. In case a transaction is not rolled back, the data allied with table variable get rolled
back.
D. None of the above.

Answer: B) In case a transaction is rolled back, the data allied with table variable does not roll
back

Explanation:

In case a transaction is rolled back, the data allied with table variable does not roll back.

4. Temporary variables use ____ resources than table variables.

A. More
B. Less
C. Equal
D. None of the above

Answer: A) More

Explanation:

Temporary variables use more resources than table variables.

5. Input and output parameters can be derived from table variables.

A. True
B. False

Answer: B) False

Explanation:

Input and output parameters can’t be derived from table variables.


6. What is SQL CREATE Table used for?

A. To Update table
B. To Create table
C. To Delete table
D. None of the above

Answer: B) To Create table

Explanation:

SQL CREATE Table is used to create table in a database.

7. For integer value, which data type is supported in Oracle?

A. INT
B. Number
C. Digit
D. None of the above

Answer: B) Number

Explanation:

For Integer Value, Number data type is supported in Oracle.

8. To delete table definition and all data from the table, which statement is used?

A. DELETE
B. DROP
C. ALTER
D. None of the above

Answer: B) DROP

Explanation:

To delete table definition and all data from the table, DROP statement is used.

9. What is the difference between DELETE and TRUNCATE statements?

A. DELETE statement free up the space kept in check by the table whereas TRUNCATE
statement does not free up the space kept in check by the table.
B. DELETE statement does not free up the space kept in check by the table whereas
TRUNCATE statement free up the space kept in check by the table.
C. DELETE statement only deletes rows from the table whereas TRUNCATE statement
can only delete columns from the table.
D. DELETE statement only deletes columns from the table whereas TRUNCATE
statement can only delete rows from the table.

Answer: B) DELETE statement does not free up the space kept in check by the table whereas
TRUNCATE statement free up the space kept in check by the table

Explanation:

DELETE statement does not free up the space kept in check by the table whereas TRUNCATE
statement free up the space kept in check by the table.

10. When the table is dropped:

A. Table structure is dropped


B. Integrity constraints are dropped
C. Relationship is dropped
D. All of the above

Answer: D) All of the above

Explanation:

When the table is dropped, the table structure, integrity constraints, relationship and access
privileges are dropped.

11. When the table is truncated:

A. Table structure is dropped


B. Integrity constraints are dropped
C. Relationship is dropped
D. None of the above

Answer: D) None of the above

Explanation:

When the table is truncated, table structure remains same; therefore none of the above
problems occur.

12. In SQL, which statement can help in changing the name of the table?

A. RENAME
B. ALTER
C. Both A) and B)
D. None of the above

Answer: C) Both A) and B)


Explanation:

In SQL, RENAME and ALTER statement can help change the name of the table.

13. TRUNCATE TABLE requires:

A. WHERE clause
B. HAVING clause
C. Both a and b
D. None of the above

Answer: D) None of the above

Explanation:

TRUNCATE TABLE does not require any clause.

14. Select the correct statement.

A. TRUNCATE TABLE is faster than DELETE TABLE statement.


B. TRUNCATE TABLE uses fewer resources than DELETE TABLE statement.
C. Both A) and B)
D. None of the above

Answer: C) Both A) and B)

Explanation:

TRUNCATE TABLE uses fewer resources and is faster than DELETE TABLE command.

15. SELECT INTO statement-

A. Select the content from a table.


B. Rename the content in a table.
C. Copy the content from one table into another existing table.
D. None of the above

Answer: C) Copy the content from one table into another existing table

Explanation:

SELECT INTO statement copy the content from one table into another existing table.

16. Which of the following statement is TRUE?

A. At run time, temporary tables can be created.


B. Temporary table can do similar operations to normal table.
C. Both A) and B)
D. None of the above

Answer: C) Both A) and B)

Explanation:

At run time, temporary tables can be created and temporary table can do similar operations
to normal table.

17. How many temp tables are there?

A. 1
B. 2
C. 3
D. 4

Answer: B) 2

Explanation:

There are 2 types of temp tables.

18. Which of the following are the types of the temp tables?

A. Local Temp
B. Global Temp
C. Both A) and B)
D. None of the above

Answer: C) Both A) and B)

Explanation:

Local and Global temp, both are the types of the temp tables.

19. Local Temp Variable is used with which sign?

A. ?
B. @
C. #
D. &

Answer: C) #

Explanation:

Local Temp Variable is used with # sign.


20. Global Temp Variable is used with which sign?

A. ###
B. ####
C. #
D. ##

Answer: D) ##

Explanation:

Global Temp Variable is used with Double-Hash (##) sign.

MCQ | SQL – Select, Clause, Order By, Insert, Update and Delete Statements

1. Which one is not the OPTIONAL Clause in SELECT statement?

A. WHERE
B. ORDER BY
C. HAVE
D. HAVING

Answer: C) HAVE

Explanation:

WHERE, ORDER BY and HAVING are all OPTIONAL Clauses in SELECT statement.

2. Which statement is TRUE about the WHERE Clause?

A. In order to retrieve rows, WHERE Clause is used.


B. In order to group the rows, WHERE Clause is used.
C. In order to select the defined groups, WHERE Clause is used.
D. In order to return the rows, WHERE Clause is used.

Answer: A) In order to retrieve rows, WHERE Clause is used

Explanation:

In order to retrieve rows, WHERE Clause is used.

3. Which statement is TRUE about the GROUP BY Clause?

A. In order to retrieve rows, GROUP BY Clause is used.


B. In order to group the rows that share the same property, GROUP BY Clause is used.
C. In order to select the defined groups, GROUP BY Clause is used.
D. In order to return the rows, GROUP BY Clause is used.
Answer: B) In order to group the rows that share the same property, GROUP BY Clause is
used

Explanation:

In order to group the rows that share the same property, GROUP BY Clause is used.

4. Which statement is TRUE about the HAVING Clause?

A. In order to group the rows, HAVING Clause is used.


B. In order to return the rows, HAVING Clause is used.
C. In order to select the defined groups by the GROUP BY Clause, HAVING Clause is used.
D. None of the above

Answer: C) In order to select the defined groups by the GROUP BY Clause, HAVING Clause is
used

Explanation:

In order to select the defined groups by the GROUP BY Clause, HAVING Clause is used.

5. Which statement is TRUE about the ORDER BY Clause?

A. In order to return the rows in a specific order, ORDER BY Clause is used.


B. In order to group the rows, ORDER BY Clause is used.
C. In order to select the defined groups, ORDER BY Clause is used.
D. None of the above

Answer: A) In order to return the rows in a specific order, ORDER BY Clause is used

Explanation:

In order to return the rows in a specific order, ORDER BY Clause is used.

6. Which of the following clause cannot be optional in SQL SELECT Statement?

A. WHERE
B. GROUP BY
C. ORDER BY
D. None of the above

Answer: D) None of the above

Explanation:

WHERE, GROUP BY and ORDER BY all are optional clauses in SQL SELECT Statement.
7. Which of the following clause is optional in SQL SELECT Statement?

A. SELECT
B. FROM
C. HAVING
D. None of the above

Answer: C) HAVING

Explanation:

HAVING Clause is optional in SQL SELECT Statement.

8. Which clause is used to retrieve a unique element from the table?

A. SELECT UNIQUE
B. SELECT DISTINCT
C. Both A) and B)
D. None of the above

Answer: C) Both A) and B)

Explanation:

SELECT UNIQUE and SELECT DISTINCT clauses are used to retrieve a unique element from a
table.

9. What is the functionality of SQL COUNT?

A. It returns the no of record of table


B. It returns the no of record of database
C. It returns the no of record of row
D. It returns the no of record of column

Answer: A) It returns the no of record of table

Explanation:

SQL COUNT returns the no of record of table.

10. In SQL SELECT COUNT, one needs to specify the –

A. Column Name
B. Row Name
C. Table Name
D. None of the above

Answer: A) Column Name


Explanation:

In SQL SELECT COUNT, one needs to specify the Column Name.

11. The SELECT TOP statement shows the limited number of:

A. Rows
B. Columns
C. Tables
D. None of the above

Answer: A) Rows

Explanation:

The SELECT TOP statement shows the limited number of records or rows.

12. Select the correct syntax of SELECT TOP clause?

A. SELECT TOP name


B. SELECT TOP column
C. SELECT TOP FROM
D. SELECT TOP Number

Answer: D) SELECT TOP Number

Explanation:

The correct syntax of SELECT TOP clause is SELECT TOP Number.

13. Using the SQL first() function, one can return the ____ value of the selected column.

A. First
B. Second
C. Third
D. Last

Answer: A) First

Explanation:

Using the SQL first() function, one can return the first value of the selected column.

14. Using the SQL last() function, one can return the ______ value of the selected column.

A. First
B. Second
C. Third
D. Last

Answer: D) Last

Explanation:

Using the SQL last() function, one can return the last value of the selected column.

15. Using SQL SELECT RANDOM() function, one can return the random –

A. Table
B. Database
C. Row
D. Column

Answer: C) Row

Explanation:

Using SQL SELECT RANDOM() function, one can return the random row.

16. In order to assign a random name to a column or table, which SQL SELECT Clause is used?

A. FROM
B. WHERE
C. HAVING
D. AS

Answer: D) AS

Explanation:

In order to assign a random name to a column or table, SQL SELECT AS Clause is used.

17. Which function combines the two different columns?

A. ADD
B. MERGE
C. CONCAT
D. None of the above

Answer: C) CONCAT

Explanation:

CONCAT() function, combines the two different columns.


18. What is the difference between HAVING and WHERE clause?

A. HAVING clause is used in column operation whereas WHERE clause is used in row
operation.
B. HAVING clause is post-filter whereas WHERE clause is pre-filter.
C. HAVING clause filters the groups whereas WHERE clauses filter the single record of
the table.
D. All of the above

Answer: D) All of the above

Explanation:

The differences between HAVING and WHERE clauses are:

a. HAVING clause is used in column operation whereas WHERE clause is used in row
operation.
b. HAVING clause is post-filter whereas WHERE clause is pre-filter.
c. HAVING clause filters the groups whereas WHERE clauses filter the single record of
the table.

19. What is the difference between MIN and MAX function?

A. MIN function is used to show the minimum data and MAX function is used to show
the maximum data.
B. MIN function is used to show the maximum data and MAX function is used to show
the minimum data.
C. Both of the above
D. None of the above

Answer: A) MIN function is used to show the minimum data and MAX function is used to
show the maximum data

Explanation:

MIN function is used to show the minimum data and MAX function is used to show the
maximum data.

20. In order to sort the records according to the columns, which clause is used?

A. HAVING
B. GROUP BY
C. ORDER BY
D. None of the above

Answer: C) ORDER BY

Explanation:
ORDER BY clause is used to sort the records according to the columns

21. By default, sorting by ORDER BY clause is done in which order?

A. Ascending
B. Descending

Answer: A) Ascending

Explanation:

By default, sorting by ORDER BY clause is done in ascending order.

22. What is the keyword of the Ascending and Descending?

A. ASCE, DESC
B. ASC, DES
C. ASCE, DES
D. ASC, DESC

Answer: D) ASC, DESC

Explanation:

ASC, DESC are the keywords of the ascending and descending.

23. SQL INSERT is used to insert a –

A. Single or Multiple record


B. Single or Multiple database
C. Single or Multiple table
D. None of the above

Answer: A) Single or Multiple record

Explanation:

SQL INSERT is used to insert a single or multiple records in the table.

24. In order to insert a row directly in the table, which command is used?

A. INSERT IN
B. INSERT INSIDE
C. INSERT UNDER
D. INSERT INTO

Answer: D) INSERT INTO


Explanation:

INSERT INTO command is used to insert a row directly in the table.

25. In order to update one table using another table and join condition, which statement is
used.

A. SQL UPDATE INTO


B. SQL UPDATE JOIN
C. SQL JOIN
D. SQL JOIN UPDATE

Answer: B) SQL UPDATE JOIN

Explanation:

SQL UPDATE JOIN is used to update one table using another table and join condition.

26. SQL DELETE can be used to delete,

A. Rows
B. Database
C. View
D. All of the above

Answer: D) All of the above

Explanation:

SQL DELETE can be used to delete Rows, Database and View using specific SQL clauses.

27. What is the clause to delete all rows from the table?

A. SQL DELETE ALL ROWS Table_Name;


B. SQL DELETE ROWS Table_Name;
C. DELETE FROM ALL ROWS Table_Name;
D. DELETE FROM Table_Name;

Answer: D) DELETE FROM Table_Name;

Explanation:

DELETE FROM Table_Name is used to delete all rows from the table.

28. In order to delete duplicate rows from the table, which keyword is used?
A. DELETE
B. DISTINCT
C. FROM
D. WHERE

Answer: B) DISTINCT

Explanation:

DISTINCT keyword is used to delete duplicate rows from the table.

29. In order to delete the database, which keyword is used?

A. DROP
B. DELETE
C. ALTER
D. None of the above

Answer: A) DROP

Explanation:

DROP keyword is used to delete the database.

30. Which of the following keyword is used to delete the Join?

A. DELETE
B. ON
C. WHERE
D. All of the above

Answer: D) All of the above

Explanation:

DELETE, ON, WHERE and few other keywords are used to delete the Join.

MCQ | SQL – Keys

1. A Key which uniquely identifies each row in the table is known as?

A. Primary Key
B. Unique Key
C. Composite Key
D. Foreign Key

Answer: A) Primary Key


Explanation:

A Key which uniquely identifies each row in the table is known as Primary Key.

2. A Primary Key is basically a –

A. Row
B. Column
C. Table
D. Database

Answer: B) Column

Explanation:

A Primary Key is basically a Column or Columns.

3. If multiple columns are used as Primary Key, it is known as –

A. Unique
B. Composite
C. Foreign
D. None of the above

Answer: B) Composite

Explanation:

If multiple columns are used as Primary Key, it is known as Composite Key.

4. Which of the following statement is TRUE about Primary Key?

A. Table integrity is not enforced by the primary key.


B. The data in a primary key is always multiple.
C. 900 bytes is the maximum length of a primary key.
D. Null values are allowed in primary keys.

Answer: C) 900 bytes is the maximum length of a primary key

Explanation:

we can have up to 16 columns as primary key column and the total size of the key columns
should be less than or equal to 900 bytes.

5. Primary keys can be contained in a table only ____?


A. Once
B. Twice
C. Thrice
D. None of the above

Answer: A) Once

Explanation:

Primary keys can be contained in a table only once.

6. To add a Primary Key constraint after table is created, which clause is used?

A. UPDATE
B. ADD
C. ALTER
D. JOIN

Answer: C) ALTER

Explanation:

To add a Primary key constraint after table is created, ALTER clause is used.

7. In order to remove a primary key constraint, which clause is used?

A. DELETE
B. DROP
C. ALTER
D. REMOVE

Answer: B) DROP

Explanation:

In order to remove a primary key constraint, DROP clause is used.

8. In order to build a link between two tables, which key is used?

A. Primary
B. Foreign
C. Composite
D. Unique

Answer: B) Foreign

Explanation:
In order to build a link between two tables, foreign key is used.

9. Which of the following statement is FALSE?

A. A Primary Key cannot be NULL


B. A Foreign Key cannot be NULL
C. A Primary Key cannot be Duplicate
D. A Foreign Key can be Duplicate

Answer: B) A Foreign Key cannot be NULL

Explanation:

The option (B) is false, because a foreign key can be NULL or duplicate.

10. Foreign key is a field in a table that is _______ key in another table?

A. Primary
B. Unique
C. Composite
D. None of the above

Answer: A) Primary

Explanation:

Foreign key is a field in a table that is Primary Key in another table.

11. When two or more columns are combined to be used to uniquely identify each row in the
table, it is known as -

A. Primary Key
B. Unique Key
C. Composite Key
D. Foreign Key

Answer: C) Composite Key

Explanation:

When two or more columns are combined to be used to uniquely identify each row in the
table, it is known as Composite Key.

12. For one table, there can be ____unique key constraint(s).

A. 1
B. NULL
C. Many
D. None of the above

Answer: C) Many

Explanation:

For one table, there can be many unique key constraints.

13. All other columns other than the column which is termed as Primary Key, are known as –

A. Unique Keys
B. Alternate Keys
C. Composite Keys
D. None of the above

Answer: B) Alternate Keys

Explanation:

All other columns other than the column which is termed as Primary Key, are known as
Alternate Keys.

MCQ | SQL – Comments, Group By, Cast Function

1. GROUP BY clause is placed before which clause in SQL?

A. HAVING
B. WHERE
C. ORDER BY
D. FROM

Answer: C) ORDER BY

Explanation:

GROUP BY clause is placed before ORDER BY clause in SQL.

2. Which one if these is used to put the same value in all the rows?

A. Group by unique column


B. Group by single column
C. Group by one column
D. Group by same value

Answer: B) Group by single column

Explanation:
Group by single column is used to put the same value in all the rows.

3. In order to convert the expression from one to another data type, which SQL Function is
used?

A. CONVERT
B. CHANGE
C. CAST
D. TRANSIT

Answer: C) CAST

Explanation:

In order to convert the expression from one to another data type, SQL CAST Function is used.

4. What is the syntax of SQL CAST Function?

A. CAST (expression AS [data type])


B. CAST (expression IN [data type])
C. CAST (expression TO [data type])
D. CAST (expression FOR [data type])

Answer: A) CAST (expression AS [data type])

Explanation:

CAST (expression AS [data type]) is the syntax of the SQL CAST function.

5. What is the default length of any data type in the CAST function?

A. 10
B. 20
C. 30
D. 40

Answer: C) 30

Explanation:

30 is the default length of any data type in the CAST function.

6. Select the correct type(s) of SQL Comments.

A. Inline Comments
B. Single Line Comments
C. Multi-line Comments
D. All of the above
Answer: D) All of the above

Explanation:

Type of SQL Comments are Inline Comments, Single Line Comments and Multi-line
Comments.

7. Select the syntax of Single Line Comment.

A. .
B. !
C. --
D. #

Answer: C) --

Explanation:

"--" is the syntax of the Single Line Comment.

8. Comments whose starting and ending lines are different are known as –

A. Inline Comments
B. Multi-line Comments
C. Single Line Comments
D. Varied line Comments

Answer: B) Multi-line Comments

Explanation:

Comments whose starting and ending lines are different are known as Multi-line Comments.

9. Select the correct syntax for Multi-line Comments.

A. //*Line1
B. Line2*//
C.
D. /*Line1
E. Line2/*
F.
G. */Line1
H. Line2*/
I.
J. /*Line1
K. Line2*/
L.

Answer: D)

/*Line1
Line2*/

Explanation:

The multi-line comment starts with /* and ends with */

10. What will be the output of the below SQL statement?

SELECT CAST(25.65 AS int);

A. 25
B. 26

Answer: A) 25

Explanation:

This statement converts the value to an int datatype.

11. What will be the output of the below SQL statement?

SELECT CAST(25.65 AS varchar);

A. 25
B. 26
C. 25.65
D. 25.00

Answer: C) 25.65

Explanation:

This statement converts the value to a varchar datatype.

12. What will be the output of the below SQL statement?

SELECT CAST('2021-10-06' AS datetime);

A. 2021-10-06 00:00:00.000
B. 2021-10-06
C. 2021 OCT 06
D. 06-10-2021

Answer: A) 2021-10-06 00:00:00.000

Explanation:

This statement converts the value to a datetime datatype.

MCQ | SQL – Functions

1. In how many parts are the SQL functions are divided into?

A. 1
B. 2
C. 3
D. 4

Answer: B) 2

Explanation:

SQL functions are divided into 2 parts, Aggregate, and Scalar Functions.

2. ____ value is returned by the SQL Aggregate functions?

A. Single
B. Twice
C. NULL
D. Infinite

Answer: A) Single

Explanation:

Single value is returned by the SQL Aggregate functions.

3. Select the Aggregate function(s) among the following.

A. AVG()
B. FIRST()
C. LAST()
D. All of the above

Answer: D) All of the above

Explanation:
AVG(), FIRST() and LAST() are all the aggregate functions.

4. What does AVG() function returns?

A. First value of the column


B. Last value of the column
C. Sum of rows of the table
D. Average value of the column

Answer: D) Average value of the column

Explanation:

AVG() function returns the Average value of the column.

5. Which function returns the largest value of the column?

A. MIN()
B. MAX()
C. LARGE()
D. AVG()

Answer: B) MAX()

Explanation:

MAX() function returns the largest value of the column.

6. What does COUNT() function returns?

A. Average value
B. Largest value
C. Smallest value
D. Number of rows

Answer: D) Number of rows

Explanation:

COUNT() function returns the number of rows in the table.

7. Select the function which is not the Scalar Function(s)?

A. UCASE()
B. LEN()
C. SUM()
D. NOW()
Answer: C) SUM()

Explanation:

SUM() is aggregate function and not the Scalar function.

8. What does UCASE() function do?

A. Converts database field to uppercase


B. Converts database field to lowercase
C. Returns the length of the text field
D. Returns the current date and time

Answer: A) Converts database field to uppercase

Explanation:

UCASE() function converts database field to uppercase.

9. ____ function extract characters from the text field.

A. LEN()
B. NOW()
C. MID()
D. FORMAT()

Answer: C) MID()

Explanation:

MID() function extract characters from the text field.

10. Which function returns the correct date and time?

A. DATE()
B. NOW()
C. TIME()
D. DATETIME()

Answer: B) NOW()

Explanation:

NOW() function returns the correct date and time.

11. In order to merge two or more strings, which string function is used?
A. CHAR
B. ALTER
C. CONCAT
D. MERGE

Answer: C) CONCAT

Explanation:

In order to merge two or more strings, CONCAT string function is used.

12. We can use literal in the CONCAT function. What does literal refer to?

A. Number
B. Character
C. Date
D. All of the above

Answer: D) All of the above

Explanation:

Literals are the numbers, characters and the data in the CONCAT function.

13. What is the symbol of Concatenation Operator?

A. |
B. ||
C. //
D. \\

Answer: B) ||

Explanation:

"||" is the symbol of Concatenation Operator.

14. What is the full form of CTE in SQL?

A. Character Table Expressions


B. Character Table Evaluator
C. Common Table Evaluator
D. Common Table Expressions

Answer: D) Common Table Expressions

Explanation:
Common Table Expressions is the full form of CTE in SQL.

15. Which clause is needed in CTE SQL syntax?

A. FOR
B. AS
C. WITH
D. TO

Answer: C) WITH

Explanation:

WITH clause is needed in CTE SQL syntax.

16. In case of ____ data, recursive CTE is used?

A. Round
B. Hierarchal
C. Linear
D. None of the above

Answer: B) Hierarchal

Explanation:

In case of Hierarchal data, recursive CTE is used.

17. In case the CTE is wrong, it goes into –

A. Infinite Loop
B. Null State
C. False State
D. True State

Answer: A) Infinite Loop

Explanation:

In case the CTE is wrong, it goes into Infinite Loop.

18. In case to prevent the endless loop in CTE, ____ is added.

A. MAXLINEAR
B. MAXROUND
C. MAXRECURSION
D. None of the above
Answer: C) MAXRECURSION

Explanation:

In case to prevent the endless loop in CTE, MAXRECURSION is added.

19. From the set of results, in order to remove the duplicate columns, ____ Clause is used.

A. DUPLICATE
B. DISTINCT
C. REMOVE
D. DROP

Answer: B) DISTINCT

Explanation:

From the set of results, in order to remove the duplicate columns, DISTINCT Clause is used. It
is used in conjunction with SELECT keyword.

20. Which of the following statement is TRUE about DISTINCT Clause?

A. Returns only Distinct values.


B. Only on the single column, it operates.
C. It can be used with the aggregates such as COUNT, AVG, etc.
D. All of the above

Answer: D) All of the above

Explanation:

i. DISTINCT can return only distinct values.


ii. DISTINCT operates only on the single column
iii. DISTINCT can be used with the aggregates such as COUNT, AVG, etc.

21. ____ are the columns for the retrieval purpose.

A. Tables
B. WHERE Conditions
C. Expressions
D. None of the above

Answer: C) Expressions

Explanation:

Expressions are the columns for the retrieval purpose.


22. Which of the following statement is TRUE about DISTINCT Clause?

A. It cannot ignore the NULL values


B. It can ignore the NULL values
C. Its query can return multiple values
D. None of the above

Answer: A) It cannot ignore the NULL values

Explanation:

DISTINCT Clause cannot ignore the NULL values.

23. In order to join N tables, minimum number of join statements required is –

A. N
B. N-1
C. N-2
D. N+1

Answer: B) N-1

Explanation:

In order to join N tables, minimum number of join statements required is N-1.

24. ____ Clause is used in Parent-child relationship in order to join two or more tables.

A. FROM
B. TO
C. WHERE
D. IN

Answer: C) WHERE

Explanation:

WHERE Clause is used in Parent-child relationship in order to join two or more tables.

25. The Web SQL API is supported by –

A. Opera
B. Google Chrome
C. Android Browsers
D. All of the above
Answer: D) All of the above

Explanation:

The WEB SQL API is supported by Opera, Google Chrome and Android Browsers.

26. In order to manage or store the data in the database, WEB SQL Database is used which is
a–

A. Web site
B. Web page
C. Web browser
D. None of the above

Answer: B) Web page

Explanation:

In order to manage or store the data in the database, WEB SQL Database is used which is a
Webpage.

27. Which of the following statement is TRUE?

A. Web API is the part of HTML5


B. Web API is not the part of HTML5
C. Web API is the part of HTML
D. Web API is the part of XHTML

Answer: B) Web API is not the part of HTML5

Explanation:

Web API a separate specification and not the part of HTML5.

28. Select the correct method of Web SQL?

A. Execute SQL
B. Transaction
C. Open Database
D. All of the above

Answer: D) All of the above

Explanation:

Execute SQL, Transaction and Open Database are all the methods of Web SQL.

29. In order to execute a query in Web SQL, which function is used?


A. open()
B. translate()
C. transaction()
D. execute()

Answer: C) transaction()

Explanation:

In order to execute a query in Web SQL, db.transaction() is used.

30. Transaction is able to control the following –

A. Transaction
B. Commit
C. Rollback
D. All of the above

Answer: D) All of the above

Explanation:

Transaction is able to control transaction and rollback or commit.

MCQ | SQL – Index

1. SQL Indexes slows the execution time of which statement(s)?

A. UPDATE
B. INSERT
C. SELECT
D. Both A and B

Answer: D) Both A and B

Explanation:

SQL Indexes slows the execution time of UPDATE and INSERT statements.

2. SQL indexes speed up the execution time of which statement(s)?

A. SELECT
B. WHERE
C. Both A and B
D. None of the above

Answer: C) Both A and B


Explanation:

SQL Indexes speed up the execution time of SELECT and WHERE statements.

3. Why index is important in SQL?

A. The large database can be searched quickly with SQL Indexes.


B. The concept below is a quick way to include different values in those columns.
C. A smaller table may not recognize the performance of an index when used with an
index.
D. All of the above

Answer: D) All of the above

Explanation:

The index is important in SQL because –

i. The large database can be searched quickly with SQL Indexes.


ii. The concept below is a quick way to include different values in those columns.
iii. A smaller table may not recognize the performance of an index when used with an
index.
iv. Columns (fields) in this data structure are sorted either ascendingly or descendingly
according to their data values. For each value, an entry is assigned.
v. There are only two columns in each index table. Row_id is the first column, and
indexed-column is the second.

4. In order to create the Index, we need to use which command?

A. ALTER
B. UPDATE
C. CREATE
D. ADD

Answer: C) CREATE

Explanation:

In order to create the Index, we need to use the CREATE command.

5. Unique Index is similar to –

A. Primary Key
B. Foreign Key
C. Composite Key
D. Alternate Key

Answer: A) Primary Key


Explanation:

Unique Index is similar to Primary Key in SQL.

6. To rename the Index, we need to use which command?

A. RENAME
B. ALTER
C. UPDATE
D. ADD

Answer: B) ALTER

Explanation:

To rename the Index, we need to use ALTER command.

7. In order to remove an index, we need to use which command?

A. REMOVE
B. DELETE
C. DROP
D. DEL

Answer: C) DROP

Explanation:

In order to remove an index, we need to use DROP command.

8. Which statement is correct to remove an Index from MySQL Database?

A. DROP INDEX Index_Name;


B. ALTER TABLE Table_Name DROP INDEX Index_Name;
C. DROP INDEX Index_Name ON Table_Name;
D. DROP INDEX Table_Name.Index_Name;

Answer: B) ALTER TABLE Table_Name DROP INDEX Index_Name;

Explanation:

Correct statement to remove an Index from MySQL Database is - ALTER TABLE Table_Name
DROP INDEX Index_Name;

9. In the relational database, in order to modify index, we need to use which command?
A. ALTER
B. MODIFY
C. UPDATE
D. ADD

Answer: A) ALTER

Explanation:

In the relational database, in order to modify index, we need to use ALTER command.

10. Which of the following states the correct situation in which Indexes should not be used in
SQL?

A. When the table is small, it is possible to avoid using SQL indexes.


B. Updates need to be made frequently to the table.
C. When there are a lot of NULL values in a column, indexed should not be used.
D. All of the above

Answer: D) All of the above

Explanation:

In the case of following situation, Indexes should not be used in SQL –

i. When the table is small, it is possible to avoid using SQL indexes.


ii. Updates need to be made frequently to the table.
iii. When there are a lot of NULL values in a column, indexed should not be used.

MCQ | SQL – Constraints Clause

1. By constraining a SQL statement, we limit the ____________ according to certain


conditions or restrictions.

A. Row
B. Column
C. Table
D. Database

Answer: D) Database

Explanation:

By constraining a SQL statement we limit the database according to certain conditions or


restrictions.

2. Which of the following is/are type of SQL Constraint?


A. Column Level
B. Table Level
C. Both A and B
D. None of the above

Answer: C) Both A and B

Explanation:

SQL Constraints can be categorized in two types:

i. Column Level Constraint


ii. Table Level Constraint

3. What is the difference between Column Level and Table Level Constraints?

A. Constraints are applied to a single row using Column Level Constraints whereas
Multiple rows can be constrained using a Table Level Constraint.
B. Constraints are applied to multiple rows using Column Level Constraints whereas a
single row can be constrained using a Table Level Constraint.
C. Constraints are applied to a single column using Column Level Constraints whereas
Multiple columns can be constrained using a Table Level Constraint.
D. Constraints are applied to multiple columns using Column Level Constraints whereas
only a single column can be constrained using a Table Level Constraint.

Answer: C) Constraints are applied to a single column using Column Level Constraints
whereas Multiple columns can be constrained using a Table Level Constraint

Explanation:

Constraints are applied to a single column using Column Level Constraints whereas Multiple
columns can be constrained using a Table Level Constraint.

4. Which of the following constraints are TRUE to be put in Password system?

A. One uppercase character must be included in the password.


B. An eight-character minimum password is required.
C. At least one symbol must appear in the password.
D. All of the above

Answer: D) All of the above

Explanation:

The constraints that are needed to be put in the Password system are:

i. One uppercase character must be included in the password.


ii. An eight-character minimum password is required.
iii. At least one symbol must appear in the password.

5. Select the correct constraint in SQL?

A. NOT NULL
B. CHECK
C. DEFAULT
D. All of the above

Answer: D) All of the above

Explanation:

The constraints available in SQL are:

i. CHECK
ii. CREATE INDEX
iii. DEFAULT
iv. FOREIGN KEY
v. NOT NULL
vi. PRIMARY KEY
vii. UNIQUE

6. What is TRUE about NOT NULL Constraint?

A. In columns that are subject to the NOT NULL constraint, duplicate values are not
allowed.
B. When a table's column is declared as NOT NULL, no record in the table can have an
empty value for that column.
C. By applying the NOT NULL constraint, we will always ensure that the column contains
a unique value and won't allow nulls.
D. The value will first be checked for certain conditions before inserting it into the
column when a NOT NULL constraint applies to a column in the table.

Answer: B) When a table's column is declared as NOT NULL, no record in the table can have
an empty value for that column

Explanation:

When a table's column is declared as NOT NULL, no record in the table can have an empty
value for that column.

7. NULL means –

A. ZERO
B. -1
C. 1
D. Empty
Answer: D) Empty

Explanation:

NULL means empty, not even zero.

8. Which of the following is TRUE about UNIQUE constraint?

A. In columns that are subject to the UNIQUE constraint, duplicate values are not
allowed.
B. Unique values will always be present in the column containing the unique constraint.
C. A single table can have more than one unique constraint, since it can be applied to
more than one column.
D. All of the above

Answer: D) All of the above

Explanation:

In case of UNIQUE constraint:

i. In columns that are subject to the UNIQUE constraint, duplicate values are not
allowed.
ii. Unique values will always be present in the column containing the unique constraint.
iii. A single table can have more than one unique constraint, since it can be applied to
more than one column.

9. You can also _______ the existing tables by using the UNIQUE constraint.

A. Change
B. Delete
C. Modify
D. Drop

Answer: C) Modify

Explanation:

You can also modify the existing tables by using the UNIQUE constraint.

10. ___________ and __________constraints form the core of the PRIMARY KEY constraint.

A. NOT NULL , CHECK


B. NOT NULL , DEFAULT
C. NOT NULL , FOREIGN KEY
D. NOT NULL , UNIQUE

Answer: D) NOT NULL , UNIQUE


Explanation:

NOT NULL and UNIQUE constraints form the core of the PRIMARY KEY constraint.

11. ___________ integrity is achieved by using a foreign key.

A. Referential Integrity
B. Domain Integrity
C. User-defined Integrity
D. Entity Integrity

Answer: A) Referential Integrity

Explanation:

Referential integrity is achieved by using a foreign key.

12. What is TRUE about DEFAULT constraint?

A. The value will first be checked for certain conditions before inserting it into the
column when a DEFAULT constraint applies to a column in the table.
B. In the event of a DEFAULT constraint being applied to a table's column without a user
specifying the value to be inserted when that constraint was applied, the default
value that was specified when the constraint was applied will be put into that column.
C. An index can be created on the table using the DEFAULT constraint.
D. None of the above

Answer: B) In the event of a DEFAULT constraint being applied to a table's column without a
user specifying the value to be inserted when that constraint was applied, the default value
that was specified when the constraint was applied will be put into that column

Explanation:

In the event of a default constraint is applied to a table's column without a user specifying
the value to be inserted when that constraint was applied, the default value that was
specified when the constraint was applied will be put into that column.

MCQ | SQL – Sub Queries, Views Clause

1. A Sub query is an SQL expression that is placed ________ another SQL statement.

A. Before
B. After
C. Inside
D. Outside

Answer: C) Inside
Explanation:

A Sub query is an SQL expression that is placed inside another SQL statement.

2. With which of the following statement(s) can the SQL sub queries be used?

A. SELECT
B. UPDATE
C. INSERT
D. All of the above

Answer: D) All of the above

Explanation:

SQL sub queries can be used with SELECT, UPDATE, INSERT and DELETE statements.

3. Whenever a sub query appears in SQL, it is enclosed within ___________ and placed to
the _____ of the SQL operators.

A. Brackets, Left
B. Brackets, Right
C. Parenthesis, Left
D. Parenthesis, Right

Answer: D) Parenthesis, Right

Explanation:

Whenever a sub query appears in SQL, it is enclosed within parenthesis and placed to the
right of the SQL operators.

4. Which of the following clause cannot be used in SQL sub queries?

A. GROUP BY
B. ORDER BY
C. DELETE
D. FROM

Answer: B) ORDER BY

Explanation:

ORDER BY clause cannot be used in SQL sub queries.

5. In order to prevent multiple records from being returned by the sub query, _______ must
be used before the sub query.
A. Many Value Operators
B. Multiple Value Operators
C. Single Value Operator
D. Unique Value Operator

Answer: B) Multiple Value Operators

Explanation:

In order to prevent multiple records from being returned by the sub query, multiple value
operators must be used before the sub query.

6. The _________ operator cannot be used with the sub query, but within it.

A. IN
B. INTO
C. BETWEEN
D. JOIN

Answer: C) BETWEEN

Explanation:

The BETWEEN operator cannot be used with the sub query, but within it.

7. An SQL ____ is a virtual table, whose contents are based on the SQL statement's results.

A. Concatenate
B. Virtual
C. View
D. None of the above

Answer: C) View

Explanation:

An SQL View is a virtual table, whose contents are based on the SQL statement's results.

8. We can create View in SQL using –

A. CREATE statement
B. CREATE VIEW statement
C. VIEW CREATE statement
D. SQL VIEW statement

Answer: B) CREATE VIEW statement

Explanation:
We can create View in SQL using CREATE VIEW statement.

9. What is TRUE about UPDATE in SQL VIEW?

A. Views that depend on a single table can be updated.


B. An update of a view created from more than one table will not be allowed by SQL.
C. There should be no NULL values in the fields of view.
D. All of the above

Answer: D) All of the above

Explanation:

UPDATE in SQL VIEW states that-

i. Views that depend on a single table can be updated.


ii. An update of a view created from more than one table will not be allowed by SQL.
iii. There should be no NULL values in the fields of view.

10. When SELECT statements used to create Views contain ______________ clauses, the
views cannot be updated.

A. JOIN
B. HAVING
C. GROUP BY
D. All of the above

Answer: D) All of the above

Explanation:

When SELECT statements used to create Views contain JOIN, HAVING, or GROUP BY clauses,
the views cannot be updated.

MCQ | SQL – BETWEEN, CRUD Operations

1. SQL BETWEEN is a ________operator.

A. Relational
B. Logical
C. Arithmetic
D. Assignment

Answer: B) Logical

Explanation:
SQL BETWEEN is a logical operator and within the range specified in the query, it retrieves
the records from the table.

2. SQL BETWEEN operators can be used to select the –

A. Dates
B. Texts
C. Numbers
D. All of the above

Answer: D) All of the above

Explanation:

SQL BETWEEN operators can be used to select the dates, texts or numbers.

3. SQL BETWEEN operators include –

A. Starting Value
B. In Between Value
C. Ending Value
D. All of the above

Answer: D) All of the above

Explanation:

SQL BETWEEN operators include the starting value, in between value and the ending value.

4. In which clause does the BETWEEN operator is used?

A. IF
B. AS
C. WHERE
D. EXCEPT

Answer: C) WHERE

Explanation:

In WHERE clause, BETWEEN operator is used.

5. BETWEEN operator is used with which SQL Statements –

A. SELECT
B. DELETE
C. INSERT
D. All of the above
Answer: D) All of the above

Explanation:

BETWEEN operators is used with SELECT, DELETE and INSERT SQL Statements.

6. BETWEEN Operator returns the TRUE value if the column value is –

A. <=Value1 & >=Value2


B. <=Value1 & <=Value2
C. >=Value1 & >=Value2
D. >=Value1 & <=Value2

Answer: D) >=Value1 & <=Value2

Explanation:

BETWEEN Operator returns the TRUE value if the column value is >=Value1 & <=Value2.

7. In CRUD Operator, U is an acronym of –

A. Upper
B. Unique
C. Update
D. Uppercase

Answer: C) Update

Explanation:

U in CRUD Operator refers to Update.

8. C in CRUD Operator means –

A. To add or insert data


B. To retrieve or fetch data
C. To update the data
D. To delete the data

Answer: A) To add or insert data

Explanation:

C in CRUD Operator is an acronym of Create which means to add or insert data in the table.

9. Read in CRUD Operator means –


A. To retrieve data
B. To fetch data
C. Both A. and B.
D. None of the above

Answer: C) Both A. and B.

Explanation:

Read in CRUD Operator means to retrieve and fetch the data from the table.

10. Using the DELETE Query from the CRUD Operator, we can delete –

A. Only one row


B. All the rows
C. Only two rows
D. None of the above

Answer: B) All the rows

Explanation:

Using the DELETE Query from the CRUD Operator, we can delete all the rows from the table.

MCQ | SQL – Concatenate, Savepoint, TIME

1. To connect strings, which function is used –

A. CONNECT
B. ADD
C. COMBINE
D. CONCAT

Answer: D) CONCAT

Explanation:

To connect strings, CONCAT function is used.

2. Which of the following is TRUE about SQL Concatenate?

A. It is also possible to combine more than two strings into one string.
B. Two columns of the table may be used to store the strings that are to be combined,
or they may just be stored individually without being stored into the table.
C. When the concatenated strings are stored in separate columns of a table, they are
stored in the column in which they were initially stored.
D. All of the above
Answer: D) All of the above

Explanation:

In case of SQL Concatenate:

1. It is also possible to combine more than two strings into one string.
2. Two columns of the table may be used to store the strings that are to be combined,
or they may just be stored individually without being stored into the table.
3. When the concatenated strings are stored in separate columns of a table, they are
stored in the column in which they were initially stored.

3. Which function is used to obtain the month from the entire data stored in a table's
column?

A. DATE
B. TIME
C. MONTH
D. DATE & TIME

Answer: C) MONTH

Explanation:

MONTH function is used to obtain the month from the entire data stored in a table's column.

4. In more readable form, you can retrieve the date values, using ______ function?

A. DATE
B. DATE_FORM
C. DATE_FORMAT
D. DATE_VALUE

Answer: C) DATE_FORMAT

Explanation:

In more readable form, you can retrieve the date values, using DATE_FORMAT function.

5. Savepoint command is used with _____ command.

A. Commit
B. Transaction
C. Rollback
D. None of the above

Answer: C) Rollback
Explanation:

Savepoint command is used with Rollback command.

6. Which of the following is TRUE about Savepoint command?

A. A transaction is marked in a table by this TCL command.


B. Imagine that you are making a long table, and you want to roll back only to a specific
point in the table. You can do this with the savepoint.
C. In order to rollback part of a table rather than the entire table, a savepoint is useful.
D. All of the above

Answer: D) All of the above

Explanation:

Some of the points about Savepoint command are:

1. A transaction is marked in a table by this TCL command.


2. Imagine that you are making a long table, and you want to roll back only to a specific
point in the table. You can do this with the savepoint.
3. In order to rollback part of a table rather than the entire table, a savepoint is useful.

7. Select the correct syntax for Savepoint.

A. Mysql > Transaction ini;


B. Mysql > &Savepoint;
C. Mysql > START Transaction;
D. Mysql > Savepoint ini;

Answer: D) Mysql > Savepoint ini;

Explanation:

Mysql > Savepoint ini; is the correct syntax for Savepoint.

8. By default, TIME data type stores time in which format?

A. MM:HH:SS;
B. SS:HH:MM;
C. HH:SS:MM;
D. HH:MM:SS;

Answer: D) HH:MM:SS;

Explanation:

By default, TIME data type stores time in HH:MM:SS format


9. It is possible to retrieve time in a more readable format, using which function?

A. TIME
B. TIME_FORM
C. TIME_FORMAT
D. TIME & DATE

Answer: C) TIME_FORMAT

Explanation:

It is possible to retrieve time in a more readable format, using TIME_FORMAT() function.

10. Using TIME_FORMAT() function, time can be retrieved in –

A. 12-hour format
B. 24-hour format
C. Both A. and B.
D. None of the above

Answer: C) Both A. and B.

Explanation:

Using TIME_FORMAT() function, time can be retrieved in 12-hour and 24-hour formats.

********************HAPPY LEARNING*******************

You might also like