oracle中如何獲得數(shù)據(jù)庫(kù)的DBID信息
1.查詢v$database獲得
由于DBID在控制文件和數(shù)據(jù)文件中都存在記錄,所以如果能夠mount數(shù)據(jù)庫(kù)就可以查詢v$database視圖獲得.
SQL> alter database mount;
Database altered.
SQL> select dbid from v$database;
DBID
----------
3152029224
2.在nomount狀態(tài)時(shí)
如果數(shù)據(jù)庫(kù)配置了自動(dòng)控制文件備份(Oracle9i),并且名稱是缺省的,那么我們可以從自動(dòng)備份文件獲得DBID.
[oracle@jumper dbs]$ cd $ORACLE_HOME/dbs
[oracle@jumper dbs]$ ll c-*
-rw-r----- 1 oracle dba 3375104 Dec 21 11:13 c-3152029224-20051221-00
-rw-r----- 1 oracle dba 3358720 Jan 21 14:03 c-3152029224-20060121-00
-rw-r----- 1 oracle dba 3358720 Jan 21 14:08 c-3152029224-20060121-01
這里的3152029224就是DBID。在10g中,使用Flash Recovery Area,則沒(méi)有這個(gè)命名規(guī)則。
3.從自動(dòng)備份中恢復(fù)
需要或缺DBID進(jìn)行恢復(fù)通常是因?yàn)閬G失了所有的控制文件.在恢復(fù)時(shí)會(huì)遇到錯(cuò)誤.
[oracle@jumper dbs]$ rman target /
Recovery Manager: Release 9.2.0.4.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
connected to target database: conner (not mounted)
RMAN> restore controlfile from autobackup;
Starting restore at 05-FEB-06
using target database controlfile instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=11 devtype=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 02/05/2006 20:47:25
RMAN-06495: must explicitly specify DBID with SET DBID command
如果存在自動(dòng)備份,我們通常可以直接恢復(fù)控制文件,mount數(shù)據(jù)庫(kù)之后就好辦了:
RMAN> restore controlfile from '/opt/oracle/product/9.2.0/dbs/c-3152029224-20051221-00';
Starting restore at 05-FEB-06
using channel ORA_DISK_1
channel ORA_DISK_1: restoring controlfile
channel ORA_DISK_1: restore complete
replicating controlfile
input filename=/opt/oracle/oradata/conner/control01.ctl
output filename=/opt/oracle/oradata/conner/control02.ctl
output filename=/opt/oracle/oradata/conner/control03.ctl
Finished restore at 05-FEB-06
4.直接從幸存的文件中讀取
由于DBID存在于數(shù)據(jù)文件及控制文件中,所以我們可以通過(guò)PL/SQL程序直接從文件中讀取:
SQL> select eygle.get_dbid('/opt/oracle/oradata/conner','user02.dbf') from dual;
EYGLE.GET_DBID('/OPT/ORACLE/OR
------------------------------
3152029224
SQL> select dbid from v$database;
DBID
----------
3152029224
其實(shí)更簡(jiǎn)單的,用BBED就好了。
這種方法僅為測(cè)試興趣所致,不被推薦.
相關(guān)文章
Oracle數(shù)據(jù)庫(kù)升級(jí)或數(shù)據(jù)遷移方法研究
本文詳細(xì)論述了oracle數(shù)據(jù)庫(kù)升級(jí)的升級(jí)前的準(zhǔn)備、升級(jí)過(guò)程和升級(jí)后的測(cè)試與調(diào)整工作,并對(duì)各種升級(jí)方法在多種操作系統(tǒng)平臺(tái)上作了測(cè)試。2016-07-07
oracle 層次化查詢(行政區(qū)劃三級(jí)級(jí)聯(lián))
現(xiàn)在將上面的行政區(qū)劃按代碼分為三個(gè)級(jí)別:省(后四位為0)/市(后兩位為0)/縣,同時(shí)分別標(biāo)出他們的級(jí)別,這樣的話,便于后期根據(jù)不同的級(jí)別查詢。2009-07-07
Oracle 觸發(fā)器實(shí)現(xiàn)主鍵自增效果
這篇文章主要介紹了Oracle 觸發(fā)器實(shí)現(xiàn)主鍵自增,說(shuō)白了就是數(shù)據(jù)確認(rèn)(after)與安全性檢查(before),此外觸發(fā)器不針對(duì)select操作,本文給大家介紹的非常詳細(xì),需要的朋友參考下吧2021-12-12
oracle group by語(yǔ)句實(shí)例測(cè)試
本文將詳細(xì)介紹oracle group by語(yǔ)句,以實(shí)例進(jìn)行測(cè)試,需要的朋友可以參考下2012-11-11
Oracle數(shù)據(jù)庫(kù)中對(duì)null值的排序及mull與空字符串的區(qū)別
這篇文章主要介紹了Oracle數(shù)據(jù)庫(kù)中對(duì)Null值的排序及Null與空字符串的區(qū)別,講解了在order by排序中如何定義null值項(xiàng)的位置及其與字符串' '的不同,需要的朋友可以參考下2016-03-03
Oracle刪除字段中的空格、回車及指定字符的實(shí)例代碼
本文給大家分享Oracle刪除字段中的空格、回車及指定字符的實(shí)例代碼,非常不錯(cuò),具有參考借鑒價(jià)值,需要的的朋友參考下2017-03-03

