由于DBID在控制文件和數(shù)據(jù)文件中都存在記錄,所以如果能夠mount數(shù)據(jù)庫(kù)就可以查詢v$database視圖獲得.
如果數(shù)據(jù)庫(kù)配置了自動(dòng)控制文件備份(Oracle9i),并且名稱是缺省的,那么我們可以從自動(dòng)備份文件獲得DBID.
需要或缺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
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
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
這種方法僅為測(cè)試興趣所致,不被推薦.