Entering content frame

 Type of Lock 

The database system differentiates between the following locks:

·        Shared lock

·        Exclusive lock

·        Optimistic lock

·        Special locks for the metadata of the database catalog. These must, however, always be explicitly assigned.

The following table provides an overview of the possible parallel shared locks (S locks) and exclusive locks (E locks).

 

A transaction has the following type of lock

 

on a table

on a row

on the database catalog

Can another transaction

E lock

S lock

E lock

S lock

E lock

S lock

request an E lock for the table?

No

No

No

No

No

Yes

request an S lock for the table?

No

Yes

No

Yes

No

Yes

request an E lock for any row in the table?

No

No

-

-

No

Yes

request an E lock for the locked row?

-

-

No

No

-

-

request an E lock for another row?

-

-

Yes

Yes

-

-

request an S lock for any row in the table?

No

Yes

-

-

No

Yes

request an S lock for the locked row?

-

-

No

Yes

-

-

request an S lock for another row?

-

-

Yes

Yes

-

-

change the definition of the table in the database catalog?

No

No

No

No

No

No

read the definition of the table in the database catalog?

Yes

Yes

Yes

Yes

No

Yes

A lock collision exists in the cases that are marked with No; that is, after having requested a lock within a transaction, the user must wait for the lock to be released until one of the above situations or one of the situations that are marked with Yes in the matrix occurs.

The following also applies:

·        If no lock has been assigned to a transaction for a data object, then a shared or exclusive lock can be requested within any transaction and the lock is immediately assigned to the transaction.

·        If a shared lock has been assigned to a transaction T1 for a data object, and if no lock has been assigned to any concurrent transaction for this data object, then the transaction T1 can request an exclusive lock for this data object and the lock is immediately assigned to this transaction.

·        If an exclusive lock has been assigned to a transaction for a data object, then a shared can, but need not, be requested for this transaction.

 

Leaving content frame