Home / MySQL Fundamentals: SQL, Joins and Transactions / Interview questions · हिन्दी
MySQL interview questions
17 questions from the MySQL Fundamentals: SQL, Joins and Transactions course, each with the correct answer and an explanation. Try to answer before you open the answer.
Module 1: Getting Started 1. What does `USE shop;` do? Creates a new database Deletes the `shop` database Makes `shop` the active database for following queries Lists every table in the server Show answer Answer: Makes `shop` the active database for following queries
`USE` just switches context — no data is created or removed.
Lesson: Databases vs Tables
Module 3: Basic Queries 2. Why insert multiple rows in a single statement? It's the only way MySQL allows inserts It skips the NOT NULL constraints It encrypts the inserted data It's generally faster than one INSERT per row Show answer Answer: It's generally faster than one INSERT per row
Batching reduces round trips to the server.
Lesson: INSERT
Module 4: Modifying Data 3. What happens if you run `DELETE FROM customers;` with no WHERE? Every row in the table is deleted Nothing, MySQL requires a WHERE clause Only the first row is deleted Only rows created today are deleted Show answer Answer: Every row in the table is deleted
MySQL doesn't require WHERE — omitting it deletes all rows.
Lesson: DELETE
Module 6: Aggregation 4. Which counts only non-NULL values in a column? COUNT(*) COUNT(column_name) SUM(column_name) MAX(column_name) Show answer Answer: COUNT(column_name)
COUNT(column) ignores NULLs in that column; COUNT(*) counts every row.
Lesson: Aggregate Functions
Module 7: Advanced Queries 5. What's the key difference between UNION and UNION ALL? UNION ALL sorts the results They require the same table name UNION removes duplicate rows, UNION ALL keeps them UNION is only for numbers Show answer Answer: UNION removes duplicate rows, UNION ALL keeps them
UNION dedupes (extra work); UNION ALL doesn't, so it's faster.
Lesson: UNION
6. How does a window function differ from GROUP BY? It keeps every row while adding a computed value It deletes duplicate rows It creates a new table It only works on text Show answer Answer: It keeps every row while adding a computed value
Window functions calculate over a window of rows without collapsing them.
Lesson: Window Functions & CTEs (MySQL 8)
Module 9: Performance 7. In EXPLAIN output, what does `type: ALL` usually indicate? The query used an index perfectly The table has no rows The query will always be fast A full table scan happened Show answer Answer: A full table scan happened
ALL means MySQL had to read every row — often fixable with an index.
Lesson: EXPLAIN at a Glance
Module 12: Beyond Basics 8. What's the main benefit of a stored procedure? It saves reusable SQL logic on the server under a callable name It replaces the need for indexes It automatically backs up the database It makes every query use an index Show answer Answer: It saves reusable SQL logic on the server under a callable name
Procedures package logic server-side so apps can just CALL it.
Lesson: Stored Procedures at a Glance
9. Which key uniquely identifies each row? Foreign key Index only Primary key View Show answer Answer: Primary key
A primary key has no duplicates and no NULLs.
Lesson: Backup & Restore
10. Which clause filters groups after aggregation? WHERE LIMIT ORDER BY HAVING Show answer Answer: HAVING
WHERE runs before grouping; HAVING runs after.
Lesson: Backup & Restore
11. Which join keeps all rows from the left table? LEFT JOIN INNER JOIN CROSS JOIN only UNION Show answer Answer: LEFT JOIN
Unmatched right-side columns become NULL.
Lesson: Backup & Restore
12. Which data type is best for money? FLOAT DECIMAL TEXT BOOLEAN Show answer Answer: DECIMAL
DECIMAL stores exact values without rounding errors.
Lesson: Backup & Restore
13. What does ROLLBACK do? Commits changes Creates an index Undoes changes since the transaction started Deletes the table Show answer Answer: Undoes changes since the transaction started
It restores the state before START TRANSACTION.
Lesson: Backup & Restore
14. What does EXPLAIN type: ALL usually signal? A perfect index use An empty table A syntax error A full table scan Show answer Answer: A full table scan
It often means a useful index is missing.
Lesson: Backup & Restore
15. Why avoid using root for an application? It has far more privileges than needed It is slower It cannot connect remotely It lacks SELECT Show answer Answer: It has far more privileges than needed
Least privilege limits the damage of a compromise.
Lesson: Backup & Restore
16. Which tool creates a logical backup of a MySQL database? mysqlcheck only mysqldump ls git Show answer Answer: mysqldump
mysqldump writes schema and data as SQL.
Lesson: Backup & Restore
17. Which practice best prevents SQL injection? Parameterised queries Concatenating strings Using root everywhere Disabling indexes Show answer Answer: Parameterised queries
Parameters keep user input separate from SQL code.
Lesson: Users, Privileges & Security
← Back to the course