使用DBNEWID Utility 工具可以同時修改資料庫名、DBID,也可以只修改其中一項 官方參考: https://docs.oracle.com/cd/E11882_01/server.112/e22490/dbnewid.htm#SUTIL014 一、同時修改db name 和 dbid ...
使用DBNEWID Utility 工具可以同時修改資料庫名、DBID,也可以只修改其中一項
官方參考:
https://docs.oracle.com/cd/E11882_01/server.112/e22490/dbnewid.htm#SUTIL014
一、同時修改db name 和 dbid (本例:emdb -> mydb)
1.修改之前建議給資料庫做個全備。
2.乾凈關閉資料庫,並重啟到mount狀態
shutdown immediate;
startup mount;
3.開始使用nid 工具修改資料庫名和dbid
[oracle@Database ~]$ which nid
/u01/app/oracle/product/11.2.0.4/db_1/bin/nid
查看命令幫助:
[oracle@Database ~]$ nid -help
DBNEWID: Release 11.2.0.4.0 - Production on Tue Jun 5 15:03:50 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Keyword Description (Default)
---------------------------------------------------------
TARGET Username/Password (NONE)
DBNAME New database name (NONE)
LOGFILE Output Log (NONE)
REVERT Revert failed change NO
SETNAME Set a new database name only NO
APPEND Append to output log NO
HELP Displays these messages NO
[oracle@Database ~]$ nid target=sys dbname=mydb
DBNEWID: Release 11.2.0.4.0 - Production on Tue Jun 5 15:04:37 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Password:
Connected to database EMDB (DBID=2097101097)
Connected to server version 11.2.0
Control Files in database:
/u01/app/oracle/oradata/emdb/control01.ctl
/u01/app/oracle/oradata/emdb/control02.ctl
Change database ID and database name EMDB to MYDB? (Y/[N]) => y
Proceeding with operation
Changing database ID from 2097101097 to 2892995079
Changing database name from EMDB to MYDB
Control File /u01/app/oracle/oradata/emdb/control01.ctl - modified
Control File /u01/app/oracle/oradata/emdb/control02.ctl - modified
Datafile /u01/app/oracle/oradata/emdb/system01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/emdb/sysaux01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/emdb/undotbs01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/emdb/users01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/emdb/mgmt_ecm_depot1.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/emdb/mgmt.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/emdb/mgmt_deepdive.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/emdb/temp01.db - dbid changed, wrote new name
Control File /u01/app/oracle/oradata/emdb/control01.ctl - dbid changed, wrote new name
Control File /u01/app/oracle/oradata/emdb/control02.ctl - dbid changed, wrote new name
Instance shut down
Database name changed to MYDB.
Modify parameter file and generate a new password file before restarting.
Database ID for database MYDB changed to 2892995079.
All previous backups and archived redo logs for this database are unusable.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.
4.最後修改參數文件中的db_name
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 1853947904 bytes
Fixed Size 2254264 bytes
Variable Size 939526728 bytes
Database Buffers 905969664 bytes
Redo Buffers 6197248 bytes
SQL> alter system set db_name='mydb' scope=spfile;
System altered.
SQL> shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
5. 以resetlogs方式打開資料庫
SQL> startup mount;
ORACLE instance started.
Total System Global Area 1853947904 bytes
Fixed Size 2254264 bytes
Variable Size 939526728 bytes
Database Buffers 905969664 bytes
Redo Buffers 6197248 bytes
Database mounted.
SQL> alter database open resetlogs;
二、只修改dbid (在使用nid 命令不加dbname參數即可)
[oracle@Database ~]$ nid target=sys dbname=mydb
三、只修改dbname (在nid 命令中 加上 SETNAME=YES 選項,表示只修改資料庫名稱)
[oracle@Database ~]$ nid target=sys dbname=mydb SETNAME=YES