使用DBNEWID Utility 工具能夠同時修改數據庫名、DBID,也能夠只修改其中一項數據庫
官方參考:oracle
https://docs.oracle.com/cd/E11882_01/server.112/e22490/dbnewid.htm#SUTIL014app
1、同時修改db name 和 dbid (本例:emdb -> mydb)工具
1.修改以前建議給數據庫作個全備。this
2.乾淨關閉數據庫,並重啓到mount狀態spa
shutdown immediate;rest
startup mount;server
3.開始使用nid 工具修改數據庫名和dbidhtm
[oracle@Database ~]$ which nid
/u01/app/oracle/product/11.2.0.4/db_1/bin/nidip
查看命令幫助:
[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;
2、只修改dbid (在使用nid 命令不加dbname參數便可)
[oracle@Database ~]$ nid target=sys dbname=mydb
3、只修改dbname (在nid 命令中 加上 SETNAME=YES 選項,表示只修改數據庫名稱)
[oracle@Database ~]$ nid target=sys dbname=mydb SETNAME=YES