oracle快速向表中插入記錄方法

taogchan發表於2012-04-13

1.使用marge快速插入;

MERGE /*+ append */
INTO A d
USING (select * B where ...) f
ON (d.account_no = f.account_no)
WHEN MATCHED THEN
update set acc_date = f.acc_date,...
WHEN NOT MATCHED THEN
insert values ( f.account_no,f.acc_date..)
/
commit;


2.向表中插入兩條記錄

SQL> INSERT ALL
2 INTO toms values(1)
3 into toms values(2)
4 select * from dual;

已建立2行。

SQL> commit;


3.在插入時不記錄日誌記錄的快速方法
INSERT的時候可透過APPEND選項不產生歸檔日誌。

alter table aa nologging

alter table aa logging

insert /*+append*/ into ...nologing
select * from ...

insert /*+ append, parallel */ into ods_list_t nologging
select * from ods_list;

但這樣不行:整個表可以插入,但要某一個欄位則不能加入nologging
insert /*+ append, parallel */ into ods_list_t(a,b) nologging
select a,b from ods_list;

但可以這樣:
insert /*+ append, parallel */ into ods_list_t nologging(a,b)
select a,b from ods_list;

create table ods_list_t nologging as select * from ods_list;

insert /*+ append, parallel */ into ods_list_t nologging 
select * from ods_list;


insert /*+ Append parallel(tablename,number) */ into ods_list_t nologging 
select * from ods_list;

tablename: 表名
number: 並行度

4、
使用批次複製方法
set arraysize 20
set copycommit 5000
copy from  append table_name1 
using select * from table_name2;

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

相關文章