MySQL Practice Quiz: 20 Multiple Choice Questions with Answers

MySQL 30 min min read Updated: Nov 27, 2026 Beginner
MySQL Practice Quiz: 20 Multiple Choice Questions with Answers
Beginner Topic 2 of 3

How to Use This Quiz

Cover the answers, pick an option for each question, then check. Aim for at least 16 out of 20. For every miss, run the example in your own MySQL 8.0 server and re-read that lesson.

Q1. Which storage engine should you use for transactions and foreign keys?

  • A) InnoDB
  • B) MyISAM
  • C) MEMORY
  • D) CSV

Answer: A. InnoDB supports transactions, row-level locks and foreign keys. It is the default.

Q2. Which character set stores emoji correctly?

  • A) latin1
  • B) utf8 (utf8mb3)
  • C) utf8mb4
  • D) ascii

Answer: C. Emoji need 4 bytes per character. MySQL's utf8 is only 3 bytes, so use utf8mb4.

Q3. What does INSERT IGNORE do on a duplicate key?

  • A) Replaces the existing row
  • B) Skips the row with a warning
  • C) Updates the existing row
  • D) Rolls back the transaction

Answer: B. IGNORE turns the duplicate error into a warning and skips the row. REPLACE deletes and re-inserts, and ON DUPLICATE KEY UPDATE updates.

Q4. Which statement is the clean upsert in MySQL?

  • A) INSERT OR REPLACE
  • B) UPSERT INTO
  • C) MERGE INTO
  • D) INSERT ... ON DUPLICATE KEY UPDATE

Answer: D. MySQL uses INSERT ... ON DUPLICATE KEY UPDATE. MERGE is SQL Server and Oracle, INSERT OR REPLACE is SQLite.

Q5. After deleting the row with the highest AUTO_INCREMENT id and inserting a new row, what id does the new row get?

  • A) NULL
  • B) The deleted id again
  • C) A new, higher id
  • D) 0

Answer: C. Ids are not reused. The counter keeps going, so gaps are normal.

Q6. Which error appears when you select a column that is not in GROUP BY (default sql_mode)?

  • A) Error 1055 (ONLY_FULL_GROUP_BY)
  • B) Error 1064 syntax error
  • C) No error
  • D) Error 1146 table missing

Answer: A. ONLY_FULL_GROUP_BY rejects non-aggregated, non-grouped columns. Use ANY_VALUE() or group the column.

Q7. How does MySQL handle FULL OUTER JOIN?

  • A) It is called CROSS APPLY
  • B) It works like in PostgreSQL
  • C) It needs a special engine
  • D) It is not supported; use LEFT JOIN UNION RIGHT JOIN

Answer: D. MySQL has no FULL OUTER JOIN. Combine a left and a right join with UNION.

Q8. Window functions such as ROW_NUMBER() need which MySQL version?

  • A) 5.5
  • B) 8.0 or later
  • C) 5.7
  • D) Any version

Answer: B. Window functions arrived in MySQL 8.0.

Q9. What does EXPLAIN show for type = ALL?

  • A) A constant row
  • B) A perfect index lookup
  • C) A full table scan
  • D) A cached result

Answer: C. ALL means every row is read. ref, range and const use an index.

Q10. A composite index is on (country, created). Which filter uses it best?

  • A) WHERE country = 'IN' AND created >= '2025-01-01'
  • B) WHERE created = '2025-01-01' only
  • C) WHERE LOWER(country) = 'in'
  • D) WHERE country LIKE '%N'

Answer: A. The leftmost column is used with equality first, then a range. Functions and leading wildcards defeat the index.

Q11. What does col->>'$.name' return for a JSON column?

  • A) The value with JSON quotes
  • B) The value as plain text
  • C) A JSON array
  • D) The key name

Answer: B. ->> unquotes the value. -> returns JSON, so strings keep their quotes.

Q12. Which index type lets you search inside a JSON array using MEMBER OF?

  • A) A spatial index
  • B) A prefix index
  • C) A FULLTEXT index
  • D) A multi-valued index

Answer: D. Multi-valued indexes (8.0.17+) index every element of a JSON array.

Q13. What is the default transaction isolation level in InnoDB?

  • A) REPEATABLE READ
  • B) READ COMMITTED
  • C) SERIALIZABLE
  • D) READ UNCOMMITTED

Answer: A. InnoDB defaults to REPEATABLE READ: one consistent snapshot per transaction.

Q14. What happens to a transaction when a DDL statement such as CREATE TABLE runs inside it?

  • A) Nothing special
  • B) It is rolled back
  • C) It is committed implicitly first
  • D) It is paused

Answer: C. Most DDL statements cause an implicit commit in MySQL and cannot be rolled back.

Q15. Which error code means a deadlock victim in MySQL?

  • A) 1146
  • B) 1062
  • C) 1205
  • D) 1213

Answer: D. 1213 is a deadlock (retry the transaction). 1205 is a lock wait timeout, 1062 a duplicate key.

Q16. What does SELECT ... FOR UPDATE SKIP LOCKED do?

  • A) Waits until locks are released
  • B) Skips rows locked by others
  • C) Fails if any row is locked
  • D) Unlocks all rows

Answer: B. SKIP LOCKED returns only rows nobody has locked, which is perfect for job queues. NOWAIT fails instead.

Q17. Which mysqldump option gives a consistent InnoDB backup without locking tables?

  • A) --lock-all-tables
  • B) --single-transaction
  • C) --no-data
  • D) --skip-opt

Answer: B. --single-transaction uses one consistent snapshot. Add --routines --triggers --events for stored programs.

Q18. What is the recommended way to give an app access to a database?

  • A) A dedicated user with only the needed privileges
  • B) The root account
  • C) A shared admin account
  • D) No password for convenience

Answer: A. Least privilege limits the damage if the app is compromised.

Q19. Why is LIMIT 20 OFFSET 100000 slow on a large table?

  • A) LIMIT locks the table
  • B) OFFSET disables indexes
  • C) MySQL reads and discards 100,000 rows
  • D) It is not slow

Answer: C. The skipped rows are still read. Keyset pagination (WHERE id > :last) avoids this.

Q20. What does a BEFORE INSERT trigger let you do that an AFTER trigger cannot?

  • A) Run faster
  • B) Read the OLD values
  • C) Access other tables
  • D) Change the NEW values before they are stored

Answer: D. In a BEFORE trigger you can modify NEW (for example trim text or set defaults) or block the row with SIGNAL.

Score Yourself

ScoreMeaningNext step
18-20ExcellentDo the labs and the advanced interview page
14-17GoodReview the lessons for the questions you missed
10-13FairRedo the lessons on joins, indexes and transactions, running every example
Below 10Keep goingStart again from the foundations lesson and practice daily

Quick Check by Running Code

Verify two quiz answers yourself:

sql CREATE TABLE t (id INT AUTO_INCREMENT PRIMARY KEY, v CHAR(1)); INSERT INTO t (v) VALUES ('a'), ('b'); DELETE FROM t WHERE id = 2; INSERT INTO t (v) VALUES ('c'); SELECT id, v FROM t ORDER BY id;

Result:

idv
1a
3c
sql SELECT JSON_EXTRACT('{"name": "Asha"}', '$.name') AS with_arrow, JSON_UNQUOTE(JSON_EXTRACT('{"name": "Asha"}', '$.name')) AS like_double_arrow;

Result:

with_arrowlike_double_arrow
"Asha"Asha

Conclusion

This quiz covered traps interviewers love: engines, utf8mb4, upserts, ONLY_FULL_GROUP_BY, no FULL JOIN, JSON operators, isolation, implicit commits and deadlock handling.

Quick Summary: MySQL MCQ on InnoDB, upserts, GROUP BY mode, indexes, JSON, transactions, locks.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators