• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

如何获取Oracle DBID

mysql 搞代码 4年前 (2022-01-09) 13次浏览 已收录 0个评论

如何获取Oracle DBID,由于DBID在控制文件和数据文件中都存在记录,所以如果能够mount数据库就可以查询v$database视图获得。

1.查询v$database获得

由于DBID在控制文件和数据文件中都存在记录,所以如果能够mount数据库就可以查询v$database视图获得。

SQL> alter database mount;

Database altered.

SQL> select dbid from v$database;

DBID
———-
1363251591

Oracle 10g中获取DBID

在CentOS 6.4下安装Oracle 11gR2(x64)

Oracle 11gR2 在VMWare虚拟机中安装步骤

Debian 下 安装 Oracle 11g XE R2

2.在nomount状态时

如果数据库配置了自动控制文件备份(Oracle9i),并且名称是缺省的,那么我们可以从自动备份文件获得DBID.

[oracle@jumper dbs]$ cd $ORACLE_HOME/dbs
[oracle@jumper dbs]$ ll c-*
-rw-r—– 1 oracle dba 3375104 Dec 21 11:13 c-1363251591-20051221-00
-rw-r—– 1 oracle dba 3358720 Jan 21 14:03 c-1363251591-20060121-00
-rw-r—– 1 oracle dba 3358720 Jan 21 14:08 c-1363251591-20060121-01

这里的1363251591就是DBID。在10g中,使用Flash Recovery Area,,则没有这个命名规则。

3.从自动备份中恢复

需要或缺DBID进行恢复通常是因为丢失了所有的控制文件.在恢复时会遇到错误.

[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 本文来源[email protected]搞@^&代*@码2网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

如果存在自动备份,我们通常可以直接恢复控制文件,mount数据库之后就好办了:

RMAN> restore controlfile from ‘/opt/oracle/product/9.2.0/dbs/c-1363251591-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

更多详情见请继续阅读下一页的精彩内容:


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:如何获取Oracle DBID

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址