Entering content frame

Background documentation Parallelism of Locks Locate the document in its SAP Library structure

The following table shows which shared locks (SHARE LOCKS) and exclusive locks (EXCLUSIVE LOCKS) can exist in parallel.

 

A transaction has..

 

For a table

For a row

For the database catalog

Another transaction can...

Exclusive lock

Shared lock

Exclusive lock

Shared lock

Exclusive lock

Shared lock

Request an exclusive lock for the table

no

no

no

no

no

yes

Request a shared lock for the table

no

yes

no

yes

no

yes

Request an exclusive lock for any row in the table

no

no

-

-

no

yes

Request an exclusive lock for the locked row

-

-

no

no

-

-

Request an exclusive lock for a different row

-

-

yes

yes

-

-

Request a shared lock for any row in the table

no

yes

-

-

no

yes

Request a shared lock for the locked row

-

-

no

yes

-

-

Request a shared lock for a different 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

There is a lock collision in the cases that are marked “no”. If a lock is requested within a transaction, then you have to wait for the lock to be released until one of the situations marked in the matrix with “yes” occurs.

The following also applies:

·        If no lock is set for a database object, then a transaction can request a shared or an exclusive lock and the lock is set immediately.

·        If transaction T1 holds a shared lock for a database object and no other transaction holds a lock for this database object, then transaction T1 can request an exclusive lock for this database object and receives it immediately.

·        If a transaction holds an exclusive lock for a database object, then this transaction can request a shared lock (although this is not necessary).

See also:

Locks

 

Leaving content frame