您在这里:首页 > 学员专区 > 技术文章
Oracle视频
Oracle
CUUG课程

临时表的undo生成


临时表的redo生成要比普通表少的多,但是undo的产生并不比普通表少。

 

 

通过一个简单的例子说明:

SQL> create global temporary table t_temp

  2  (id number, name varchar2(30))

  3  on commit preserve rows;

表已创建。

SQL> create table t_normal

  2  (id number, name varchar2(30));

表已创建。

SQL> select sid

  2  from v$mystat

  3  where rownum = 1;

       SID

----------

       133

SQL> select value

  2  from v$statname a, v$sesstat b

  3  where a.statistic# = b.statistic#

  4  and a.name = 'undo change vector size '

  5  and b.sid = 133;

未选定行

SQL> select value

  2  from v$statname a, v$sesstat b

  3  where a.statistic# = b.statistic#

  4  and a.name = 'undo change vector size'

  5  and b.sid = 133;

     VALUE

----------

      3988

SQL> insert into t_normal

  2  select rownum, object_name

  3  from dba_objects;

已创建49081行。

SQL> commit;

提交完成。

SQL> select value

  2  from v$statname a, v$sesstat b

  3  where a.statistic# = b.statistic#

  4  and a.name = 'undo change vector size'

  5  and b.sid = 133;

     VALUE

----------

    135232

SQL> insert into t_temp

  2  select rownum, object_name

  3  from dba_objects;

已创建49081行。

SQL> commit;

提交完成。

SQL> select value

  2  from v$statname a, v$sesstat b

  3  where a.statistic# = b.statistic#

  4  and a.name = 'undo change vector size'

  5  and b.sid = 133;

     VALUE

----------

    254240

SQL> select 254240 - 135232 temp_table, 135232 - 3988 normal_table from dual;

TEMP_TABLE NORMAL_TABLE

---------- ------------

    119008       131244

可以看到,临时表和普通表产生的undo数据没有太多的差别,而实际上临时表的插入产生的redo信息也是undo信息对应的redo。

SQL> insert /*+ append */ into t_temp

  2  select *

  3  from t_temp;

已创建49081行。

SQL> commit;

提交完成。

SQL> select value

  2  from v$statname a, v$sesstat b

  3  where a.statistic# = b.statistic#

  4  and a.name = 'undo change vector size'

  5  and b.sid = 133;

     VALUE

----------

    254408

SQL> insert /*+ append */ into t_normal

  2  select *

  3  from t_normal;

已创建49081行。

SQL> commit;

提交完成。

SQL> select value

  2  from v$statname a, v$sesstat b

  3  where a.statistic# = b.statistic#

  4  and a.name = 'undo change vector size'

  5  and b.sid = 133;

     VALUE

----------

    256468

SQL> select 254408 - 254240 temp_table, 256468 - 254408 normal_table from dual;

TEMP_TABLE NORMAL_TABLE

---------- ------------

       168         2060

对于append方式插入,普通表和临时表都会产生少量的undo,而临时表相对会更少一些。

 


(以上内容摘于网络,如有侵权,请告之,将第一时间删除)

相关文章 [上一篇] 小心TNSNAMES服务名配置陷阱(三)
010-88589926(88587026)
CUUG热门培训课程
Oracle DBA就业培训
CUUG名师
网络课程
技术沙龙
最新动态

总机:(010)-88589926,88589826,88587026 QQ讨论群:243729577 182441349 邮箱:cuug_bj@cuug.com
通信地址:北京市海淀区紫竹院路98号北京化工大学科技园609室(CUUG)邮政编码:100089 
中国UNIX用户协会 Copyright 2010  ALL Rights Reserved 北京神脑资讯技术有限公司
京ICP备11008061号  京公网安备110108006275号