Interview Question

What is locking?

Locks coordinate concurrent operations on shared data.

💡 Concept ✅ Quick Revision 🗃️ SQL

Answer

Database locking coordinates concurrent access to database objects or rows. • Locks can protect data while a statement or transaction operates. • Conflicting locks can make another transaction wait. • Lock mode, duration, and granularity depend on the operation and database.

💡 SQL Example

SELECT * FROM accounts WHERE account_id = 1 FOR UPDATE;

Result

The selected row is locked for update

⚡ Quick Revision

Locks coordinate concurrent operations on shared data.