码迷,mamicode.com
首页 > 其他好文 > 详细

delete未提交rollback是否会改变行号

时间:2016-06-24 15:29:19      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:

今天做个试验,delete未提交rollback是否会改变行号?

创建测试表:
create table dxmy (id number,name varchar2(100));

插入数据
insert into dxmy values(1,'dxmy');
insert into dxmy values(2,'dxmy');
insert into dxmy values(3,'dxmy');
insert into dxmy values(4,'dxmy');
commit;

查看行号
SQL> select dbms_rowid.rowid_relative_fno(rowid) fno,
  2         dbms_rowid.rowid_block_number(rowid) block_id,
  3         dbms_rowid.rowid_row_number(rowid) row_id,
  4         id
  5    from dxmy;
 
       FNO   BLOCK_ID     ROW_ID         ID
---------- ---------- ---------- ----------
         4        462          0          1
         4        462          1          2
         4        462          2          3
         4        462          3          4 


delete,但是不提交:
SQL> delete dxmy where id = 1;
 
1 row deleted
 
SQL> 
SQL> select dbms_rowid.rowid_relative_fno(rowid) fno,
  2         dbms_rowid.rowid_block_number(rowid) block_id,
  3         dbms_rowid.rowid_row_number(rowid) row_id,
  4         id
  5    from dxmy;
 
       FNO   BLOCK_ID     ROW_ID         ID
---------- ---------- ---------- ----------
         4        462          1          2
         4        462          2          3
         4        462          3          4

rollback:
SQL> rollback;
 
Rollback complete

SQL> select dbms_rowid.rowid_relative_fno(rowid) fno,
  2         dbms_rowid.rowid_block_number(rowid) block_id,
  3         dbms_rowid.rowid_row_number(rowid) row_id,
  4         id
  5    from dxmy;
 
       FNO   BLOCK_ID     ROW_ID         ID
---------- ---------- ---------- ----------
         4        462          0          1
         4        462          1          2
         4        462          2          3
         4        462          3          4

行号未改变。

那如果delete之后,我提交了,然后重新插入呢?
SQL> delete dxmy where id = 1;
 
1 row deleted
 
SQL> commit;
 
Commit complete
SQL> insert into dxmy values(1,'dxmy');
 
1 row inserted
 
SQL> commit;
 
Commit complete

SQL> select dbms_rowid.rowid_relative_fno(rowid) fno,
  2         dbms_rowid.rowid_block_number(rowid) block_id,
  3         dbms_rowid.rowid_row_number(rowid) row_id,
  4         id
  5    from dxmy;
 
       FNO   BLOCK_ID     ROW_ID         ID
---------- ---------- ---------- ----------
         4        462          1          2
         4        462          2          3
         4        462          3          4
         4        463          0          1

<pre name="code" class="html">SQL> delete dxmy where id = 1;
 
1 row deleted
 
SQL> commit;
 
Commit complete

SQL> insert into dxmy values(1,‘dxmy2‘);
 
1 row inserted
 
SQL> commit;
 
Commit complete
 
SQL>
SQL> select dbms_rowid.rowid_relative_fno(rowid) fno,
  2         dbms_rowid.rowid_block_number(rowid) block_id,
  3         dbms_rowid.rowid_row_number(rowid) row_id,
  4         id
  5    from dxmy;
 
       FNO   BLOCK_ID     ROW_ID         ID
---------- ---------- ---------- ----------
         4        462          1          2
         4        462          2          3
         4        462          3          4
         4        463          1          1

然后就发现:
1.delete未提交即rollback不会改变行号
2.delete提交后插入数据,可能会改变行号,但是也有可能不改变,但行的位置肯定会改变。




delete未提交rollback是否会改变行号

标签:

原文地址:http://blog.csdn.net/ghostliming/article/details/51736392

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!