AskTom筆記(2)

husthxd發表於2005-04-04

last updated 2005-04-04

key word : forall/delete/update


1.

1)forall一次只能執行一個單一的語句,如果有多個insert/delete,必須使用多個forall
2)limit子句使用示例
//other statement
fetch c BULK COLLECT INTO data LIMIT 100;-- 每次100行
  begin
    FORALL i IN 1 .. data.count SAVE EXCEPTIONS
      insert into t2 values data(i);
//other statement

2.
如何刪除大表中的大批次的資料
1)
create table new_table unrecoverable as select * from old_table where ....;
drop table old_table;
rename new_table to old_table;
create index old_table_idx1 on old_table(c1,c2) unrecoverable parallel 5;
.....
沒有日誌產生,只是把資料移動到新表上,drop/rename old/new,而且儘可能快的建立索引
2)
分割槽表.並行刪除資料.每個分割槽會使用自身的回滾段,會以並行的方式執行.
3)
分割槽表以便使用DROP分割槽而不是使用DELETE刪除資料.

3.
如何更新大表中的大批次資料
CREATE TABLE new_table as select from old_table;
index new_table
grant on new table
add constraints on new_table
etc on new_table
drop table old_table
rename new_table to old_table;

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