临时表 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