Complete the code to check the current deadlocks in MySQL.
SHOW [1];The command SHOW ENGINE INNODB STATUS; displays detailed information including deadlock detection in InnoDB engine.
Complete the code to enable the InnoDB deadlock monitor in MySQL.
SET GLOBAL innodb_deadlock_detect = [1];Setting innodb_deadlock_detect to 1 enables deadlock detection in InnoDB.
Fix the error in the query to detect deadlocks from the InnoDB status output.
SHOW ENGINE INNODB [1];The correct syntax is SHOW ENGINE INNODB STATUS; with STATUS spelled correctly.
Fill both blanks to write a query that shows the last deadlock information and resets the deadlock count.
SHOW ENGINE INNODB [1]; SET GLOBAL innodb_deadlock_detect = [2];
The first command shows the InnoDB status including deadlocks. The second disables deadlock detection by setting it to 0.
Fill all three blanks to write a transaction that prevents deadlocks by locking rows in a consistent order.
START TRANSACTION; SELECT * FROM orders WHERE order_id = [1] FOR [2]; UPDATE orders SET status = 'processed' WHERE order_id = [3]; COMMIT;
The SELECT locks the row with order_id 1001 using FOR UPDATE to prevent deadlocks by locking rows in a consistent order before updating.