Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Little confusing about Lock mode

MUSICOVERYJun 7 2016 — edited Jun 7 2016

Hi all,

I read a book explaining about lock mode. - shared & exclusive lock.

It says, shared lock can be shared by some compatible sessions(?).

and exlcusive lock is just for one session modifying data so, anyone altering the same row is prevented from Oracle.

But, here is another case.

"TX Lock - row lock contention wait event"

Let's say,"dept" table has a column named, "deptno" for department number, and it has PK constraint.

and "Trasaction 1" inserts one row containing deptno "40".

and the other "Transaction 2" inserts one row containing deptno "40", too.

Since the dept table has PK constraint, transaction 2 will be blocked before transaction 1 is committed or rollbacked to check the PK violation.

In other words, transaction 2 is waiting for row lock contention wait event.

In this book, this case, the wait event is occured in "SHARED" lock mode.

but transaction 2 is blocked. Does shared lock mode can block other sessions?

i thought shared mode is just for sharing some data, not blocking any other sessions.(but shared lock can block exclusive lock.)

i can not undestand shared & exclusive lock mode.

This post has been answered by Jonathan Lewis on Jun 7 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 5 2016
Added on Jun 7 2016
5 comments
1,530 views