Section 1: Basic SQL Concepts (1–10)
1. What does SQL stand for?
2. Which part of SQL is primarily used to retrieve data?
3. SQL is programming language for storing and processing information in?
4. Which keyword begins a query that retrieves data from a table?
5. SQL is considered what type of language?
6. Which of the following is a common relational database system?
7. Which keyword removes duplicates in a SELECT statement?
8. Which statement changes data in a database?
9. In SQL, which symbol is commonly used as a wildcard in strings?
10. Which command is used to remove rows from a table?
11. Which clause specifies the source table(s) in a query?
12. Which keyword selects all columns from a table?
13. To select a literal string "Hello", you can write:
14. To rename a column in the result set, use:
15. If you omit FROM, selecting from where is possible in standard SQL?
16. To choose columns "name" and "age" from table "persons":
17. A SELECT statement without a WHERE clause returns:
18. To avoid specifying a table alias, you can:
19. Which of these is a valid SELECT syntax?
20. Using SELECT without specifying columns returns:
21. The WHERE clause is used to:
22. To select rows where age > 18:
23. To match rows where name starts with 'A':
24. To select rows where city is either 'Paris' or 'London':
25. The WHERE clause is placed:
26. To find rows where salary is NOT 5000:
27. Which operator checks for NULL values?
28. To exclude rows with age = 30:
29. To use a pattern to filter rows containing 'abc' anywhere in name:
30. To filter rows where price is between 10 and 20 inclusive:
31. Which function returns the number of rows?
32. SUM() function is used to:
33. MIN() function returns:
34. MAX() function returns:
35. AVG() function returns:
36. COUNT(*) differs from COUNT(column) by:
37. To get total sales from 'orders' table with 'amount' column:
38. To find the lowest salary in employees table:
39. To count rows ignoring NULL in column 'age':
40. Which function can remove duplicates when counting distinct values?
41. GROUP BY is used to:
42. GROUP BY must be used with:
43. HAVING clause filters rows after:
44. To find total sales per department:
45. HAVING is used to filter groups, for example groups with SUM(sales)>1000:
46. If a SELECT uses GROUP BY, columns not aggregated must be:
47. Average salary by job_title but only show groups with avg>5000:
48. Without GROUP BY, HAVING acts like WHERE, but standard SQL requires:
49. Count employees per department and only show departments with count>10:
50. You cannot use HAVING without what?
51. ORDER BY is used to:
52. By default ORDER BY sorts in:
53. To sort by name ascending and age descending:
54. ORDER BY must come:
55. To sort by a column not in SELECT, generally:
56. To sort by multiple columns, separate by:
57. To get alphabetical order on 'name':
58. To reverse the sorting order:
59. If no ORDER BY specified, order of rows is:
60. ORDER BY can sort by column position using:
61. INNER JOIN returns:
62. LEFT JOIN returns:
63. RIGHT JOIN returns:
64. FULL OUTER JOIN returns:
65. To join 'orders' and 'customers' where orders.cust_id=customers.id:
66. INNER JOIN is also called:
67. To get all customers even if they have no orders:
68. CROSS JOIN returns:
69. To filter joined results, use conditions in:
70. If you want all rows from both tables with no match replaced by NULLs:
71. A subquery is:
72. Subqueries are often used in:
73. A scalar subquery returns:
74. To find rows with value greater than the average, use:
75. A derived table is a subquery used:
76. A subquery returning multiple values can be used with:
77. Correlated subqueries:
78. To use a subquery as a column list:
79. Subqueries can appear in:
80. A derived table must have:
81. UNION combines:
82. UNION requires:
83. UNION by default removes duplicates. To keep duplicates use:
84. INTERSECT returns:
85. EXCEPT returns:
86. Set operations typically require:
87. UNION ALL vs UNION differs by:
88. INTERSECT and EXCEPT might not be supported by all SQL dialects. A common replacement for INTERSECT is:
89. Set operators combine results of multiple SELECTs. The correct syntax usually is:
90. EXCEPT is sometimes known as:
91. CREATE TABLE is used to:
92. DROP TABLE does what?
93. ALTER TABLE is used to:
94. To remove a column from a table:
95. CREATE TABLE syntax generally includes:
96. To rename a table:
97. To add a new column:
98. DDL statements like CREATE, DROP, ALTER usually:
99. To completely remove a table and its data:
100. To remove all rows but keep table structure:
101. INSERT is used to:
102. UPDATE changes:
103. DELETE removes:
104. INSERT INTO table (col1, col2) VALUES (val1, val2):
105. To update a row's salary in employees:
106. DELETE FROM table WHERE condition:
107. To insert multiple rows at once (some dialects allow):
108. Without WHERE in UPDATE or DELETE:
109. INSERT can be combined with SELECT to:
110. TRUNCATE TABLE differs from DELETE because:
111. PRIMARY KEY ensures:
112. FOREIGN KEY enforces:
113. UNIQUE constraint ensures:
114. NOT NULL ensures:
115. CHECK constraint allows:
116. A table can have how many PRIMARY KEY constraints?
117. FOREIGN KEY references:
118. UNIQUE differs from PRIMARY KEY in that:
119. To ensure age > 0 in a column, use:
120. Constraints are defined usually in:
121. A VIEW is:
122. CREATE VIEW syntax includes:
123. A MATERIALIZED VIEW is:
124. Views can be used to:
125. To refresh a materialized view (in systems that support it):
126. Dropping a view:
127. Some views are updatable if:
128. A view does not physically store data except:
129. To ensure view runs a complex query efficiently without recalculating each time, use:
130. Views can be used for security by:
131. An index is used to:
132. A primary key usually creates:
133. Adding too many indexes can:
134. A clustered index:
135. Non-clustered index stores:
136. To analyze query performance, one might use:
137. Indexes help SELECT queries but can slow down:
138. A good candidate for indexing is:
139. Removing unused indexes can:
140. Indexes are created by:
141. A window function is defined using:
142. Window functions allow calculations:
143. PARTITION BY in window functions:
144. ROW_NUMBER() function:
145. RANK() vs ROW_NUMBER():
146. LAG() and LEAD() functions allow:
147. NTILE(n) divides rows into:
148. To use window functions, OVER clause is mandatory because:
149. Window functions do not collapse rows like GROUP BY. They:
150. ORDER BY inside OVER(...) defines:
151. A CTE starts with:
152. A CTE is defined for:
153. CTEs can be used to:
154. A CTE resembles a derived table, but:
155. Recursive CTEs allow:
156. Syntax of a basic CTE:
157. Multiple CTEs can be defined by:
158. CTEs are not stored persistently; they are:
159. Recursive CTEs need:
160. CTEs improve readability compared to:
161. String functions like LENGTH() or CHAR_LENGTH() return:
162. SUBSTRING(string, start, length) extracts:
163. UPPER() and LOWER() functions change string case to:
164. Date functions like NOW() or CURRENT_DATE():
165. EXTRACT(YEAR FROM date) returns:
166. DATEADD or ADD_MONTHS are used to:
167. CASE expression allows:
168. CASE WHEN condition THEN value ELSE other END:
169. String functions like CONCAT(s1,s2):
170. COALESCE(expr1, expr2, ...) returns:
171. A stored procedure is:
172. A stored function differs from a procedure by:
173. CREATE PROCEDURE syntax varies by dialect, but generally includes:
174. Stored procedures can improve performance by:
175. Functions are often used in SELECT statements because:
176. Stored procedures can accept IN, OUT parameters to:
177. In PL/SQL or T-SQL, you can write:
178. To drop a stored procedure:
179. Stored functions must:
180. Procedures and functions enhance:
181. A transaction is:
182. COMMIT saves changes made during a transaction:
183. ROLLBACK undoes:
184. BEGIN or START TRANSACTION begins:
185. Isolation levels define:
186. A common isolation level is:
187. Locking is used to prevent:
188. Deadlocks occur when:
189. COMMIT ends a transaction and makes changes:
190. SAVEPOINT allows:
191. Partitioning a table means:
192. Horizontal partitioning splits data by:
193. Vertical partitioning splits data by:
194. Sharding is a form of partitioning where:
195. Caching query results in memory can:
196. Query optimization involves:
197. Table partitioning can improve performance by:
198. Parallel query execution means:
This quiz is for Premium Users only, purchase a premium membership here to access.
199. Compression in databases can:
This quiz is for Premium Users only, purchase a premium membership here to access.