SQL MCQ Test
20 random SQL multiple-choice questions with answers: SELECT, WHERE, ORDER BY, INSERT/UPDATE/DELETE, aggregate functions, GROUP BY, JOINs, keys and indexes.
- 20 random questions
- 20 minutes
- 45 in the question bank
No sign-up needed. Answers and explanations are shown at the end.
About this test
SQL is asked in nearly every placement test, from service companies to product startups. The questions here cover the queries you will write every day and the classic confusions: WHERE vs HAVING, INNER vs LEFT JOIN, and what NULL does to a count.
Pair it with the SQL Playground in Free Tools to run the queries yourself.
Each attempt picks new questions at random from the question bank. You can go back and change answers until you finish or the timer runs out. At the end you see your score, the right answer and a short explanation for every question, and the lessons to revise for the ones you missed.
Topics covered
- SQL Introduction
- SQL Databases and Tables
- SQL SELECT
- SQL WHERE
- SQL ORDER BY
- SQL INSERT
- SQL UPDATE
- SQL DELETE
- SQL Functions (COUNT, SUM, AVG)
- SQL GROUP BY
- SQL JOINs (INNER JOIN)
- SQL LEFT JOIN
- SQL Constraints and Keys
- SQL Indexes
- SQL Project: Library Database
Sample questions with answers
1. What does SQL stand for?
- Simple Question Language
- Server Query Logic
- Structured Query Language
Show answer
C. Structured Query Language — It talks to relational databases.
2. What is a primary key?
- The first column
- A column that uniquely identifies each row
- A password
Show answer
B. A column that uniquely identifies each row — It can't be NULL or duplicated.
3. Which removes duplicate rows from results?
- UNIQUE
- DISTINCT
- DIFFERENT
Show answer
B. DISTINCT — SELECT DISTINCT city FROM students.
4. How do you find rows where email is missing?
WHERE email == NULLWHERE email IS NULLWHERE email = NULL
Show answer
B. WHERE email IS NULL — = NULL is never true.
5. How do you sort highest first?
- ORDER BY marks UP
- SORT marks
- ORDER BY marks DESC
Show answer
C. ORDER BY marks DESC — ASC is the default.
6. Why always list the columns in INSERT?
- It's required
- It's faster
- The query keeps working if columns are added or reordered
Show answer
C. The query keeps working if columns are added or reordered — INSERT INTO t (a, b) VALUES (...).
7. What happens with UPDATE without WHERE?
- Every row is updated
- Error
- Nothing
Show answer
A. Every row is updated — Always check WHERE first (run it as a SELECT).
8. DELETE vs TRUNCATE vs DROP?
- DROP removes rows only
- They're the same
- DELETE removes rows; TRUNCATE empties the table quickly; DROP removes the table
Show answer
C. DELETE removes rows; TRUNCATE empties the table quickly; DROP removes the table — DROP deletes structure too.
9. COUNT(*) vs COUNT(email)?
- COUNT(*) skips NULLs
- COUNT(email) skips NULLs
- They're identical
Show answer
B. COUNT(email) skips NULLs — COUNT(*) counts all rows.
10. WHERE vs HAVING?
- HAVING runs first
- WHERE filters rows before grouping; HAVING filters groups
- They're the same
Show answer
B. WHERE filters rows before grouping; HAVING filters groups — HAVING COUNT(*) > 2.