SQL MCQs | Database Interview MCQ Questions and Answers

Test your knowledge of Database - [ SQL ] section with these interactive multiple-choice questions.

« First 1 2 3 4 Last »
« Previous Page Next Page »

1. Which SQL clause is used to filter records?

  • a) WHERE
  • b) HAVING
  • c) GROUP BY
  • d) ORDER BY
Answer: A - The WHERE clause filters records before any groupings are made.

2. What is the primary purpose of an SQL INDEX?

  • a) To speed up data retrieval
  • b) To enforce data integrity
  • c) To allocate storage space
  • d) To create backups
Answer: A - Indexes improve query performance by creating a quick lookup path.

3. Which SQL command permanently removes a table?

  • a) DROP TABLE
  • b) DELETE TABLE
  • c) TRUNCATE TABLE
  • d) REMOVE TABLE
Answer: A - DROP TABLE deletes the table structure and its data permanently.

4. What does SQL's ACID stand for?

  • a) Atomicity, Consistency, Isolation, Durability
  • b) Accuracy, Consistency, Integrity, Durability
  • c) Atomicity, Concurrency, Isolation, Durability
  • d) Automation, Consistency, Isolation, Durability
Answer: A - ACID properties ensure reliable transaction processing.

5. Which join returns all records from the left table?

  • a) LEFT JOIN
  • b) INNER JOIN
  • c) RIGHT JOIN
  • d) FULL JOIN
Answer: A - LEFT JOIN returns all left table records, matched or not.

6. What is the default sorting order of ORDER BY?

  • a) ASC (Ascending)
  • b) DESC (Descending)
  • c) Random
  • d) Depends on the database
Answer: A - ORDER BY sorts in ascending order unless specified otherwise.

7. Which constraint ensures column values are unique?

  • a) UNIQUE
  • b) PRIMARY KEY
  • c) FOREIGN KEY
  • d) CHECK
Answer: A - The UNIQUE constraint prevents duplicate values in a column.

8. Which function calculates the number of rows?

  • a) COUNT()
  • b) SUM()
  • c) AVG()
  • d) MAX()
Answer: A - COUNT() returns the number of rows matching a criteria.

9. What does DML stand for in SQL?

  • a) Data Manipulation Language
  • b) Data Modeling Language
  • c) Database Management Language
  • d) Data Migration Language
Answer: A - DML includes SELECT, INSERT, UPDATE, DELETE.

10. Which operator checks for NULL values?

  • a) IS NULL
  • b) = NULL
  • c) == NULL
  • d) NULL()
Answer: A - IS NULL is the correct way to test for null values.

11. What is the purpose of GROUP BY?

  • a) To group rows by column values
  • b) To filter groups
  • c) To sort results
  • d) To join tables
Answer: A - GROUP BY aggregates data by one or more columns.

12. Which command rolls back a transaction?

  • a) ROLLBACK
  • b) UNDO
  • c) REVERT
  • d) CANCEL
Answer: A - ROLLBACK undoes changes made in the current transaction.

13. What does a FOREIGN KEY constraint do?

  • a) Links two tables via a referenced primary key
  • b) Ensures unique values in a column
  • c) Automatically increments values
  • d) Encrypts column data
Answer: A - Foreign keys enforce referential integrity between tables.

14. Which wildcard matches any sequence of characters?

  • a) %
  • b) _
  • c) *
  • d) ?
Answer: A - % matches zero or more characters in LIKE clauses.

15. What is a subquery?

  • a) A query nested inside another query
  • b) A backup query
  • c) A temporary table
  • d) A stored procedure
Answer: A - Subqueries are SELECT statements used within another SQL statement.

16. Which command modifies existing data?

  • a) UPDATE
  • b) ALTER
  • c) MODIFY
  • d) CHANGE
Answer: A - UPDATE changes existing records in a table.

17. What is the purpose of HAVING?

  • a) To filter groups after GROUP BY
  • b) To filter rows before grouping
  • c) To sort results
  • d) To join tables
Answer: A - HAVING filters aggregated data, unlike WHERE.

18. Which SQL function combines strings?

  • a) CONCAT()
  • b) MERGE()
  • c) JOIN()
  • d) COMBINE()
Answer: A - CONCAT() merges two or more strings into one.

19. What does SQL's TRUNCATE TABLE do?

  • a) Removes all rows but keeps table structure
  • b) Deletes the table permanently
  • c) Archives table data
  • d) Renames the table
Answer: A - TRUNCATE is faster than DELETE for removing all rows.

20. Which clause removes duplicate rows?

  • a) DISTINCT
  • b) UNIQUE
  • c) GROUP BY
  • d) HAVING
Answer: A - DISTINCT eliminates duplicate values in the result set.
« First 1 2 3 4 Last »
« Previous Page Next Page »

SQL MCQs - Master Database Concepts from Basic to Advanced | PCBooks

🚀 Want to master SQL for interviews and exams? PCBooks offers the most comprehensive free SQL MCQ bank covering queries, joins, subqueries, and database optimization. Perfect for:

📊 SQL Query & Database Design MCQs

👉 SELECT, INSERT, UPDATE, DELETE command practice
👉 INNER, LEFT, RIGHT, FULL JOINs with real-world scenarios
👉 GROUP BY, HAVING, ORDER BY advanced usage
👉 Indexing strategies and query optimization techniques

📚 Free SQL Learning Path

🎯 Step-by-step tutorials on:
- Database normalization (1NF to BCNF)
- Stored procedures and functions
- Window functions (ROW_NUMBER, RANK, DENSE_RANK)
- Transaction control (COMMIT, ROLLBACK, SAVEPOINT)
🎯 Chapter-wise quizzes with detailed explanations
🎯 Downloadable SQL cheat sheets for quick revision

🚀 Practice SQL MCQs Now

Start Basic SQL MCQs →
MongoDB MCQs Practice →
Top 300 DBMS Concepts Interview Questions →


🏆 Trusted by 75,000+ learners for SQL certification and career growth!