• 怎样获取oracle dbid


    1.查询v$database获得


    因为DBID在控制文件和数据文件里都存在记录,所以假设可以mount数据库就行查询v$database视图获得. 



    SQL> alter database mount;


    Database altered.


    SQL> select dbid from v$database;


          DBID
    ----------
    1363251591






    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 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


     


    4.直接从幸存的文件里读取


    因为DBID存在于数据文件及控制文件里,所以我们能够通过PL/SQL程序直接从文件里读取: 




    SQL> select eygle.get_dbid('/opt/oracle/oradata/conner','user02.dbf') from dual;


    EYGLE.GET_DBID('/OPT/ORACLE/OR
    ------------------------------
    1363251591


    SQL> select dbid from v$database;


    DBID
    ----------
    1363251591


     事实上更简单的,用BBED就好了。




    这样的方法仅为測试兴趣所致,不被推荐.
    --此处为eygle自己定义的函数  (抽时间我会补上)




    5、通过dump数据文件获取dbid:
    SYS@orcl> alter system dump datafile 'D:APPADMINISTRATORORADATAORCLUSERS01.DBF' block 1000;


    系统已更改。


    SYS@orcl> select tracefile from v$process where addr in (select paddr from v$session where sid in (select sid from v$mystat));


    --查看trace文件:Db ID=1363251591
    TRACEFILE
    ------------------------------------------------------------------------------
    d:appadministratordiag dbmsorclorcl raceorcl_ora_6740.trc


    Start dump data block from file D:APPADMINISTRATORORADATAORCLUSERS01.DBF minblk 0 maxblk -1
     V10 STYLE FILE HEADER:
    Compatibility Vsn = 186646528=0xb200000
    Db ID=1363251591=0x51419187, Db Name='ORCL'
    Activation ID=0=0x0
    Control Seq=10579=0x2953, File size=1600=0x640
    File Number=4, Blksiz=8192, File Type=3 DATA

    Dump all the blocks in range:

    ...





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

    Dylan    Presents.



  • 相关阅读:
    装备购买 线性基+贪心
    花园 状压DP+矩阵快速幂
    数学作业 递推+矩阵快速幂
    石头游戏 构造+矩阵快速幂
    sumdiv 算术基本定理的推论
    huffman
    Integer 类型比较大小
    java 中的 String 相加
    Java 中的 static 关键字
    JAVA 基础
  • 原文地址:https://www.cnblogs.com/mthoutai/p/7325239.html
Copyright © 2020-2023  润新知