What is a database lock in the context of SQL?
A database lock is used to “lock” some data in a database so that only one database user/session may update that particular data. So, database locks exist to prevent two or more database users from updating the same exact piece of data at the same exact time. When data is locked, then that means that another database session can NOT update that data until the lock is released (which unlocks the data and allows other database users to update that data. Locks are usually released by either a ROLLBACK or COMMIT SQL statement.
Database level locking
With database level locks, the entire database is locked – which means that only one database session can apply any updates to the database. this lock can be useful when some major support update is necessary – like upgrading the database to a new version.
Table level locking
An entire table is locked as a whole. This lock level comes in handy when making a change that affects an entire table, like updating all the rows in a table, or modifiying the table to add or remove columns.
Row level locking
A row level lock applies to a row in a table.
When data is either deleted or updated locks are always used.
What is the point of database locking?
prevent the potential loss of data that could happen if updates are applied concurrently – or at the same exact time.
Having locks may cause lock contention and deadlock.
Read full article from Database locking
A database lock is used to “lock” some data in a database so that only one database user/session may update that particular data. So, database locks exist to prevent two or more database users from updating the same exact piece of data at the same exact time. When data is locked, then that means that another database session can NOT update that data until the lock is released (which unlocks the data and allows other database users to update that data. Locks are usually released by either a ROLLBACK or COMMIT SQL statement.
Database level locking
With database level locks, the entire database is locked – which means that only one database session can apply any updates to the database. this lock can be useful when some major support update is necessary – like upgrading the database to a new version.
Table level locking
An entire table is locked as a whole. This lock level comes in handy when making a change that affects an entire table, like updating all the rows in a table, or modifiying the table to add or remove columns.
Row level locking
A row level lock applies to a row in a table.
When data is either deleted or updated locks are always used.
What is the point of database locking?
prevent the potential loss of data that could happen if updates are applied concurrently – or at the same exact time.
Having locks may cause lock contention and deadlock.
Read full article from Database locking
No comments:
Post a Comment