30 SQL Quiz Questions and Answers

SQL (Structured Query Language) is a domain-specific programming language used for managing and manipulating relational databases. It is the standard language for communicating with and querying databases, and it provides a set of commands and statements to perform various operations on data, such as retrieving, inserting, updating, and deleting records.

Key Features of SQL:

Relational Databases: SQL is primarily designed for working with relational databases, which organize data into tables with rows and columns.

Data Querying: SQL allows users to retrieve specific data from databases using SELECT statements, filtering records based on various conditions.

Data Manipulation: SQL provides commands for inserting new records into tables (INSERT), updating existing records (UPDATE), and deleting records (DELETE).

Data Definition: SQL also includes Data Definition Language (DDL) commands to define and modify the structure of database objects, such as creating tables (CREATE TABLE), altering tables (ALTER TABLE), and dropping tables (DROP TABLE).

Pro Tip

You can build engaging online quizzes with our free online quiz maker.

Data Control: SQL offers Data Control Language (DCL) commands to grant and revoke permissions for accessing database objects.

Data Integrity: SQL enforces data integrity through constraints like PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, and CHECK, ensuring that data remains consistent and accurate.

In this article

Part 1: 30 SQL quiz questions & answers

1. What does SQL stand for?
a) Structured Query Language
b) Sequential Query Language
c) Standardized Query Logic
d) Structured Query Logic
Answer: a) Structured Query Language

2. Which type of database does SQL primarily work with?
a) Hierarchical database
b) Network database
c) Relational database
d) Object-oriented database
Answer: c) Relational database

3. Which SQL command is used to retrieve data from a database?
a) INSERT
b) DELETE
c) SELECT
d) UPDATE
Answer: c) SELECT

4. What is the purpose of the SQL INSERT statement?
a) To update existing records in a table
b) To delete records from a table
c) To add new records to a table
d) To retrieve data from a table
Answer: c) To add new records to a table

5. Which SQL keyword is used to filter data in a SELECT statement?
a) FILTER
b) WHERE
c) HAVING
d) BY
Answer: b) WHERE

6. What is the purpose of the SQL UPDATE statement?
a) To add new records to a table
b) To delete records from a table
c) To update existing records in a table
d) To retrieve data from a table
Answer: c) To update existing records in a table

7. Which SQL keyword is used to delete data from a table?
a) REMOVE
b) ERASE
c) DELETE
d) DROP
Answer: c) DELETE

8. Which SQL statement is used to create a new database?
a) CREATE DATABASE
b) NEW DATABASE
c) ADD DATABASE
d) BUILD DATABASE
Answer: a) CREATE DATABASE

9. Which SQL command is used to add a new table to an existing database?
a) CREATE TABLE
b) ADD TABLE
c) INSERT TABLE
d) NEW TABLE
Answer: a) CREATE TABLE

10. Which SQL statement is used to change the structure of an existing table?
a) MODIFY TABLE
b) ALTER TABLE
c) CHANGE TABLE
d) UPDATE TABLE
Answer: b) ALTER TABLE

11. Which SQL function is used to count the number of rows in a table?
a) SUM()
b) AVG()
c) COUNT()
d) MAX()
Answer: c) COUNT()

12. The SQL ORDER BY keyword is used to:
a) Filter rows in a table
b) Group rows based on a condition
c) Sort rows in a specified order
d) Join multiple tables
Answer: c) Sort rows in a specified order

13. Which SQL command is used to join two or more tables together based on a related column?
a) MERGE
b) UNION
c) JOIN
d) COMBINE
Answer: c) JOIN

14. Which type of SQL join returns only the rows that have matching values in both tables?
a) INNER JOIN
b) LEFT JOIN
c) RIGHT JOIN
d) FULL JOIN
Answer: a) INNER JOIN

15. What does the SQL GROUP BY clause do?
a) Filters rows in a table
b) Sorts rows in a specified order
c) Groups rows based on a condition
d) Combines multiple tables
Answer: c) Groups rows based on a condition

Part 2: Download SQL questions & answers for free

Download questions & answers for free

16. Which SQL clause is used to filter rows after grouping with the GROUP BY clause?
a) HAVING
b) WHERE
c) ORDER BY
d) GROUP AFTER
Answer: a) HAVING

17. What is the purpose of the SQL DISTINCT keyword?
a) Deletes duplicate rows from a table
b) Returns only the first occurrence of each unique value
c) Filters rows based on a condition
d) Changes the data type of a column
Answer: b) Returns only the first occurrence of each unique value

18. Which SQL function is used to find the highest value in a column?
a) SUM()
b) AVG()
c) COUNT()
d) MAX()
Answer: d) MAX()

19. What does the SQL LIKE operator do?
a) Compares two values for equality
b) Checks if a value is NULL
c) Searches for a pattern in a column
d) Combines the results of two queries
Answer: c) Searches for a pattern in a column

20. The SQL BETWEEN operator is used to:
a) Combine the results of two queries
b) Check if a value falls within a specified range
c) Search for a pattern in a column
d) Compare two values for equality
Answer: b) Check if a value falls within a specified range

21. The SQL IN operator is used to:
a) Combine the results of two queries
b) Check if a value is NULL
c) Search for a pattern in a column
d) Compare a value to a list of values
Answer: d) Compare a value to a list of values

22. What does the SQL NULL value represent?
a) A missing or unknown value
b) Zero or empty value
c) A placeholder for future data
d) An error or invalid value
Answer: a) A missing or unknown value

23. Which SQL statement is used to delete a table from a database?
a) DROP TABLE
b) DELETE TABLE
c) REMOVE TABLE
d) ERASE TABLE
Answer: a) DROP TABLE

24. Which SQL command is used to grant permissions to a user in a database?
a) GRANT PERMISSION
b) GIVE PERMISSION
c) ALLOW PERMISSION
d) GRANT
Answer:

d) GRANT

25. What is the purpose of the SQL JOIN clause?
a) To filter rows in a table
b) To group rows based on a condition
c) To sort rows in a specified order
d) To combine rows from multiple tables
Answer: d) To combine rows from multiple tables

26. Which SQL function is used to calculate the average value of a column?
a) SUM()
b) AVG()
c) COUNT()
d) MAX()
Answer: b) AVG()

Just to let you know

Sign up for a free OnlineExamMaker account to create an interactive online quiz in minutes – automatic grading & mobile friendly.

27. The SQL UNION operator is used to:
a) Combine the results of two queries
b) Check if a value is NULL
c) Search for a pattern in a column
d) Compare two values for equality
Answer: a) Combine the results of two queries

28. What does the SQL NOT operator do?
a) Combines the results of two queries
b) Checks if a value is NULL
c) Negates a condition in a WHERE clause
d) Searches for a pattern in a column
Answer: c) Negates a condition in a WHERE clause

29. The SQL TRUNCATE TABLE command is used to:
a) Delete specific rows from a table
b) Remove all rows from a table
c) Change the structure of a table
d) Update values in a table
Answer: b) Remove all rows from a table

30. What is the purpose of the SQL GROUP BY clause?
a) Filters rows in a table
b) Sorts rows in a specified order
c) Groups rows based on a condition
d) Combines multiple tables
Answer: c) Groups rows based on a condition

Part 3: Best online quiz making platform – OnlineExamMaker

OnlineExamMaker gives you everything you need to create interactive online quizzes to assess students and staffs, and engage potential customers. The online quiz platform offers options for adding multimedia elements, such as images and videos, to enhance the quiz-taking experience.

Create Your Next Quiz/Exam with OnlineExamMaker

SAAS, free forever
100% data ownership