Complete the code to detect a deadlock in a database system.
SELECT * FROM [1] WHERE waiting = TRUE;The deadlock_detection table or view is typically used to find transactions waiting due to deadlocks.
Complete the code to resolve a deadlock by aborting a transaction.
KILL [1];To resolve a deadlock, the database aborts a session_id involved in the deadlock.
Fix the error in the SQL statement to detect deadlocks.
SELECT * FROM deadlock_detection WHERE [1] = TRUE;The waiting column indicates if a transaction is waiting due to a deadlock.
Fill both blanks to create a query that lists transactions involved in deadlocks and their wait times.
SELECT transaction_id, [1] FROM deadlock_detection WHERE [2] = TRUE;
The wait_time shows how long a transaction has waited, and waiting indicates if it is currently waiting due to deadlock.
Fill all three blanks to write a query that identifies deadlocked transactions, their blocking transaction, and the resource involved.
SELECT [1], [2], [3] FROM deadlock_detection WHERE waiting = TRUE;
This query selects the transaction_id waiting, the blocking_transaction_id causing the wait, and the resource_id involved in the deadlock.