How to Change the DBID, DBNAME Using NID Utility (Doc ID 863800.1)

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 mount

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

Oracle 使用Nid 修改数据库的DBID 和 Database Name的更多相关文章

  1. MySQL创建和修改数据库语法

    1.创建数据库语法: CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name    [create_specification [, create_spe ...

  2. MSSQL 修改数据库的排序规则

    1.修改数据库排序规则 ALTER DATABASE [CHARACTER] COLLATE Chinese_PRC_CI_AS ; 2.修改表中列的排序规则 如果下列其中之一当前正在引用一个列,则无 ...

  3. MSSQL2005 修改数据库的排序规则

    1.修改数据库排序规则ALTER DATABASE [DataBaseName] COLLATE Chinese_PRC_CI_AS ; 2.修改表中列的排序规则 如果下列其中之一当前正在引用一个列, ...

  4. Oracle NID工具修改数据库DBID、数据库名称、数据库实例名

    DBID是数据库的唯一标识符,在一些特殊场合会涉及到DBID的相关内容,本篇文章的目的是演示将DB_NAME的值从ORCL修改为ORCL1. 一.查看当前的环境 [oracle@oracledb ad ...

  5. oracle nid修改dbname

    修改name的目的只是为了日后管理清晰点,不重复.我比较懒.记性又差,所以就整理记下1.检查当前nameSQL> show parameter nameNAME TYPE VALUE------ ...

  6. Oracle :修改数据库服务器字符集

    最近,有现场反应,程序显示乱码.感觉很奇怪,该系统已经卖出去无数了.肯定是现场数据库字符集有问题,经过查看, 现场环境: window系统,oracle10g. 我们要求的数据库字符集是AL32UTF ...

  7. Oracle 11g中修改默认密码过期天数和锁定次数

    Oracle 11g中修改默认密码过期天数和锁定次数 密码过期的原因一般有两种可能: 一.由于Oracle中默认在default概要文件中设置了"PASSWORD_LIFE_TIME=180 ...

  8. Ubuntu 安装 mysql 并修改数据库目录

    . . . . . 今天折腾了一下午的时间,恢复了无数次虚拟机快照,终于在 Ubuntu 上把 mysql 安装好了. mysql 是从官网下载的:mysql-server_5.7.16-1ubunt ...

  9. ORACLE查看并修改session和连接最大数

    第一步,在cmd命令行,输入sqlplus 第二步,根据提示输入用户名与密码 1. 查看processes和sessions参数 SQL> show parameter processes NA ...

随机推荐

  1. inventor删除不干净

    AUTODESK系列软件着实令人头疼,安装失败之后不能完全卸载!!!(比如maya,cad,3dsmax等).有时手动删除注册表重装之后还是会出现各种问题,每个版本的C++Runtime和.NET f ...

  2. 探讨PHP获取checkbox值

    如何才能正确的实现PHP获取checkbox值对于初学者来说还是比较陌生的.在这里我们将为大家详细介绍相关的实现方法,希望对大家有所帮助. > > > weeks后的中括号不可漏,否 ...

  3. idea安装激活

    安装激活链接: https://blog.csdn.net/newabcc/article/details/80601933 激活出错链接:(key is invalid 失效) https://bl ...

  4. .NET开发人员必知的八个网站

    当前全球有数百万的开发人员在使用微软的.NET技术.如果你是其中之一,或者想要成为其中之一的话,我下面将要列出的每一个站点都应该是你的最爱,都应该收藏到书签中去.对于不熟悉.NET技术的朋友,需要说明 ...

  5. window下隐藏apache版本和PHP脚本等敏感信息

    隐藏Apache信息 1.1 主配置中启用httpd-default.conf 文件: conf/httpd.Conf 找到httpd-default.conf,删除前面的注释“#”,改成如下 Inc ...

  6. Inconsistent accessibility

    Inconsistent accessibility: return type 'ConsoleApplication17.IBacklight' is less accessible than me ...

  7. Android GreenDAO 3.0 不修改版本号的情况下增加、删除表、添加字段

    最近项目中使用了GreenDAO的3.0以上的版本,出现需要增加删除表的需求,刚开始用,发现官方对增加和删除的方法是每次去修改数据库版本号,版本一旦升级,那么原来数据库中的表会全部删除再重建.太麻烦, ...

  8. Android设置TextView的行间距,EditText下划线

    textView用于显示文本,大量文字显示在一起显得过于紧凑.可通过在布局中更改TextView属性设置行间距. 1.android:lineSpacingMultiplier="1.5&q ...

  9. iphone 微信下浏览器中数字去除下划线

    在开发iphone应用程序的时候,safari下手机号码默认是有下划线的,通过下面的方法就可以去掉: <meta name="format-detection" conten ...

  10. IplImage转为Mat的方法

    IplImage* S_change_out; Mat matimg; matimg=cvarrToMat(S_change_out);