有人问,对索引列做修改时会不会锁定索引,呃,事实胜于雄辩,用事实说话。
SQL> create table t1(id number primary key, name varchar2(10));
Table created
SQL> select sid from v$session t where t.USERNAME='TEST';
SID
----------
121
SQL> select count(*) from v$lock t where t.SID='121';
COUNT(*)
----------
1
SQL> insert into t1 select 1, '1' from dual;
1 row inserted
SQL> select count(*) from v$lock t where t.SID='121';
COUNT(*)
----------
3
SQL> commit;
Commit complete
SQL> select count(*) from v$lock t where t.SID='121';
COUNT(*)
----------
1
SQL> update t1 set name='11' where id=1;
1 row updated
SQL> select count(*) from v$lock t where t.SID='121';
COUNT(*)
----------
3
SQL> commit;
Commit complete
SQL> select count(*) from v$lock t where t.SID='121';
对索引列的改动和对非索引列的修改所产生的锁定数是一致的,所以说对索引列做修改时不会锁定索引。其实这个例子用非主键索引,并做update而不是delete更好,但是效果是一样的。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/13515865/viewspace-609828/
,如需转载,请注明出处,否则将追究法律责任。