0
0
SQLquery~5 mins

Deadlock concept and prevention in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a deadlock in a database system?
A deadlock happens when two or more transactions wait forever for each other to release locks, so none can proceed.
Click to reveal answer
beginner
Name one common cause of deadlocks.
Deadlocks often occur when transactions lock resources in different orders, causing a cycle of waiting.
Click to reveal answer
intermediate
How can deadlocks be prevented by ordering resource access?
By always locking resources in the same order, transactions avoid circular waiting and prevent deadlocks.
Click to reveal answer
intermediate
What is the role of a deadlock detection algorithm?
It finds deadlocks when they happen and helps the system choose a transaction to roll back to break the deadlock.
Click to reveal answer
intermediate
Explain how setting a lock timeout helps prevent deadlocks.
If a transaction waits too long for a lock, it times out and rolls back, preventing indefinite waiting and deadlocks.
Click to reveal answer
What causes a deadlock in a database?
AA transaction committing changes
BA transaction reading data without locks
CTwo transactions waiting on each other's locked resources
DA database backup running
Which method helps prevent deadlocks?
ALocking resources in random order
BRunning multiple transactions simultaneously without locks
CIgnoring locks
DLocking resources in a consistent order
What does a deadlock detection algorithm do?
ADetects deadlocks and rolls back one transaction
BAutomatically commits all transactions
CPrevents all locks from being acquired
DDeletes database tables
How does a lock timeout help with deadlocks?
AIt lets transactions wait forever
BIt rolls back transactions that wait too long for locks
CIt disables locking
DIt speeds up transactions
Which of these is NOT a deadlock prevention technique?
AIgnoring transaction isolation
BUsing lock timeouts
COrdering resource locks consistently
DDetecting and rolling back deadlocks
Describe what a deadlock is and why it happens in databases.
Think about two people blocking each other's way.
You got /3 concepts.
    Explain three ways to prevent or handle deadlocks in a database system.
    Consider how to avoid waiting cycles or how to break them.
    You got /3 concepts.