暫存資料表的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
本欄目更多精彩內容:http://www.bianceng.cn/database/Oracle/
可以看到,暫存資料表和普通表產生的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,而暫存資料表相對會更少一些。