系统 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.

下面是英文原文

How to Change the DBID, DBNAME Using NID Utility  转到底部

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 ***

How to Change the DBID, DBNAME Using NID Utility (文档 ID 863800.1) 转到底部

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 ***

使用nid修改dbname和dbid相关推荐

  1. 利用nid修改数据库的DBID

    转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/19263339 1.运行nid,显示如下参数: oracle@mydb 2014_02_15 ...

  2. oracle数据库之DBNAME和DBID

    一.查看DBID (1)使用rman查看 $ rman target /Recovery Manager: Release 11.2.0.4.0 - Production on Fri Jun 12 ...

  3. 使用nid工具修改db_name和DBID

    #########原来的################## SQL> select dbid from v$database; DBID ---------- 1490502756 SQL&g ...

  4. Oracle使用NID调整数据库的DBNAME和DBID

    我们知道,在数据库内部,数据库的DBNAME和DBID是数据库标识符,其中,DBID更是数据库的唯一标识符,如果要重新调整数据库的名字,一般是要重建控制文件,为数据库赋予新的名称 (DBNAME): ...

  5. 修改oracle 的dbname,在oracle 10g上修改dbname的实验

    1[参考资料] 对以上资料的作者表示感谢 2[环境参数] Vmware workstation ACE editionversion 6.0 Windows server 2003service pa ...

  6. NID修改数据库名称时候碰到NID-00137

    Oracle 11.2.0.3.5 ,  EBS R12.1.3 今天在做EBS系统克隆时候,使用RMAN备份恢复数据库后,需要更改数据库名称,以免混淆,在做了一系列动作(recover,  redo ...

  7. nid 修改数据库的名字

    Nid是Oracle从9iR2开始提供的工具,可以用来更改数据库名称,而无需通过之前重建控制文件等繁琐方式. 需要说明的是,虽然这个工具来自9iR2,但是仍然可以被用于Oracle8i. 先看一下帮助 ...

  8. Oracle rac使用nid和dbms_backup_restore包修改dbid和dbname

    Oracle rac使用nid和dbms_backup_restore包修改dbid和dbname 之前的连接: http://blog.itpub.net/26736162/viewspace-21 ...

  9. 使用nid命令修改 db name 及 dbid

    工作中不可避免地碰到需要修改dbname以及dbid的情形,如将数据库恢复到同一台机器的情形是其中之一.但dbname以及dbid是用于标识数据库的重要标志之一,尤其是dbid,具有唯一性,因此对其修 ...

最新文章

  1. 重温Thinking in java
  2. 手把手教你使用TF服务将TensorFlow模型部署到生产环境
  3. gitlab的升级【二】旧数据的备份和新数据的恢复
  4. RabbitMQ简单队列模式
  5. 占内存小的qq_手机内存空间告急,这些办法就能轻松搞定!
  6. 主持人副语言包括什么_央视主持人大赛,董卿最精彩的这几段点评,居然被剪掉了...
  7. 数据库SQL语句学习笔记(4)-过滤数据
  8. [信息收集] HCOMP 2010概况及收录论文
  9. 大型网络之---公司内部局域网
  10. 【操作系统】SPOOLing技术(外部设备联机并行操作/假脱机技术)
  11. Bambook 简介
  12. java 数据权限控制_数据权限-数据列权限设计方案
  13. 2.深入解析Javascript异步编程
  14. “电脑族”保健六项注意
  15. 用Python画小猪佩奇
  16. Serializable transient
  17. MATLAB学习笔记:行列式及其应用
  18. 12864LCD驱动ST7567
  19. HelloBird——资源回收o2o平台
  20. Flutter 之简洁实用的图片编辑器

热门文章

  1. 知名站长工具服务商:爱站网突然关站
  2. CF337A Maze 解题报告
  3. 强大的UI组件集Telerik R3 2022支持.NET 7、全新的主题等
  4. time(),date(),microtime()三者的区别
  5. sideEffects导致的全局样式消失
  6. h3c r4900服务器系统安装,H3C R4900 G3安装CentOS 6.7网卡配置方法
  7. HTML开心餐厅网页制作,开心餐厅技巧经验总结
  8. elementui分页隐藏最后一页
  9. sw运行很卡怎么办_打开SolidWorks软件卡顿怎么办?教你完美解决
  10. 在iOS当中发送电子邮件和短信