ITPub博客

首页 > 数据库 > 数据库开发技术 > Changing the DBID and Database Name

Changing the DBID and Database Name

原创 数据库开发技术 作者:davies 时间:2007-02-02 16:57:03 0 删除 编辑
Changing the DBID and Database Name[@more@]

Changing the DBID and Database Name
The following steps describe how to change the DBID of a database. Optionally, you can change the database name as well.

Ensure that you have a recoverable whole database backup.
Ensure that the target database is mounted but not open, and that it was shut down consistently prior to mounting. For example:
SHUTDOWN IMMEDIATE
STARTUP MOUNT


Invoke the DBNEWID utility on the command line, specifying a valid user with the SYSDBA privilege. For example:
% nid TARGET=SYS/oracle@test_db


To change the database name in addition to the DBID, specify the DBNAME parameter. This example changes the name to test_db2:

% nid TARGET=SYS/oracle@test DBNAME=test_db2


The DBNEWID utility performs validations in the headers of the datafiles and control files before attempting I/O to the files. If validation is successful, then DBNEWID prompts you to confirm the operation (unless you specify a log file, in which case it does not prompt), changes the DBID for each datafile (including offline normal and read-only datafiles), and then exits. The database is left mounted but is not yet usable. For example:

DBNEWID: Release 9.2.0.1.0

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

Connected to database TEST_DB (DBID=3942195360)

Control Files in database:
/oracle/dbs/cf1.f
/oracle/dbs/cf2.f

Change database id of database SOLARIS? (Y/[N]) => y

Proceeding with operation
Datafile /oracle/dbs/tbs_01.f - changed
Datafile /oracle/dbs/tbs_02.f - changed
Datafile /oracle/dbs/tbs_11.f - changed
Datafile /oracle/dbs/tbs_12.f - changed
Datafile /oracle/dbs/tbs_21.f - changed

New DBID for database TEST_DB is 3942196782.
All previous backups and archived redo logs for this database are unusable
Proceed to shutdown database and open with RESETLOGS option.
DBNEWID - Database changed.


If validation is not successful, then DBNEWID terminates and leaves the target database intact. You can open the database, fix the error, and then either resume the DBNEWID operation or continue using the database without changing its DBID.

After DBNEWID successfully changes the DBID, shut down the database:
SHUTDOWN IMMEDIATE


Mount the database. For example:
STARTUP MOUNT


Open the database in RESETLOGS mode and resume normal use. For example:
ALTER DATABASE OPEN RESETLOGS;


Make a new database backup. Because you reset the online redo logs, the old backups and archived logs are no longer usable in the current incarnation of the database.

--log
C:>nid TARGET=SYS/HISUNSYS DBNAME=ORA92
DBNEWID: Release 9.2.0.1.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

Connected to database STUDY (DBID=2606284142)

Control Files in database:
D:ORACLEORADATASTUDYCONTROL01.CTL
D:ORACLEORADATASTUDYCONTROL02.CTL
D:ORACLEORADATASTUDYCONTROL03.CTL

Change database ID and database name STUDY to ORA92? (Y/[N]) => Y

Proceeding with operation
Changing database ID from 2606284142 to 1925496585
Changing database name from STUDY to ORA92
Control File D:ORACLEORADATASTUDYCONTROL01.CTL - modified
Control File D:ORACLEORADATASTUDYCONTROL02.CTL - modified
Control File D:ORACLEORADATASTUDYCONTROL03.CTL - modified
Datafile D:ORACLEORADATASTUDYSYSTEM01.DBF - dbid changed, wrote new name
Datafile D:ORACLEORADATASTUDYUNDOTBS01.DBF - dbid changed, wrote new name
Datafile D:ORACLEORADATASTUDYCWMLITE01.DBF - dbid changed, wrote new name
Datafile D:ORACLEORADATASTUDYDRSYS01.DBF - dbid changed, wrote new name
Datafile D:ORACLEORADATASTUDYEXAMPLE01.DBF - dbid changed, wrote new name
Datafile D:ORACLEORADATASTUDYINDX01.DBF - dbid changed, wrote new name
Datafile D:ORACLEORADATASTUDYODM01.DBF - dbid changed, wrote new name
Datafile D:ORACLEORADATASTUDYTOOLS01.DBF - dbid changed, wrote new name
Datafile D:ORACLEORADATASTUDYUSERS01.DBF - dbid changed, wrote new name
Datafile D:ORACLEORADATASTUDYXDB01.DBF - dbid changed, wrote new name
Datafile D:ORACLEORADATASTUDYTEMP01.DBF - dbid changed, wrote new name
Control File D:ORACLEORADATASTUDYCONTROL01.CTL - dbid changed, wrote new name
Control File D:ORACLEORADATASTUDYCONTROL02.CTL - dbid changed, wrote new name
Control File D:ORACLEORADATASTUDYCONTROL03.CTL - dbid changed, wrote new name

Database name changed to ORA92.
Modify parameter file and generate a new password file before restarting.
Database ID for database ORA92 changed to 1925496585.
All previous backups and archived redo logs for this database are unusable.
Shut down database and open with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/178357/viewspace-897038/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: free buffer waits
请登录后发表评论 登录
全部评论
  • 博文量
    81
  • 访问量
    507773