全局临时表

从数据安全的角度来讲,对表记录操作写日志是不可避免的。否则备份回复就无从谈起了。

但是在现实中,有一些操作不需要重新恢复。比如临时处理的中间结果集,这时我们就可以考虑用全局临时表来实现。

 

全局临时表的两种类型

一 基于回话的全局临时表

二 基于事务的全局临时表

 

drop table aa

drop table bb

create  global temporary  table aa on commit  preserve rows  as select * from dba_objects where 1=2;

--基于回话的全局临时表 (事务提交的时候仍然保留记录 on commit preserve rows)

在回话断开之后,或执行delete或者truncate时,就会删除临时表空间的内容。

create global temporary table bb on commit delete rows as select * from dba_objects where 1=2;

--基于事务的全局临时表   (事务提交的时候删除这些记录 on commit delete rows)

当事务已提交,就会删除临时表空间的数据,收回undo

断开会话后也会清空临时表

 

 

全局临时表的两大特性

一高效的删除记录

二不同会话数据独立,不同的session访问全局临时表看到的结果不同

 

 

经试验证明在全局临时表中做dml操作不是不会产生日志,而是比较普通表,它产生的日志非常少。

posted on 2014-06-04 17:15  todayiwillgo  阅读(246)  评论(0)    收藏  举报

导航