MySQL Interview Questions (Basic to Advanced)
Basic MySQL Interview Questions
- What is MySQL?
- What are the different data types in MySQL?
- What is the default storage engine in MySQL?
- What is the difference between CHAR and VARCHAR?
- What is the difference between WHERE and HAVING clause?
- What are joins in MySQL? List types of joins.
- What is the difference between INNER JOIN and LEFT JOIN?
- How do you insert data into a table?
- How do you create a new table with a primary key?
- What are aggregate functions in MySQL? (e.g., COUNT, SUM, AVG)
Intermediate MySQL Interview Questions
- What is a foreign key? How does it enforce referential integrity?
- What is normalization? Explain 1NF, 2NF, and 3NF.
- What are indexes? How do they improve performance?
- What is the difference between DELETE, TRUNCATE, and DROP?
- What is a subquery? How is it different from a JOIN?
- What is the use of GROUP BY?
- What is the difference between UNION and UNION ALL?
- What is a view in MySQL?
- What are stored procedures and functions?
- How do you prevent SQL injection in MySQL?
Advanced MySQL Interview Questions
- What is a transaction? What are the ACID properties?
- How does MySQL handle concurrency and locking?
- What is the difference between optimistic and pessimistic locking?
- What is deadlock? How does MySQL handle it?
- What are isolation levels? List and explain them.
- How do you find slow queries in MySQL?
- What is the query execution plan? (EXPLAIN)
- What is indexing, and when can it slow down performance?
- What are composite indexes? How does column order affect them?
- How to optimize a slow SELECT query?
- Where does MySQL store data physically?
- What are .frm, .ibd, .MYI, .MYD files?
- What is the purpose of ibdata1 and binary log files?
- How to change the MySQL data directory?
- What is MySQL replication?
- Difference between master-slave and master-master replication.
- What is binary logging used for?
- How do you backup a MySQL database?
- How do you restore a .sql dump file?
- What are mysqldump, mysqlbinlog, and xtrabackup?
- Difference between InnoDB and MyISAM engines.
- What is innodb_buffer_pool_size?
- What is innodb_file_per_table?
- What is the difference between clustered and non-clustered index in InnoDB?
- What is the use of information_schema and performance_schema?
Practical Query Challenges
- Write a query to get the second highest salary.
- Find all duplicate rows in a table.
- Get count of orders per customer using GROUP BY.
- Get customers who haven't placed any order.
- Write a query to pivot data using CASE statements.