臨時表 on commit delete rows 與 on commit preserve rows 的區別


-- 事務級臨時表:提交時刪除數據
create global temporary  table tmp_table1
(
       x     number
) on commit delete rows ;
 
-- 會話級臨時表:會話結束時刪除數據
create global temporary table tmp_table2
(
       x     number
) on commit preserve rows ;
 
insert into tmp_table1
values(1);
insert into tmp_table1
values(2);
insert into tmp_table1
values(3);
 
 
insert into tmp_table2
values(1);
insert into tmp_table2
values(2);
insert into tmp_table2
values(3);
 
select * from   tmp_table1 ;
X
1
2
3
 
 
select * from   tmp_table2 ;
X
1
2
3
 
commit;
 
select * from   tmp_table1 ;
-- 無結果輸出
select * from   tmp_table2 ;
X
1
2
3
 
SQL> conn / as sysdba;
SQL> select * from   user01.tmp_table1 ;
-- 無結果輸出 
SQL> select * from   user01.tmp_table2 ;
-- 無結果輸出


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM