修改dbid

可以通过nid命令来修改数据库的dbid或者db_name
修改后需要关闭数据库,用open resetlogs打开,旧的备份都将失效

参考一下测试
最初的dbid如下:
      DBID NAME
---------- -----
 904273405 FOX

c:>nid target=/
Connected to database FOX (DBID=904273405)

Control Files in database:
    D:\ORACLE\ORADATA\FOX\CONTROL01.CTL
    D:\ORACLE\ORADATA\FOX\CONTROL02.CTL

Change database ID of database FOX? (Y/[N]) => y

Proceeding with operation
Changing database ID from 904273405 to 928230252
    Control File D:\ORACLE\ORADATA\FOX\CONTROL01.CTL - modified
    Control File D:\ORACLE\ORADATA\FOX\CONTROL02.CTL - modified
    Datafile D:\ORACLE\ORADATA\FOX\SYSTEM01.DBF - dbid changed
    Datafile D:\ORACLE\ORADATA\FOX\UNDOTBS01.DBF - dbid changed
    Datafile D:\ORACLE\ORADATA\FOX\INDX01.DBF - dbid changed
    Datafile D:\ORACLE\ORADATA\FOX\TBS01.DBF - dbid changed
    Datafile D:\ORACLE\ORADATA\FOX\USERS01.DBF - dbid changed
    Datafile D:\ORACLE\ORADATA\FOX\DEMO01.DBF - dbid changed
    Datafile D:\ORACLE\ORADATA\FOX\TBS02.DBF - dbid changed
    Datafile D:\ORACLE\ORADATA\FOX\RMAN.DBF - dbid changed
    Datafile D:\D1.DBF - dbid changed
    Control File D:\ORACLE\ORADATA\FOX\CONTROL01.CTL - dbid changed
    Control File D:\ORACLE\ORADATA\FOX\CONTROL02.CTL - dbid changed

Database ID for database FOX changed to 928230252.
All previous backups and archived redo logs for this database are unusable.
Shut down database and open with RESETLOGS option.
Succesfully changed database ID.
DBNEWID - Completed succesfully.


C:\Documents and Settings\linjing>sqlplus "/as sysdba"

SQL*Plus: Release 9.2.0.1.0 - Production on Tue Jan 4 18:05:42 2011

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production


> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: 'D:\ORACLE\ORADATA\FOX\SYSTEM01.DBF'
ORA-01206: file is not part of this database - wrong database id


> shutdown immediate;
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
> startup mount
ORACLE instance started.

Total System Global Area  160504432 bytes
Fixed Size                   453232 bytes
Variable Size             117440512 bytes
Database Buffers           41943040 bytes
Redo Buffers                 667648 bytes
Database mounted.
> alter database open ;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


> alter database open resetlogs;

Database altered.

 >select dbid,name from v$database;

     DBID NAME
--------- --------------------------------
928230252 FOX
可以看到dbid已经发生了变化

注:在执行nid的时候如果碰上错误NID-00135,需要open数据库后再做一次干净的关闭,并启动到mount状态
NID-00135 There are number active threads

Cause: There are active threads in the database. The most likely cause is that the database crashed the last time it was shut down.

Action: Ensure that all threads are closed before retrying the operation. Start and open the database to perform crash recovery, then shut down with the NORMAL or IMMEDIATE options to close it cleanly. Finally, try running the utility again.


作者: lovegigi1999   发布时间: 2011-01-04