Oracle的表级锁

来源:互联网 发布:火狐浏览器优化版 编辑:程序博客网 时间:2024/06/05 19:29
Lock mode in which the session holds the lock,Oracle的表级锁有如下级别(行级锁就他妈一个:行级排他锁):     0级 - none        1级 - null (NULL)        2级 - row-S (SS/RS),行共享          锁定语句:lock table test in row share mode;          ROW SHARE permits concurrent access to the locked table but prohibits users from locking the entire table for exclusive access.           ROW SHARE is synonymous with SHARE UPDATE, which is included for compatibility with earlier versions of Oracle Database.          ROW SHARE允许并发地访问被锁定的表,但是禁止用户锁定整个表以进行排他访问。          他是SHARE UPDATE的同义词,SHARE UPDATE是同早期数据库的一个兼容。        3级 - row-X (SX/RX),行排他          锁定语句:lock table test in row exclusive mode;          ROW EXCLUSIVE is the same as ROW SHARE, but it also prohibits locking in SHARE mode.           ROW EXCLUSIVE locks are automatically obtained when updating, inserting, or deleting.          ROW EXCLUSIVE同ROW SHARE一样,但是ROW EXCLUSIVE也禁止其他SHARE锁定。          ROW EXCLUSIVE锁在更新,插入以及删除时自动被获取。        4级 - share (S),共享          锁定语句:lock table test in share mode;           SHARE permits concurrent queries but prohibits updates to the locked table.          SHARE允许并发地查询,但禁止其他去更新被锁定的表。                    对表建立索引的时候,就要加4级锁。这个锁会阻止dml,所以大表加索引,必须要指定为online,可以避免对表加4级锁。              5级 - S/Row-X (SSX/SRX),共享行排他          锁定语句:lock table test in share row exclusive mode;          SHARE ROW EXCLUSIVE is used to look at a whole table and to allow others to look at rows in the table but to prohibit           others from locking the table in SHARE mode or from updating rows.          SHARE ROW EXCLUSIVE用来锁住整个表,当然其他会话可以查询表中的行。但是禁止其他以SHARE模式锁住表而更新表里的行。    6级 - exclusive (X),排他          锁定语句:lock table test in exclusive mode;          EXCLUSIVE permits queries on the locked table but prohibits any other activity on it.          EXCLUSIVE允许其他查询,但是禁止任何其他的操作。
0 0
原创粉丝点击