Oracle 10g中 system 復原段的作用

來源:互聯網
上載者:User

在Oracle10g中依然存在一個復原段,名叫system,它是有Oracle在建立資料庫的時候建立的,並且這個復原段存在於SYSTEM資料表空間中。它存在的目的就是為了復原系統事物,也就是說資料字典修改之後的鏡像就存在於system復原段。

SQL> select segment_name,owner,tablespace_name,segment_id,file_id from dba_rollback_segs where segment_id=0;

 

SEGMENT_NAME    OWNER  TABLESPACE_NAME SEGMENT_ID    FILE_ID

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

SYSTEM          SYS    SYSTEM                   0          1

我們查詢dba_rollback_segs這個視圖就可以得到系統中復原段/撤銷段資訊

為了探究system復原段的作用,我做如下實驗:

首先在一個session中建立一個測試表,然後運行一個過程,批量插入1百萬條資料

SQL> create table test(data varchar2(100));

 

表已建立。

 

SQL> begin

  2    for v_loop in 1 ..1000000 loop

  3        insert into test values('test!');

  4        commit;

  5    end loop;

  6  end;

  7  /

 

PL/SQL 過程已成功完成。

 

同時在另外一個session中運行下面的指令碼

 

SQL> declare

  2    v_cnt int :=0;

  3  begin

  4    for v_loop in 1 ..1000000 loop

  5        select count(*) into v_cnt from v$transaction where xidusn=0;---xidusn表示rollback segment_id

  6        if v_cnt>0 then

  7           dbms_output.put_line('Find it');

  8        end if;

  9    end loop;

 10  end;

 11  /

Find it

Find it

Find it

Find it

....省略之...................

由此實驗得出system復原段依然會被系統利用,同時得出v$transaction視圖也記錄後台進程的事物

system復原段是用了記錄Oracle內部操作的,也就是資料字典更改。

看見某本書上面寫system復原段在Oracle建立之後,就永遠不會被使用,恩其實是錯誤的.

相關文章

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.