使用nid修改dbname和dbid

本文介绍如何使用NID工具变更Oracle数据库的DBID和DBNAME,包括准备工作、具体步骤及注意事项。变更DBID会使得之前的备份和归档日志失效。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

                                


系统 rh5.8

oracle 10.2.0.5

使用nid实验之前要明白dbname和dbid以及sid的关系

在使用dbca建库的时候,有一步要填dbname和sid,一般情况下填完dbname后下面那个自动填上。实际上,sid和dbname是可以不一样的

另外,dbname能够指定一个数据库,dbid也能对应一个库,它们在数据库里是一一对应的。

但是二者又都是可以修改的,不过dbid的修改是系统自动改的(应该是往大的方向改)

下面是我的实验内容,后面附上英文原文(我只做修改 dbname和dbid,分别修改也都差不多,如果你需要,请参考我的步骤但实施前请按照英文文档核实需要的操作)

1.实验前准备(如果有可能最好生成下pfile)

查看原数据库dbid,dbname

SQL> select dbid,name from v$database;


      DBID NAME
---------- ---------
1439048815 ORCL


[oracle@ttee ~]$ sqlplus sys/oracle as sysdba


SQL*Plus: Release 10.2.0.5.0 - Production on Tue May 24 05:52:38 2016


Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.




Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

2.关闭数据库,启动到mount

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.


SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

3.使用nid工具修改
[oracle@ttee ~]$ nid target=sys/oracle dbname=test


DBNEWID: Release 10.2.0.5.0 - Production on Tue May 24 05:56:14 2016


Copyright (c) 1982, 2007, Oracle.  All rights reserved.


Connected to database ORCL (DBID=1439048815)


Connected to server version 10.2.0


Control Files in database:
    /oradata/orcl/control01.ctl
    /oradata/orcl/control02.ctl
    /oradata/orcl/control03.ctl


Change database ID and database name ORCL to TEST? (Y/[N]) => y


Proceeding with operation
Changing database ID from 1439048815 to 2210806654
Changing database name from ORCL to TEST
    Control File /oradata/orcl/control01.ctl - modified
    Control File /oradata/orcl/control02.ctl - modified
    Control File /oradata/orcl/control03.ctl - modified
    Datafile /oradata/orcl/system01.dbf - dbid changed, wrote new name
    Datafile /oradata/orcl/undotbs01.dbf - dbid changed, wrote new name
    Datafile /oradata/orcl/sysaux01.dbf - dbid changed, wrote new name
    Datafile /oradata/orcl/users01.dbf - dbid changed, wrote new name
    Datafile /oradata/orcl/temp01.dbf - dbid changed, wrote new name
    Control File /oradata/orcl/control01.ctl - dbid changed, wrote new name
    Control File /oradata/orcl/control02.ctl - dbid changed, wrote new name
    Control File /oradata/orcl/control03.ctl - dbid changed, wrote new name
    Instance shut down


Database name changed to TEST.
Modify parameter file and generate a new password file before restarting.
Database ID for database TEST changed to 2210806654.
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.提示成功,使用参数文件启动成功,如果有保存的pfile修改其中的dbname,我这里没有保存但是$ORACLE_HOME/dbs下有原来的spfile

将它拷贝到tmp下命名为init.ora,然后保留里面带*号的选项,其他一概删掉(尤其是乱码)更改dbname哪一行



SQL> startup mount pfile='/tmp/init.ora'
ORACLE instance started.


Total System Global Area  171966464 bytes
Fixed Size                  2094832 bytes
Variable Size             113248528 bytes
Database Buffers           50331648 bytes
Redo Buffers                6291456 bytes
Database mounted.
SQL> alter database open resetlogs
  2  ;

5.resetlogs后创建打开数据库创建spfile

SQL> create spfile from pfile='/tmp/init.ora';


File created.


6.创建新的密码文件。我这里使用的是操作系统认证,所以这一步在第5步之后,否则要先建密码文件


oracle@ttee dbs]$ orapwd file=orapwtest password=oracle 


[oracle@ttee dbs]$ 
[oracle@ttee dbs]$ sqlplus  sys/oracle as sysdba


SQL*Plus: Release 10.2.0.5.0 - Production on Tue May 24 06:16:05 2016


Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.



Database altered.

7.查看此时的dbid和dbname,发现已经是新的了
SQL> select dbid,name from v$database;


      DBID NAME
---------- ---------
2210806654 TEST




Connected.

8.查看参数除了sid都变为test
SQL> show parameter name


NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert                 string
db_name                              string      test
db_unique_name                       string      test
global_names                         boolean     FALSE
instance_name                        string      orcl
lock_name_space                      string
log_file_name_convert                string
service_names                        string      test
SQL> 

9.查看监听,停止,开启,注册
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "test" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "test_XPT" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@ttee admin]$ 

10.修改tnsnames.ora,这里的服务名要修改
ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ttee)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
修改完后

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ttee)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = test)
    )
  )
然后使用一个普通用户sqlplus scott/tiiger@orcl

SQL> conn scott/tiger@orcl
Connected.


下面是英文原文





转到底部转到底部

In this Document

Goal
 Solution
 Changing the DBID and Database Name (DB_NAME) :
 Changing Only the Database ID
 Changing Only the Database Name
 Logs for NID :
 References

APPLIES TO:

Oracle Database - Enterprise Edition - Version 10.2.0.1 and later
Information in this document applies to any platform.

GOAL

The goal of this note is to describe how to change DBID AND/OR DB_NAME of a database.

Note:

Changing the DBID of a database is a serious procedure. 
When the DBID of a database is changed, all previous backups and archived logs of the database become unusable. This is similar to creating a database except that the data is already in the datafiles. After you change the DBID, backups and archive logs that were created prior to the change can no longer be used because they still have the original DBID, which does not match the current DBID. You must open the database with the RESETLOGS option, which re-creates the online redo logs and resets their sequence to 1 (see the Oracle Database Administrator's Guide). Consequently, you should make a backup of the whole database immediately after changing the DBID.

If you change DBID at Primary in a Standby Environment, the STANDBY Database must be rebuild.
Without Standby recreated, you will see messages like this example in Alert.log:  

 Standby database ID mismatch [0x80a847ae:0x396b3b92] (2158512046:963328914)
 Mon Apr 07 12:18:26 2014
 Standby database ID mismatch [0x80a847ae:0x396b3b92] (2158512046:963328914)
.
 
Changing the DBNAME without changing the DBID does not require you to open with the RESETLOGS option, so database backups and archived logs are not invalidated. However, changing the DBNAME does have consequences. You must change the DB_NAME initialization parameter after a database name change to reflect the new name. Also, you may have to re-create the Oracle password file. If you restore an old backup of the control file (before the name change), then you should use the initialization parameter file and password file from before the database name change.




For RAC Databases, ensure that you shutdown all instances, start only one instance with CLUSTER_DATABASE=FALSE and perform below activities. After the activity is performed, start all rac instances normally.

SOLUTION

Changing the DBID and Database Name (DB_NAME) :

1. Ensure you have valid cold/hot backup of database. If it's a hot backup (RMAN or OS), ensure you also have all the archived logs and backup of all Online Redo logs (after database is consistently shutdown).

2. export ORACLE_HOME=<Path of the Oracle Home> -- Unix and Linux

set ORACLE_HOME=<Path of the Oracle Home> -- Windows 

3. cd <Oracle Home>/bin

4. Drop the dbconsole :

Refer to the following note for more information:

Note.278100.1 How To Drop, Create And Recreate DB Control In A 10g Database.

5. Bring the database to the Mount stage:
    SQL> STARTUP MOUNT


6. If you need to use TNS to connect to database, make sure that you have DB_OLD specified in the tnsnames.ora and listener is started.
    You can also check if you able to connect to the database using sqlplus :   
  $ sqlplus sys/<password>@DB_OLD

7. Issue following command to invoke NID utility:   

$ nid TARGET=SYS/password@DB_OLD DBNAME=DB_NEW

or

$ nid TARGET=SYS/password DBNAME=DB_NEW

 

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 (and the DBNAME, if specified, as in this example) for each datafile, including offline normal and read-only datafiles, shuts down the database, and then exits.


The following is an example of what the output for this would look like:

DBNEWID: Release 10.2.0.4.0 - Production on Mon Jul 27 18:29:06 2009

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

Connected to database TSTNID2 (DBID=729333573)

Connected to server version 10.2.0

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

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

Proceeding with operation
Changing database ID from 729333573 to 2473929266
Changing database name from DB_OLD to DB_NEW
Control File D:\ORACLE\ORADATA\DB102NEW\CONTROL01.CTL - modified
Control File D:\ORACLE\ORADATA\DB102NEW\CONTROL02.CTL - modified
Control File D:\ORACLE\ORADATA\DB102NEW\CONTROL03.CTL - modified

Datafile D:\ORACLE\ORADATA\DB102NEW\SYSTEM01.DBF - dbid changed, wrote new name
Datafile D:\ORACLE\ORADATA\DB102NEW\UNDOTBS01.DBF - dbid changed, wrote new name
Datafile D:\ORACLE\ORADATA\DB102NEW\SYSAUX01.DBF - dbid changed, wrote new name
Datafile D:\ORACLE\ORADATA\DB102NEW\USERS01.DBF - dbid changed, wrote new name
Datafile D:\ORACLE\ORADATA\DB102NEW\EXAMPLE01.DBF - dbid changed, wrote new name
Datafile D:\ORACLE\ORADATA\DB102NEW\TEST.DBF - dbid changed, wrote new name
Datafile D:\ORACLE\ORADATA\DB102NEW\TEMP01.DBF - dbid changed, wrote new name
Datafile D:\ORACLE\ORADATA\DB102NEW\TEMP011.DBF - dbid changed, wrote new name
Control File D:\ORACLE\ORADATA\DB102NEW\CONTROL01.CTL - dbid changed, wrote new name
Control File D:\ORACLE\ORADATA\DB102NEW\CONTROL02.CTL - dbid changed, wrote new name
Control File D:\ORACLE\ORADATA\DB102NEW\CONTROL03.CTL - dbid changed, wrote new name

Instance shut down

Database name changed to DB_NEW.
Modify parameter file and generate a new password file before restarting.
Database ID for database DB_NEW changed to 2473929266.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.

 

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


8. Change the DB_NAME in the pfile/spfile:
    Set the DB_NAME initialization parameter in the initialization parameter file (PFILE) to  the new   
    database name.

The NID utility does not change the server parameter file (SPFILE). Therefore, if you use SPFILE to start your Oracle database, you must re-create the initialization parameter file from the server parameter file, remove the server parameter file, change the DB_NAME in the initialization parameter file, and then re-create the server parameter file.


9. If you are using ASM and want to change the file name, follow this Article at this point

Note 564993.1 How to rename/move a datafile in the same ASM diskgroup



10. NID Utility will shutdown the database after the execution. So mount the database once again. 
    SQL> STARTUP MOUNT

11. Open the database in RESETLOGS mode: 
    SQL> 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.


12. Recreate the password file since the DB NAME has been changed:

$ orapwd file=<fname> password=<password> entries=<users> force=<y/n> nosysdba=<y/n>

where
file - name of password file (mand),
password - password for SYS (mand),
entries - maximum number of distinct DBA,
force - whether to overwrite existing file (opt),
nosysdba - whether to shut out the SYSDBA logon (opt for Database Vault only).
Note: There are no spaces around the equal-to (=) character.

On Unix/Linux the passwordfile convention is : $ORACLE_HOME/dbs/orapw$ORACLE_SID
On MS Windows the passwordfile convention is : %ORACLE_HOME%\database\PWD%ORACLE_SID%.ORA


13. Change the $ORACLE_HOME/network/admin/tnsnames.ora file wherever it has the old db name.

14. If there is a static registration of the database in the listener.ora file then change the database name in the following file $ORACLE_HOME/network/admin/listener.ora.
 
15. Change of Global Database Names:

If you are dealing with a database in a distributed database system, then each database should have a unique global database name. The DBNEWID utility does not change global database names. This can only be done with the SQL ALTER DATABASE statement, for which the syntax is as follows:

ALTER DATABASE RENAME GLOBAL_NAME TO <newname>.<domain>;


The global database name is made up of a database name and a domain, which are determined by the DB_NAME and DB_DOMAIN initialization parameters when the database is first created.

Windows specific steps:

16. Recreate the Database Service :

$ oradim -NEW -SID prod -STARTMODE auto -PFILE <....\initDB_NEW.ora>


17. Recreate the DB Console service : 

$ emca -config dbcontrol db -repos recreate

This command will ask you the new SID and will delete and recreate the service.


Refer to the following note for more information:
Note.278100.1 How To Drop, Create And Recreate DB Control In A 10g Database

Changing Only the Database ID

1-6 except 4. Follow the steps 1 to 6 (except step 4) given in above section.

7. Issue following command to invoke the NID utility:   

$ nid TARGET=SYS/password@DB_OLD

or

$ nid TARGET=SYS/password


8. NID Utility will shutdown the database after the execution. So mount the database once again. 
    SQL> STARTUP MOUNT

9. Open the database in RESETLOGS mode: 
    SQL> 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.

 

Changing Only the Database Name

1-6. Follow the steps 1 to 6 given in first section.

7. Invoke the NID utility using following command
   You must specify both the DBNAME and SETNAME parameters.   

$ nid TARGET=SYS/password@test_db DBNAME=test_db SETNAME=YES

or

$ nid TARGET=SYS/password DBNAME=test_db SETNAME=YES


8. Change the DB_NAME in the pfile/spfile: Follow step 8 from the first section.

9. If you are using ASM and want to change the file name, follow this Article at this point

Note 564993.1 How to rename/move a datafile in the same ASM diskgroup



10. Start up the database in normal mode.
    SQL> STARTUP

Because you have changed only the database name, and not the database ID, it is not necessary to use the RESETLOGS option when you open the database. This means that all previous backups are still usable.


11 - 16 Follow steps 11 to 16 given in the first section as applicable.

Logs for NID :

The operation performed by NID is recorded in the alert file:
For example:

*** DBNEWID utility started ***
DBNAME will be changed from PROD to new DBNAME of TEST_DB
Starting datafile conversion
Datafile conversion complete
Database name changed to TEST_DB.
Modify parameter file and generate a new password file before restarting.
Successfully changed database name.
*** DBNEWID utility finished successfully ***


转到底部转到底部

In this Document

Goal
 Solution
 Changing the DBID and Database Name (DB_NAME) :
 Changing Only the Database ID
 Changing Only the Database Name
 Logs for NID :
 References

APPLIES TO:

Oracle Database - Enterprise Edition - Version 10.2.0.1 and later
Information in this document applies to any platform.

GOAL

The goal of this note is to describe how to change DBID AND/OR DB_NAME of a database.

Note:

Changing the DBID of a database is a serious procedure. 
When the DBID of a database is changed, all previous backups and archived logs of the database become unusable. This is similar to creating a database except that the data is already in the datafiles. After you change the DBID, backups and archive logs that were created prior to the change can no longer be used because they still have the original DBID, which does not match the current DBID. You must open the database with the RESETLOGS option, which re-creates the online redo logs and resets their sequence to 1 (see the Oracle Database Administrator's Guide). Consequently, you should make a backup of the whole database immediately after changing the DBID.

If you change DBID at Primary in a Standby Environment, the STANDBY Database must be rebuild.
Without Standby recreated, you will see messages like this example in Alert.log:  

 Standby database ID mismatch [0x80a847ae:0x396b3b92] (2158512046:963328914)
 Mon Apr 07 12:18:26 2014
 Standby database ID mismatch [0x80a847ae:0x396b3b92] (2158512046:963328914)
.
 
Changing the DBNAME without changing the DBID does not require you to open with the RESETLOGS option, so database backups and archived logs are not invalidated. However, changing the DBNAME does have consequences. You must change the DB_NAME initialization parameter after a database name change to reflect the new name. Also, you may have to re-create the Oracle password file. If you restore an old backup of the control file (before the name change), then you should use the initialization parameter file and password file from before the database name change.




For RAC Databases, ensure that you shutdown all instances, start only one instance with CLUSTER_DATABASE=FALSE and perform below activities. After the activity is performed, start all rac instances normally.

SOLUTION

Changing the DBID and Database Name (DB_NAME) :

1. Ensure you have valid cold/hot backup of database. If it's a hot backup (RMAN or OS), ensure you also have all the archived logs and backup of all Online Redo logs (after database is consistently shutdown).

2. export ORACLE_HOME=<Path of the Oracle Home> -- Unix and Linux

set ORACLE_HOME=<Path of the Oracle Home> -- Windows 

3. cd <Oracle Home>/bin

4. Drop the dbconsole :

Refer to the following note for more information:

Note.278100.1 How To Drop, Create And Recreate DB Control In A 10g Database.

5. Bring the database to the Mount stage:
    SQL> STARTUP MOUNT


6. If you need to use TNS to connect to database, make sure that you have DB_OLD specified in the tnsnames.ora and listener is started.
    You can also check if you able to connect to the database using sqlplus :   
  $ sqlplus sys/<password>@DB_OLD

7. Issue following command to invoke NID utility:   

$ nid TARGET=SYS/password@DB_OLD DBNAME=DB_NEW

or

$ nid TARGET=SYS/password DBNAME=DB_NEW

 

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 (and the DBNAME, if specified, as in this example) for each datafile, including offline normal and read-only datafiles, shuts down the database, and then exits.


The following is an example of what the output for this would look like:

DBNEWID: Release 10.2.0.4.0 - Production on Mon Jul 27 18:29:06 2009

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

Connected to database TSTNID2 (DBID=729333573)

Connected to server version 10.2.0

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

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

Proceeding with operation
Changing database ID from 729333573 to 2473929266
Changing database name from DB_OLD to DB_NEW
Control File D:\ORACLE\ORADATA\DB102NEW\CONTROL01.CTL - modified
Control File D:\ORACLE\ORADATA\DB102NEW\CONTROL02.CTL - modified
Control File D:\ORACLE\ORADATA\DB102NEW\CONTROL03.CTL - modified

Datafile D:\ORACLE\ORADATA\DB102NEW\SYSTEM01.DBF - dbid changed, wrote new name
Datafile D:\ORACLE\ORADATA\DB102NEW\UNDOTBS01.DBF - dbid changed, wrote new name
Datafile D:\ORACLE\ORADATA\DB102NEW\SYSAUX01.DBF - dbid changed, wrote new name
Datafile D:\ORACLE\ORADATA\DB102NEW\USERS01.DBF - dbid changed, wrote new name
Datafile D:\ORACLE\ORADATA\DB102NEW\EXAMPLE01.DBF - dbid changed, wrote new name
Datafile D:\ORACLE\ORADATA\DB102NEW\TEST.DBF - dbid changed, wrote new name
Datafile D:\ORACLE\ORADATA\DB102NEW\TEMP01.DBF - dbid changed, wrote new name
Datafile D:\ORACLE\ORADATA\DB102NEW\TEMP011.DBF - dbid changed, wrote new name
Control File D:\ORACLE\ORADATA\DB102NEW\CONTROL01.CTL - dbid changed, wrote new name
Control File D:\ORACLE\ORADATA\DB102NEW\CONTROL02.CTL - dbid changed, wrote new name
Control File D:\ORACLE\ORADATA\DB102NEW\CONTROL03.CTL - dbid changed, wrote new name

Instance shut down

Database name changed to DB_NEW.
Modify parameter file and generate a new password file before restarting.
Database ID for database DB_NEW changed to 2473929266.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.

 

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


8. Change the DB_NAME in the pfile/spfile:
    Set the DB_NAME initialization parameter in the initialization parameter file (PFILE) to  the new   
    database name.

The NID utility does not change the server parameter file (SPFILE). Therefore, if you use SPFILE to start your Oracle database, you must re-create the initialization parameter file from the server parameter file, remove the server parameter file, change the DB_NAME in the initialization parameter file, and then re-create the server parameter file.


9. If you are using ASM and want to change the file name, follow this Article at this point

Note 564993.1 How to rename/move a datafile in the same ASM diskgroup



10. NID Utility will shutdown the database after the execution. So mount the database once again. 
    SQL> STARTUP MOUNT

11. Open the database in RESETLOGS mode: 
    SQL> 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.


12. Recreate the password file since the DB NAME has been changed:

$ orapwd file=<fname> password=<password> entries=<users> force=<y/n> nosysdba=<y/n>

where
file - name of password file (mand),
password - password for SYS (mand),
entries - maximum number of distinct DBA,
force - whether to overwrite existing file (opt),
nosysdba - whether to shut out the SYSDBA logon (opt for Database Vault only).
Note: There are no spaces around the equal-to (=) character.

On Unix/Linux the passwordfile convention is : $ORACLE_HOME/dbs/orapw$ORACLE_SID
On MS Windows the passwordfile convention is : %ORACLE_HOME%\database\PWD%ORACLE_SID%.ORA


13. Change the $ORACLE_HOME/network/admin/tnsnames.ora file wherever it has the old db name.

14. If there is a static registration of the database in the listener.ora file then change the database name in the following file $ORACLE_HOME/network/admin/listener.ora.
 
15. Change of Global Database Names:

If you are dealing with a database in a distributed database system, then each database should have a unique global database name. The DBNEWID utility does not change global database names. This can only be done with the SQL ALTER DATABASE statement, for which the syntax is as follows:

ALTER DATABASE RENAME GLOBAL_NAME TO <newname>.<domain>;


The global database name is made up of a database name and a domain, which are determined by the DB_NAME and DB_DOMAIN initialization parameters when the database is first created.

Windows specific steps:

16. Recreate the Database Service :

$ oradim -NEW -SID prod -STARTMODE auto -PFILE <....\initDB_NEW.ora>


17. Recreate the DB Console service : 

$ emca -config dbcontrol db -repos recreate

This command will ask you the new SID and will delete and recreate the service.


Refer to the following note for more information:
Note.278100.1 How To Drop, Create And Recreate DB Control In A 10g Database

Changing Only the Database ID

1-6 except 4. Follow the steps 1 to 6 (except step 4) given in above section.

7. Issue following command to invoke the NID utility:   

$ nid TARGET=SYS/password@DB_OLD

or

$ nid TARGET=SYS/password


8. NID Utility will shutdown the database after the execution. So mount the database once again. 
    SQL> STARTUP MOUNT

9. Open the database in RESETLOGS mode: 
    SQL> 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.

 

Changing Only the Database Name

1-6. Follow the steps 1 to 6 given in first section.

7. Invoke the NID utility using following command
   You must specify both the DBNAME and SETNAME parameters.   

$ nid TARGET=SYS/password@test_db DBNAME=test_db SETNAME=YES

or

$ nid TARGET=SYS/password DBNAME=test_db SETNAME=YES


8. Change the DB_NAME in the pfile/spfile: Follow step 8 from the first section.

9. If you are using ASM and want to change the file name, follow this Article at this point

Note 564993.1 How to rename/move a datafile in the same ASM diskgroup



10. Start up the database in normal mode.
    SQL> STARTUP

Because you have changed only the database name, and not the database ID, it is not necessary to use the RESETLOGS option when you open the database. This means that all previous backups are still usable.


11 - 16 Follow steps 11 to 16 given in the first section as applicable.

Logs for NID :

The operation performed by NID is recorded in the alert file:
For example:

*** DBNEWID utility started ***
DBNAME will be changed from PROD to new DBNAME of TEST_DB
Starting datafile conversion
Datafile conversion complete
Database name changed to TEST_DB.
Modify parameter file and generate a new password file before restarting.
Successfully changed database name.
*** DBNEWID utility finished successfully ***
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值