oracle中通過update _NEXT_OBJECT 實現obj$.obj#和obj$.dataobj#跳號

來源:互聯網
上載者:User

在一些特殊的情況下(比如ORA-00600 [15267],ORA-00600 [KKDLCOB-OBJN-EXISTS],Ora-600 [15260]),考慮需要把dba_objects中的object_id往前推進,這裡通過實驗的方法實現該功能
資料庫版本資訊
SQL> select * from v$version;
 
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
PL/SQL Release 10.2.0.4.0 - Production
CORE    10.2.0.4.0      Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
分析obj和dataobj
SQL> select max(obj#),max(dataobj#) from obj$;
 
 MAX(OBJ#) MAX(DATAOBJ#)
---------- -------------
     51887         51907
 
SQL> select name from obj$ where obj#=51887;
 
NAME
------------------------------
T_DUL
 
SQL> select name from obj$ where dataobj#=51907;
 
NAME
------------------------------
_NEXT_OBJECT
 
SQL> select object_id,data_object_id from dba_objects where object_name='_NEXT_OBJECT';
 
no rows selected
為什麼dba_objects中無_NEXT_OBJECT
因為dba_objects視圖中跳過了_NEXT_OBJECT這條記錄
_next_object


測試建立新表後obj和dataobj的變化
SQL>  create table t_xff as select * from dual;
 
Table created.
 
SQL> select max(obj#),max(dataobj#) from obj$;
 
 MAX(OBJ#) MAX(DATAOBJ#)
---------- -------------
     51898         51907
 
SQL> select name from obj$ where obj#=51898;
 
NAME
------------------------------
T_XFF
 
SQL> select max(object_id),max(data_object_id) from dba_objects where object_name='T_XFF';
 
MAX(OBJECT_ID) MAX(DATA_OBJECT_ID)
-------------- -------------------
         51898               51898
通過測試可以確定,obj發生增加,但是dataobj不一定增加(因為dataobj本身比obj大,如果出現obj>dataobj那屬於異常情況)

測試資料庫重啟obj和dataobj是否會跳號
---正常重啟資料庫
SQL> SHUTDOWN IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP
ORACLE instance started.
 
Total System Global Area  260046848 bytes
Fixed Size                  1266920 bytes
Variable Size              83888920 bytes
Database Buffers          171966464 bytes
Redo Buffers                2924544 bytes
Database mounted.
Database opened.
SQL> select max(obj#),max(dataobj#) from obj$;
 
 MAX(OBJ#) MAX(DATAOBJ#)
---------- -------------
     51898         51907
 
---強制重啟資料庫
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
 
Total System Global Area  260046848 bytes
Fixed Size                  1266920 bytes
Variable Size              83888920 bytes
Database Buffers          171966464 bytes
Redo Buffers                2924544 bytes
Database mounted.
Database opened.
SQL> select max(obj#),max(dataobj#) from obj$;
 
 MAX(OBJ#) MAX(DATAOBJ#)
---------- -------------
     51898         51907
通過這個證明obj和dataobj沒有因為資料庫重啟而發生改變

實現obj跳號
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup restrict
ORACLE instance started.
 
Total System Global Area  260046848 bytes
Fixed Size                  1266920 bytes
Variable Size              83888920 bytes
Database Buffers          171966464 bytes
Redo Buffers                2924544 bytes
Database mounted.
Database opened.
SQL>  update obj$ set dataobj#=1000000 where name='_NEXT_OBJECT'; 
 
1 row updated.
 
SQL> commit;
 
Commit complete.
 
SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
 
Total System Global Area  260046848 bytes
Fixed Size                  1266920 bytes
Variable Size              83888920 bytes
Database Buffers          171966464 bytes
Redo Buffers                2924544 bytes
Database mounted.
Database opened.
 
SQL> select max(obj#),max(dataobj#) from obj$;
 
 MAX(OBJ#) MAX(DATAOBJ#)
---------- -------------
     51898       1000000
 
SQL> create table t_www_xifenfei_com as select * from dual;
 
Table created.
 
SQL> select max(obj#),max(dataobj#) from obj$;
 
 MAX(OBJ#) MAX(DATAOBJ#)
---------- -------------
   1000000       1000010
 
SQL> select max(object_id),max(data_object_id) from dba_objects;
 
MAX(OBJECT_ID) MAX(DATA_OBJECT_ID)
-------------- -------------------
       1000000             1000000
 
SQL> select object_name from dba_objects where object_id=1000000;
 
OBJECT_NAME
----------------------------------------------------------------
T_WWW_XIFENFEI_COM
通過丟_NEXT_OBJECT的更新實現obj和dataobj跳號(變成100w)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.