Multiple database transactions can access the same database object at the same time. To synchronize access, SQL locks are used.
The following database objects can be locked:
Tables
Rows
Entries in the database catalog
Lock Type |
Objects that Can Be Locked |
Description |
---|---|---|
Exclusive |
|
The system sets exclusive locks for all SQL statements that change data, such as INSERT, UPDATE, or DELETE. Other transactions have neither read nor write access to the locked database object. This means that other users cannot access the locked database object. If another transaction also tries to set an exclusive lock, a lock collision occurs (the lock request is rejected). Caution
Exclusive locks can significantly interfere with the performance of the database and the SAP system. |
Share |
|
Other transactions have read access to the locked database object. They can still set share locks for the database object. However, other transactions cannot set exclusive locks for the database object and therefore cannot change it. |
Optimistic |
|
An optimistic lock keeps track of changes to a database object. This enables database applications to determine whether the data that they have read while setting the lock is still up-to-date, or whether they must read it again. Other transactions can still set share, exclusive, or optimistic locks for the locked database object. Before a transaction can change a row for which it has set an optimistic lock, the system checks whether the row has been changed by another user since the optimistic lock was set.
An optimistic lock is only useful in isolation levels 0, 1, 10, and 15. |
Concepts of the Database System, SQL Locks
Database Administration, Analyzing Database Performance
Database Studio, Displaying SQL Locks and Displaying Information About Database Activities
Database Administration in CCMS, Locks
SQL Reference Manual, Transactions
SAP Note 1243937 (FAQ: MaxDB SQL Locks)