Preparing for your next SQL interview? This interactive SQL MCQ list is your ultimate resource. It includes the most frequently asked SQL multiple-choice questions, covering key topics like queries, joins, indexing, and more. Test your skills and identify areas for improvement!
Note: "Score 60% or more and unlock an exclusive chance to grab up to 50% off on all self-paced SQL courses."
Let's Start!
1. What does SQL stand for?
2. Which SQL statement is used to retrieve data from a database?
3. Which SQL clause is used to filter rows before grouping?
4. Which clause is used to group rows having the same values?
5. Which SQL clause filters grouped results after aggregation?
6. Which keyword removes duplicate rows from a SELECT result?
7. Which clause is commonly used to sort query results?
8. What is the default sort direction of ORDER BY in standard SQL?
9. Which operator is used to search for a pattern in SQL?
10. Which wildcard represents any sequence of zero or more characters with LIKE?
11. Which LIKE wildcard represents exactly one character?
12. Which operator checks whether a value is within a specified range?
13. Which operator is used to compare a value against a list of values?
14. Which condition correctly checks whether a column contains NULL?
15. Which SQL expression is used to replace NULL with another value?
16. Which function returns the number of rows in a result set?
17. Which aggregate function returns the average of numeric values?
18. Which aggregate function returns the largest value?
19. Which aggregate function returns the smallest value?
20. Which aggregate function calculates the total of numeric values?
21. Which keyword is used to assign an alias to a column or table?
22. Which SQL statement is used to add new rows to a table?
23. Which SQL statement modifies existing rows?
24. Which SQL statement removes selected rows from a table?
25. Which statement removes an entire table definition and its data?
26. Which statement removes all rows while retaining the table structure in common SQL implementations?
27. Which SQL command is used to create a new table?
28. Which command modifies the structure of an existing table?
29. Which constraint uniquely identifies each row in a table?
30. What is a foreign key primarily used for?
31. Which constraint prevents NULL values in a column?
32. Which constraint ensures that values in a column are unique?
33. Which constraint is used to enforce a condition on column values?
34. Which constraint supplies a value when no value is explicitly provided?
35. Which type of join returns matching rows from both tables?
36. Which join returns all rows from the left table and matching rows from the right table?
37. Which join returns all rows from the right table and matching rows from the left table?
38. What does a CROSS JOIN produce?
39. Which join can return matched and unmatched rows from both tables?
40. Which SQL join is useful when a table is joined to itself?
41. Which set operator combines results and removes duplicate rows?
42. Which set operator combines results while retaining duplicates?
43. Which set operator returns rows present in both query results?
44. Which SQL concept is used to query the result of another SELECT statement?
45. What is a correlated subquery?
46. Which keyword is commonly used to test whether a subquery returns at least one row?
47. Which SQL object stores a reusable query definition?
48. Which command is generally used to create a view?
49. What is a common reason for using a database view?
50. What is an index primarily designed to improve?
51. What is a common trade-off of adding indexes?
52. Which index can contain multiple columns?
53. In a composite index on (A, B), which query often benefits most directly from the index prefix?
54. What does a query execution plan show?
55. Which practice is generally useful when diagnosing a slow SQL query?
56. Which SQL feature assigns a sequential value or ranking within a result set?
57. Which window function assigns a unique sequential number to rows?
58. What happens to ranking values after a tie when using RANK()?
59. How does DENSE_RANK() differ from RANK()?
60. Which clause defines the rows over which a window function operates?
61. Which keyword divides rows into groups for a window function?
62. Which window function is commonly used to calculate a running total?
63. Which function returns a value from a following row in a window?
64. Which function returns a value from a preceding row in a window?
65. Which SQL expression is commonly used for conditional logic?
66. Which expression returns the first non-NULL value from its arguments?
67. Which SQL function is commonly used to count non-NULL values in a specific column?
68. What does COUNT(*) generally count?
69. Which SQL function is commonly used to determine the number of characters in a string?
70. Which function is commonly used to convert text to uppercase?
71. Which function is commonly used to convert text to lowercase?
72. Which SQL function is commonly used to remove leading and trailing spaces?
73. Which function is commonly used to concatenate strings in SQL?
74. Which SQL function is commonly used to extract part of a string?
75. Which SQL function is commonly used to round a numeric value?
76. Which SQL function returns the absolute value of a number?
77. Which SQL function can return the current date in many database systems?
78. Which SQL data type is intended to store calendar dates without time?
79. Which SQL data type is designed to represent both date and time in systems that support it?
80. Which SQL clause is logically evaluated after GROUP BY for filtering grouped rows?
81. Which clause is logically evaluated before GROUP BY to filter individual rows?
82. Which clause specifies the source tables for a SELECT statement?
83. Which clause specifies the columns or expressions returned by a SELECT query?
84. What does SELECT * generally mean?
85. Which SQL statement is commonly used to change a table by adding a column?
86. Which SQL command can rename a table in database systems that support the standard-style syntax?
87. Which SQL category primarily contains CREATE, ALTER, and DROP?
88. Which category generally includes INSERT, UPDATE, and DELETE?
89. Which SQL category is associated with COMMIT and ROLLBACK?
90. Which SQL category includes GRANT and REVOKE?
91. What does COMMIT do in a transaction?
92. What does ROLLBACK generally do?
93. What is a database transaction?
94. In ACID properties, what does Atomicity mean?
95. In ACID properties, what does Consistency ensure?
96. In ACID properties, what does Isolation address?
97. In ACID properties, what does Durability mean?
98. Which isolation level generally permits dirty reads?
99. What is a dirty read?
100. What is a non-repeatable read?
101. What is a phantom read?
102. Which isolation level provides the strongest standard isolation?
103. What is a database deadlock?
104. Which database mechanism is commonly used to control concurrent access to data?
105. What is normalization primarily intended to reduce?
106. Which normal form requires atomic values and no repeating groups?
107. What additional dependency does 2NF eliminate compared with 1NF?
108. What dependency does 3NF primarily eliminate?
109. What is denormalization?
110. What is a functional dependency?
111. Which key is a minimal set of attributes that uniquely identifies a row?
112. What is a superkey?
113. What is a composite key?
114. What is referential integrity intended to maintain?
115. Which foreign key action can automatically remove related child rows when a parent row is deleted?
116. What is a stored procedure?
117. What is a database trigger?
118. What is a common concern with excessive trigger usage?
119. What is a user-defined function in SQL?
120. What is a common advantage of a stored procedure?
121. What is a Common Table Expression (CTE)?
122. Which keyword introduces a standard CTE?
123. What is a recursive CTE useful for?
124. What is a recursive CTE composed of conceptually?
125. What is a temporary table primarily used for?
126. Which SQL concept represents a query result as a virtual table without necessarily storing the result data separately?
127. Which type of view stores the query result physically in systems that support materialized views?
128. What is a major benefit of a materialized view?
129. What is query optimization?
130. What does a database optimizer typically use to choose an execution plan?
131. Why can SELECT * be undesirable in production queries?
132. What is a sargable predicate?
133. Which condition can make an indexed column less likely to be searched efficiently in many databases?
134. What is a full table scan?
135. When can a full table scan be a reasonable execution strategy?
136. What is a covering index?
137. What is index selectivity?
138. Which column is generally a strong candidate for indexing?
139. What is a database schema?
140. What is a database catalog or data dictionary?
141. What does SQL injection exploit?
142. Which technique is a primary defense against SQL injection?
143. Why should application code avoid building SQL with untrusted string concatenation?
144. What is the principle of least privilege in database security?
145. Which SQL command is commonly used to grant privileges?
146. Which SQL command removes previously granted privileges?
147. What is a database role?
148. What is data masking used for?
149. What is database encryption primarily intended to protect?
150. What is a database backup?
151. What is a point-in-time recovery capability designed to do?
152. What is a transaction log commonly used for?
153. What is database replication?
154. What is read replication commonly used for?
155. What is replication lag?
156. What is sharding?
157. What is horizontal partitioning?
158. What is vertical partitioning?
159. What is partition pruning?
160. Which partitioning strategy divides data according to ranges of values?
161. Which partitioning strategy uses a hash function to distribute rows?
162. Which partitioning strategy assigns rows based on specified discrete values?
163. What is a surrogate key?
164. What is a natural key?
165. What does cardinality describe in a database relationship?
166. Which relationship means one record in one table can relate to many records in another?
167. Which relationship allows records in both tables to relate to multiple records in the other table?
168. How is a many-to-many relationship commonly implemented in a relational database?
169. What is an entity in relational database design?
170. What does an ER diagram primarily represent?
171. Which SQL query finds rows whose value appears more than once in a column?
172. Which technique is commonly used to remove duplicate rows while retaining one row per group?
173. Which query pattern is commonly used to find the second-highest distinct salary?
174. Which window function is particularly useful for finding the top N rows per group?
175. Why is DENSE_RANK() often useful for top-N-per-group queries when ties should share a rank without gaps?
176. Which clause can be used with FETCH FIRST in databases that support the standard syntax to limit returned rows?
177. What is the purpose of LIMIT in SQL dialects that support it?
178. Why should a row limit usually be combined with ORDER BY when retrieving a top-N result?
179. What is keyset pagination?
180. What is a common disadvantage of deep OFFSET pagination on large tables?
181. Which join condition is most important for preventing an accidental Cartesian product in a typical relational join?
182. What is an anti-join pattern commonly used for?
183. Which SQL construct is commonly used to implement an anti-join?
184. Which construct is often used to test whether a matching row exists without needing columns from the subquery?
185. Why can NOT EXISTS be preferable to NOT IN when the subquery can contain NULL values?
186. What is three-valued logic in SQL?
187. Why is comparing a column directly with NULL using = problematic?
188. Which operator checks whether an expression is not NULL?
189. Which function can return the first non-NULL value among several expressions?
190. Which SQL expression is useful for returning one value when a condition is true and another when it is false?
191. Which clause is generally evaluated last in the logical processing order of a SELECT query?
192. Why can't a SELECT-list alias always be referenced in the WHERE clause?
193. Which clause can often reference a SELECT-list alias because it is processed later?
194. What is the purpose of DISTINCT?
195. What is the difference between DELETE and TRUNCATE at a high level?
196. Which statement is used to delete selected rows based on a condition?
197. What is an upsert?
198. Which SQL feature is commonly associated with upsert behavior in PostgreSQL?
199. What is the purpose of the SQL MERGE statement in systems that support it?
200. What is an identity column commonly used for?
201. What is a sequence object commonly used for?
202. What is an auto-incrementing key commonly used for?
203. What is a generated column?
204. What is a check constraint useful for?
205. What is a unique constraint designed to enforce?
206. Which constraint is generally used to ensure a column cannot be left without a value?
207. Which SQL statement is used to grant SELECT permission on a table?
208. What does CASCADE generally mean in a referential action?
209. What does ON DELETE SET NULL do when supported and applicable?
210. Which requirement must generally be satisfied before a foreign key can use SET NULL?
211. What is an aggregate query?
212. Which function can count distinct customer IDs?
213. Why might COUNT(column) return fewer rows than COUNT(*)?
214. Which aggregate function can calculate the total number of non-NULL numeric values?
215. Which clause is required when you want separate aggregate results for each department?
216. Which query correctly filters departments whose average salary exceeds 50000?
217. Which clause should normally be used to filter rows before calculating an aggregate?
218. What is the purpose of FILTER in aggregate expressions in SQL dialects that support it?
219. What is a window aggregate?
220. Which query pattern can calculate each employee's salary as a percentage of total salary?
221. What is a lateral join used for in SQL dialects that support it?
222. What does NATURAL JOIN do in systems that support it?
223. Why can NATURAL JOIN be risky in production SQL?
224. What is a semi-join conceptually used to find?
225. Which SQL construct commonly expresses a semi-join?
226. What is the main difference between WHERE and HAVING?
227. Which clause is used to specify ascending or descending order?
228. Which keyword explicitly requests descending sort order?
229. Which SQL operator combines multiple conditions where all specified conditions must be true?
230. Which SQL operator is true when at least one of its conditions is true?
231. Which operator reverses a Boolean condition?
232. Which comparison operator means "not equal" in standard SQL?
233. Which operator means "greater than or equal to"?
234. Which operator checks whether a value falls inclusively between two boundaries?
235. Which statement about BETWEEN is generally correct?
236. Which operator can test whether a value belongs to a specified list?
237. What does NOT IN return when the list contains NULL under SQL's three-valued logic?
238. Which SQL feature is useful for recursive hierarchical queries?
239. Which example is best suited for a recursive SQL query?
240. What is a recursive query's base or anchor member?
241. What is an execution plan operator such as an index seek or scan?
242. Why are database statistics important to query optimization?
243. What can happen when optimizer statistics are significantly outdated?
244. What is a parameterized SQL query?
245. Besides improving security, what can parameterized queries help with?
246. What is SQL prepared statement execution?
247. Which SQL concept is most useful for returning a value from a previous row without joining the table to itself?
248. Which SQL concept is useful for comparing the current row with the next row?
249. Which window function returns the first value within an ordered window frame?
250. Which window function returns the last value within an ordered window frame?
You Can Also Check:
1. Top SQL Server Interview Questions And Answer
2. PostgreSQL Tutorial For Beginners in 2026
3. How to Delete Duplicate Rows in SQL?
4. What is NoSQL Database?
5. Top Salesforce Developer Skills You Should Learn In 2026 6. What is PL/SQL- Everything You Need To Know