Suggest an editImprove this articleRefine the answer for “What is a lock in SQL?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)A **lock** in SQL is a mechanism that **restricts other transactions' access to data**, to preserve integrity and avoid conflicts during concurrent operations: when one transaction reads or changes a row, table, or memory page, the database can **lock** that object, preventing other transactions from changing it until the current one finishes. **Key point:** the main types are a **shared lock** (allows reads, blocks changes) and an **exclusive lock** (fully blocks access); this prevents race conditions and data corruption.Shown above the full answer for quick recall.Answer (EN)ImageA **lock** in SQL is a mechanism that **restricts other transactions' access to data**, to preserve integrity and avoid conflicts during concurrent operations. When one transaction reads or changes a row, table, or memory page, the database can **lock** that object, preventing other transactions from changing it until the current one finishes. ### The main lock types - A **shared lock** allows other transactions to read the data, but not change it. - An **exclusive lock** fully blocks access: no one can read or change it until the lock is released. Example: if one transaction is updating a user's balance, a second one can't change the same data until the first finishes (`COMMIT` or `ROLLBACK`). This prevents **race conditions** and **data corruption**.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.