Last Updated: 28 Jun 2023
|
MySQL Interview Questions
- Explain the basic CRUD operations (CREATE, UPDATE, DELETE) and how you'd use SQL to perform them.
- Explain the
WHERE
clause on aSELECT
statement, what it does and how it works. - Explain
GROUP BY
. What does it do, and when do you have to use it? - What is a view? Why would you want to use one?
- What is a trigger? Why are triggers good and bad?
- What's an index? Advanced: What are the different types of indexes?
- What's a foreign key? What does the
ON CASCADE
clause do when creating a foreign key? - Explain what a transaction is, when you'd want to use one, and when you probably wouldn't want to use one.
- Explain the MySQL architecture (e.g. the three layers… networking/connection layer, query parsing, and the storage engine)
- Explain the differences between InnoDB and MyISAM. When would you want to use each?
- Talk to me about the process you'd use for optimizing an SQL query.
- What's the difference between
CHAR
,VARCHAR
,TEXT
andBLOB
datatypes? - Is there anything special about
NULL
values in MySQL (or SQL in general?) How do you test for aNULL
value? - What's the difference between a
TIMESTAMP
field and aDATETIME
field? Advanced question: can you describe the different handling of timezones betweenTIMESTAMP
andDATETIME
? - Explain locking principles in MySQL. Table level locks, page-level locks, and row-level locks. Which storage engines can do which? Explain what shared vs. exclusive locks are.
- Why does
DELETE FROM `mytable`
run very quickly, whereasDELETE FROM `mytable` WHERE 1=1
run very slowly, if 'mytable' has a large number of records? (e.g. the former just deletes and recreates the table on disk, whereas the latter will delete each row one-by-one.)
PHP/MySQL Questions
- Explain the difference between the standard MySQL libraries (e.g. mysql_connect() ) and the MySQLi libraries (e.g. mysqli_connect() )
- Walk me through the basic process for connecting to a MySQL database and querying some information.
Discussion