SQL MCQ (Multiple Choice Questions)

Here are 1000 MCQs on SQL (Chapterwise).

1. What does SQL stand for?
a) Structured Query Language
b) Standard Query Language
c) Simple Query Language
d) Sequential Query Language
View Answer

Answer: a
Explanation: SQL stands for Structured Query Language. It is a domain-specific language used to manage and manipulate relational databases. SQL provides a standardized way to interact with databases, enabling users to perform tasks such as querying, updating, and managing the structure of databases.

2. Which of the following is NOT a valid keyword in SQL?
a) SELECT
b) DELETE
c) WHERE
d) INCLUDE
View Answer

Answer: d
Explanation: In SQL, “INCLUDE” is not a valid keyword. The correct keywords are:

  • SELECT: Used to retrieve data from one or more tables.
  • DELETE: Used to delete records from a table.
  • WHERE: Used to filter the results based on a specified condition.

“INCLUDE” is not a standard SQL keyword. SQL keywords are reserved words that have specific meanings in the language, and “INCLUDE” is not recognized as one of them in standard SQL syntax.

advertisement
advertisement

3. Which of the following operators is used to compare two values in SQL?
a) +
b) =
c) <>
d) &
View Answer

Answer: c
Explanation: The <> operator in SQL is used to compare two values for inequality. It checks if the values on both sides are different.

4. What is the purpose of the SQL keyword “DISTINCT” in a SELECT statement?
a) To retrieve unique values from a column
b) To filter NULL values
c) To delete duplicate records
d) To sort the result set
View Answer

Answer: a
Explanation: The DISTINCT keyword is used to retrieve unique values from a specified column in a SELECT query.

5. Which of the following tasks CANNOT be accomplished using SQL?
a) Creating and modifying database structures
b) Writing complex algorithms for data analysis
c) Retrieving specific data from a database
d) Adding new data to a database
View Answer

Answer: b
Explanation: SQL is not primarily designed for writing complex algorithms for data analysis. Other languages like Python or R are more suitable for this task.

6. Which of the following is basis for SQL?
a) SQL Server
b) DBMS
c) RDBMS
d) Oracle
View Answer

Answer: c
Explanation: RDBMS is the basis for SQL, and for all modern database systems such as MS SQL Server, IBM DB2, Oracle, MySQL and Microsoft Access.
advertisement

7. Which character is used to separate SQL statements in database systems?
a) :
b) %
c) _
d) ;
View Answer

Answer: d
Explanation: A SQL statement begins with a SQL keyword and ends with a semicolon. Using semicolon is the standard way to separate each SQL statement in database systems.

8. Which statement(s) are mandatory in a simple SQL SELECT statement?
a) Select, From
b) Select, OrderBy
c) Select, Where
d) Select, GroupBy
View Answer

Answer: a
Explanation: From statement contains the table name from which the required columns are to be retrieved. So it is necessary along with Select statement, whereas others are optional.
advertisement

9. Which of the following is a default join type?
a) Right join
b) Left join
c) Inner join
d) Outer join
View Answer

Answer: c
Explanation: Inner join Selects records that have matching values in both the tables. It’s the default join type, so if we just type JOIN without specifying any other conditions, an INNER JOIN will be used.

10. Which of the following command is used to create a database in SQL?
a) MAKE
b) CREATE
c) INSERT
d) DEVELOP
View Answer

Answer: b
Explanation: The CREATE command is used to create a database in SQL. The same command can be used to create a table within the database. The INSERT command is used to insert data inside the tables.

11. Which of the following statement is true about views in SQL?
a) We can delete but not insert rows in a view
b) We cannot insert and delete rows in a view
c) We can insert but not delete rows in a view
d) We can insert and delete rows in a view
View Answer

Answer: d
Explanation: In SQL, we can insert and delete rows in a view. We can perform insert and update in an updatable view only. Read-only views are not updatable.

12. What is the full form of PL in PL/SQL?
a) Programming Language
b) Programming Logic
c) Procedural Language
d) Procedural Logic
View Answer

Answer: c
Explanation: PL in PL/SQL stands for Procedural Language. It is a block structured language that enables developers to combine the power of SQL with procedural language.

13. Which of the following can execute a trigger in PL/SQL?
a) Oracle server
b) User
c) Both user and oracle server
d) Neither user nor oracle server
View Answer

Answer: a
Explanation: A trigger is automatically executed by the Oracle server whenever a specified event occurs. A user can create and store a trigger and specify when to execute it but the its execution is done by the server automatically.

14. Which of the following SQL statement selects only unique values from ‘section’ column of table ‘school’?
a) SELECT section FROM school;
b) SELECT DISTINCT section FROM school;
c) SELECT * FROM school;
d) SELECT ALL section FROM school;
View Answer

Answer: b
Explanation: Distinct keyword along with Select clause returns only distinct values. All keyword when used with select clause returns all values without eliminating the duplicates. * Results all the fields of a table without eliminating duplicates.

15. Which SQL keyword is used to sort the data returned by a SELECT statement?
a) Group
b) Order
c) Group By
d) Order By
View Answer

Answer: d
Explanation: Order By clause is used to sort the retrieved data in ascending or descending order. Group By clause is used to group the result-set by one or more columns. Order and Group are not valid SQL commands.

16. The SQL LIKE operator is used in which of the following clause?
a) Having
b) Select
c) Where
d) Group by
View Answer

Answer: c
Explanation: The SQL LIKE operator is used in a WHERE clause to search for a specified pattern in a column.


Chapterwise Multiple Choice Questions on SQL

SQL MCQ - Multiple Choice Questions and Answers

Our 1000+ MCQs focus on all topics of the SQL subject, covering 100+ topics. This will help you to prepare for exams, contests, online tests, quizzes, viva-voce, interviews, and certifications. You can practice these MCQs chapter by chapter starting from the 1st chapter or you can jump to any chapter of your choice.
  1. SQL Basics
  2. Select Statement
  3. SQL Clause, Operators and Keywords
  4. SQL Statements
  5. SQL Numeric Functions
  6. SQL Operators and Wildcards
  7. SQL Joins
  8. Data Retrieval Techniques
  9. SQL Subqueries
  10. SQL Database
  11. SQL Constraints
  12. SQL Data Types, Views and Injection
  13. SQL Hosting, Operators and Data Types
  14. PL/SQL Basics
  15. PL/SQL Data Types and Variables
  16. PL/SQL Constants and Operators
  17. PL/SQL Loops, Strings and Arrays
  18. PL/SQL Procedures, Functions and Cursors
  19. PL/SQL Records, Exceptions and Triggers
  20. PL/SQL Packages, Collections and Transactions
  21. PL/SQL Data Types and DBMS Output

1. SQL Questions and Answers on Basics

The section contains multiple choice questions and answers on sql basics and sql syntax.

  • SQL Basics
  • SQL Syntax
  • 2. SQL MCQs on Select Statement

    The section contains questions and answers on sql select statement and select distinct statements.

  • SQL Select Statement
  • SQL Select Distinct
  • 3. SQL Clause, Operators and Keywords

    The section contains MCQs on SQL clauses such as WHERE and SELECT TOP, SQL keywords like ORDER BY, and SQL operators such as AND, OR, and NOT. It also covers topics related to SQL null values.

  • SQL Where Clause
  • SQL And, Or, Not
  • SQL Order By Clause
  • SQL Select Top Clause
  • SQL Null Values
  • 4. SQL Multiple Choice Questions on Statements

    The section contains multiple choice questions and answers on sql statements like insert, update and delete.

  • SQL Insert Into Statement
  • SQL Update Statement
  • SQL Delete Statement
  • 5. SQL Numeric Functions

    The section contains questions and answers on sql numeric functions like min, max, count, avg and sum.

  • SQL Min and Max Functions
  • SQL Count Function
  • SQL Avg & Sum Functions
  • 6. SQL Operators and Wildcards

    The section contains MCQs on sql like operator, wildcard characters, aliases, and the IN and BETWEEN SQL operators.

  • SQL Like Operator
  • SQL Wildcards
  • SQL In Operator
  • SQL Between Operator
  • SQL Aliases
  • 7. SQL Joins

    The section contains multiple choice questions and answers on sql union operator, as well as various joins like inner join, left join, right join, full and self joins.

  • SQL Joins
  • SQL Inner Join
  • SQL Left Join
  • SQL Right Join
  • SQL Full Join
  • SQL Self Join
  • SQL Union
  • 8. SQL Questions on Data Retrieval Techniques

    The section contains questions and answers on sql group by statement, sql having clause, sql exists operator, sql any and all operators.

  • SQL Group By
  • SQL Having Clause
  • SQL Exists
  • SQL Any & All
  • 9. SQL Subqueries

    The section contains MCQs on sql subqueries, sql statements like select into and insert into, sql null functions and sql comments.

  • SQL Subqueries
  • SQL Insert Into Select
  • SQL Null Functions
  • SQL Comments
  • 10. SQL Database

    The section contains multiple choice questions and answers on sql database and table creation, sql drop database, sql drop and alter tables.

  • SQL Database
  • SQL Drop DB
  • SQL Create Table
  • SQL Drop Table
  • SQL Alter Table
  • 11. SQL Constraints

    The section contains questions and answers on sql constraints like not null constraint, unique constraint, primary and foreign key constraints, sql check and default constraint, sql create index statement and sql auto-increment field.

  • SQL Constraints
  • SQL Not Null
  • SQL Unique Constraint
  • SQL Primary Key
  • SQL Foreign Key
  • SQL Check Constraint
  • SQL Default Constraint
  • SQL Index
  • SQL Auto Increment
  • 12. SQL Data Types, Views and Injection

    The section contains MCQs on sql dates data types, sql view statements and sql injection.

  • SQL Dates
  • SQL Views
  • SQL Injection
  • 13. SQL Hosting, Operators and Data Types

    The section contains multiple choice questions and answers on sql hosting, sql operators and sql data types.

  • SQL Hosting
  • SQL Operators
  • SQL Data Types
  • 14. PL/SQL Basics

    The section contains questions and answers on pl/sql basics and syntax.

  • PL/SQL Basics
  • PL/SQL Syntax
  • 15. PL/SQL Data Types and Variables

    The section contains MCQs on pl/sql data types and variables.

  • PL/SQL Data Types
  • PL/SQL Variables
  • 16. PL/SQL Constants and Operators

    The section contains multiple choice questions and answers on pl/sql constants and literals, pl/sql operators and conditions.

  • PL/SQL Constants and Literals
  • PL/SQL Operators
  • PL/SQL Conditions
  • 17. PL/SQL Loops, Strings and Arrays

    The section contains questions and answers on pl/sql loops, pl/sql strings and arrays.

  • PL/SQL Loops
  • PL/SQL Strings
  • PL/SQL Arrays
  • 18. PL/SQL Procedures, Functions and Cursors

    The section contains MCQs on pl/sql procedures, functions and cursors.

  • PL/SQL Procedure
  • PL/SQL Function
  • PL/SQL Cursors
  • 19. PL/SQL Records, Exceptions and Triggers

    The section contains multiple choice questions and answers on pl/sql records, pl/sql exceptions and triggers.

  • PL/SQL Records
  • PL/SQL Exceptions
  • PL/SQL Triggers
  • 20. PL/SQL Packages, Collections and Transactions

    The section contains questions and answers on pl/sql packages, collections and transactions.

  • PL/SQL Packages
  • PL/SQL Collections
  • PL/SQL Transactions
  • 21. PL/SQL Data Types and DBMS Output

    The section contains MCQs on pl/sql dbms output, pl/sql date and time data types.

  • PL/SQL Date and Time
  • PL/SQL DBMS Output
  • If you would like to learn "SQL" thoroughly, you should attempt to work on the complete set of 1000+ MCQs - multiple choice questions and answers mentioned above. It will immensely help anyone trying to crack an exam or an interview.

    Wish you the best in your endeavor to learn and master SQL!

    If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

    advertisement
    advertisement
    Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

    Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
    Manish Bhojasia - Founder & CTO at Sanfoundry
    Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

    Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.