oracle 快速刪除和快速插入的方法之一

lishiran發表於2007-11-04
快速插入[@more@]

oracle 快速刪除和快速插入的方法之一oracle 快速刪除和快速插入的方法之一SQL> insert /*+append*/ into t select * from dba_objects nologging;
oracle 快速刪除和快速插入的方法之一
oracle 快速刪除和快速插入的方法之一
9157 rows created.
oracle 快速刪除和快速插入的方法之一
oracle 快速刪除和快速插入的方法之一
oracle 快速刪除和快速插入的方法之一SQL
> select a.xidusn,a.xidslot,a.used_ublk,a.used_urec,b.username
oracle 快速刪除和快速插入的方法之一
2 from v$transaction a,v$session b,v$mystat c
oracle 快速刪除和快速插入的方法之一
3 where a.addr = b.taddr and c.statistic# = 1
oracle 快速刪除和快速插入的方法之一
4 /
oracle 快速刪除和快速插入的方法之一
oracle 快速刪除和快速插入的方法之一 XIDUSN XIDSLOT USED_UBLK USED_UREC USERNAME
oracle 快速刪除和快速插入的方法之一
---------- ---------- ---------- ---------- ------------------------------
oracle 快速刪除和快速插入的方法之一
2 21 1 1 CUST
oracle 快速刪除和快速插入的方法之一
oracle 快速刪除和快速插入的方法之一SQL
> commit;
oracle 快速刪除和快速插入的方法之一
oracle 快速刪除和快速插入的方法之一
Commit complete.
oracle 快速刪除和快速插入的方法之一
oracle 快速刪除和快速插入的方法之一SQL
> insert into t select * from dba_objects;
oracle 快速刪除和快速插入的方法之一
oracle 快速刪除和快速插入的方法之一
9157 rows created.
oracle 快速刪除和快速插入的方法之一
oracle 快速刪除和快速插入的方法之一SQL
> select a.xidusn,a.xidslot,a.used_ublk,a.used_urec,b.username
oracle 快速刪除和快速插入的方法之一
2 from v$transaction a,v$session b,v$mystat c
oracle 快速刪除和快速插入的方法之一
3 where a.addr = b.taddr and c.statistic# = 1
oracle 快速刪除和快速插入的方法之一
4 /
oracle 快速刪除和快速插入的方法之一
oracle 快速刪除和快速插入的方法之一 XIDUSN XIDSLOT USED_UBLK USED_UREC USERNAME
oracle 快速刪除和快速插入的方法之一
---------- ---------- ---------- ---------- ------------------------------
oracle 快速刪除和快速插入的方法之一
1 1 13 423 CUST
oracle 快速刪除和快速插入的方法之一
oracle 快速刪除和快速插入的方法之一

快速刪除

建個儲存過程,達到2000條或者更多條,提交一次.

oracle 快速刪除和快速插入的方法之一create or replace procedure p_delete
oracle 快速刪除和快速插入的方法之一
as
oracle 快速刪除和快速插入的方法之一n
number(10);
oracle 快速刪除和快速插入的方法之一
cursor my_cur is select * from t1;
oracle 快速刪除和快速插入的方法之一
begin
oracle 快速刪除和快速插入的方法之一n:
=0;
oracle 快速刪除和快速插入的方法之一
for i in my_cur loop
oracle 快速刪除和快速插入的方法之一
delete from t1 where <條件>;
oracle 快速刪除和快速插入的方法之一n:
=n+1;
oracle 快速刪除和快速插入的方法之一
if (mod(n,2000))=0 then
oracle 快速刪除和快速插入的方法之一
commit;
oracle 快速刪除和快速插入的方法之一
end if;
oracle 快速刪除和快速插入的方法之一
end loop;
oracle 快速刪除和快速插入的方法之一
end;
oracle 快速刪除和快速插入的方法之一
/

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9099175/viewspace-980794/,如需轉載,請註明出處,否則將追究法律責任。

相關文章