Oracle暫存資料表undo產生解析

來源:互聯網
上載者:User

暫存資料表的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,而暫存資料表相對會更少一些。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.