You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Updated mysql-quiz.md with new MySQL questions (#7215)
Added multiple quiz questions and explanations related to MySQL features, including 'WITH ROLLUP', 'WINDOW' clause, transactions, 'EXPLAIN ANALYZE', and 'JSON_TABLE()'.
Copy file name to clipboardExpand all lines: mysql/mysql-quiz.md
+60Lines changed: 60 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1403,3 +1403,63 @@ The `UNION` operator in MySQL is used to combine the results of multiple `SELECT
1403
1403
The `HAVING` clause in a MySQL query is used to filter the groups in the result set based on the values of aggregate functions, such as `SUM`, `AVG`, `COUNT`, etc. This is different from the `WHERE` clause, which is used to filter the rows in the result set based on the values in the columns.
1404
1404
1405
1405
The `HAVING` clause is typically used in conjunction with the `GROUP BY` clause, which groups the rows in the result set based on the values in one or more columns.
1406
+
1407
+
#### Q153. In MySQL, what is the purpose of the `WITH ROLLUP` modifier in a `GROUP BY` clause?
1408
+
1409
+
-[ ] It removes duplicate rows before grouping
1410
+
-[x] It adds summary rows that represent subtotals and grand totals
1411
+
-[ ] It allows grouping by computed columns only
1412
+
-[ ] It enforces sorting order before aggregation
1413
+
1414
+
**Explanation:**
1415
+
`WITH ROLLUP` is an extension of `GROUP BY` that generates aggregate rows representing subtotals for each group and an overall total at the end of the result set.
1416
+
1417
+
1418
+
1419
+
#### Q154. In MySQL 8.0, what is the function of the `WINDOW` clause?
1420
+
1421
+
-[ ] It defines table partitions for join operations
1422
+
-[x] It allows naming and reusing window specifications for analytic functions
1423
+
-[ ] It creates a temporary view for query optimization
1424
+
-[ ] It defines a physical table alias for subqueries
1425
+
1426
+
**Explanation:**
1427
+
The `WINDOW` clause lets you define a named window (like frame and partitioning rules) for reuse across multiple window functions in the same query—great for readability and performance in analytic queries.
1428
+
1429
+
1430
+
1431
+
#### Q155. Which MySQL feature allows you to execute multiple SQL statements as a single unit that can be rolled back entirely in case of an error?
1432
+
1433
+
-[ ] Temporary table
1434
+
-[x] Transaction
1435
+
-[ ] Event scheduler
1436
+
-[ ] Trigger
1437
+
1438
+
**Explanation:**
1439
+
Transactions ensure atomicity — either all operations succeed or none are applied. They’re controlled via `START TRANSACTION`, `COMMIT`, and `ROLLBACK`.
1440
+
1441
+
1442
+
1443
+
#### Q156. What is the primary use of the `EXPLAIN ANALYZE` statement in MySQL 8.0.18 and later?
1444
+
1445
+
-[ ] To display user privileges on the database
1446
+
-[ ] To validate SQL syntax before execution
1447
+
-[x] To execute the query and display real execution time with the query plan
1448
+
-[ ] To show estimated cost without executing the query
1449
+
1450
+
**Explanation:**
1451
+
`EXPLAIN ANALYZE` actually runs the query and provides both estimated and **actual** execution metrics — useful for deep query performance tuning.
1452
+
1453
+
1454
+
1455
+
#### Q157. In MySQL, what does the `JSON_TABLE()` function do?
1456
+
1457
+
-[x] It maps JSON data into a relational table format for SQL querying
1458
+
-[ ] It stores JSON documents in a separate schema
1459
+
-[ ] It converts relational data back into JSON text
1460
+
-[ ] It indexes JSON data automatically for search
1461
+
1462
+
**Explanation:**
1463
+
`JSON_TABLE()` converts JSON documents into relational rows and columns, enabling powerful SQL queries over semi-structured JSON data using standard SQL syntax.
0 commit comments