ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 对索引列做修改时会不会锁定索引

对索引列做修改时会不会锁定索引

原创 Linux操作系统 作者:meshada 时间:2009-07-21 16:45:45 0 删除 编辑
有人问,对索引列做修改时会不会锁定索引,呃,事实胜于雄辩,用事实说话。

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';
COUNT(*) ---------- 1


对索引列的改动和对非索引列的修改所产生的锁定数是一致的,所以说对索引列做修改时不会锁定索引。其实这个例子用非主键索引,并做update而不是delete更好,但是效果是一样的。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/13515865/viewspace-609828/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2009-02-27

  • 博文量
    2
  • 访问量
    7893