How [Oracle] observes the conflicts between various lock types in table
Example:
SESSION#15 Create a table:
SID 15
==============
CREATE TABLE T1 (C1 number)
Partition by range (C1)
(partition P1 values less than (' 11 '),
Partition P2 values less than (' 21 '),
Partition P3 values less than (' 31 ')
)
/
SESSION#15 the maximum lock on the table (exclusive)
Lock table T1 in exclusive mode; (T1 X (6) lock)
SESSION#137 other operations (ALTER TABLE ADD partition)
SID 137
==============
ALTER TABLE T1 ADD partition P4 values less than (' 41 '); (T1 S (4) lock, T1 X (60 cannot be shared, so blocked, will stay there)
To view the status of a lock
Sys> select * from V$locked_object;
Xidusn xidslot xidsqn object_id session_id oracle_username os_user_name PROCESS Locked_mode
---------- ---------- ---------- ---------- ---------- ------------------------------ ------------------------------ - ----------------------- -----------
0 0 0 87656 JIMMY ora11204 698 6
3 1056 87656 137 JIMMY ora11204 854 0
3 1056 137 JIMMY ora11204 854 3
At this point we can do other operations, anyway, everyone is blocked by the largest level of Exclusive lock, this time we can look at the lock they performed Locked_mode,
See if the lock types of the various operations are compatible.
sid#141
==============
INSERT into T1 values (28);
Sys> select * from V$locked_object;
Xidusn xidslot xidsqn object_id session_id oracle_username os_user_name PROCESS Locked_mode
---------- ---------- ---------- ---------- ---------- ------------------------------ ------------------------------ - ----------------------- -----------
6 1234 87659 141 JIMMY ora11204 927 3
6 1234 87656 141 JIMMY ora11204 927 3
...
How [Oracle] observes the conflicts between various lock types in table