Sep 12, 2015

Rename database using nid (newdb id) utility

Rename database using newdb id utility ( Standalone database)
-- Before Rename

$ . oraenv
ORACLE_SID = [prod] ? prod
The Oracle base remains unchanged with value /u01/app/oracle

SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
PROD      READ WRITE           PRIMARY

SQL> shutdown immediate;
SQL> startup mount;

Note: If you are doing for the first time, then take a full backup for security purpose.

$ cd $ORACLE_HOME/dbs
$ nid target=system/manager dbname=prod1 setname=yes

bash-4.2$ nid target=system/manager dbname=prod1 setname=yes

DBNEWID: Release 11.2.0.3.0 - Production on Sat Sep 12 14:40:51 2015

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Connected to database PROD (DBID=302068115)

Connected to server version 11.2.0

Control Files in database:
    /u02/oradata/prod/control01.ctl
    /u02/oradata/prod/control02.ctl

Change database name of database PROD to PROD1? (Y/[N]) => Y

Proceeding with operation
Changing database name from PROD to PROD1
    Control File /u02/oradata/prod/control01.ctl - modified
    Control File /u02/oradata/prod/control02.ctl - modified
    Datafile /u02/oradata/prod/system01.db - wrote new name
    Datafile /u02/oradata/prod/sysaux01.db - wrote new name
    Datafile /u02/oradata/prod/undotbs01.db - wrote new name
    Datafile /u02/oradata/prod/users01.db - wrote new name
    Datafile /u02/oradata/prod/example01.db - wrote new name
    Datafile /u02/oradata/prod/temp01.db - wrote new name
    Control File /u02/oradata/prod/control01.ctl - wrote new name
    Control File /u02/oradata/prod/control02.ctl - wrote new name
    Instance shut down

Database name changed to PROD1.
Modify parameter file and generate a new password file before restarting.
Succesfully changed database name.
DBNEWID - Completed succesfully.

$ . oraenv
ORACLE_SID = [prod] ? prod1
ORACLE_HOME = [/home/oracle] ? /u01/app/oracle/product/11.2.0/db_home
The Oracle base remains unchanged with value /u01/app/oracle

Note : Now create your parameter file, password file and ensure an entry in /etc/oratab.

$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Sat Sep 12 14:45:29 2015

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

Connected to an idle instance.

SQL> startup mount;
ORACLE instance started.

Total System Global Area 1.2827E+10 bytes
Fixed Size                  2233480 bytes
Variable Size            6476008312 bytes
Database Buffers         6341787648 bytes
Redo Buffers                7340032 bytes
Database mounted.
SQL>

SQL> alter database open;

Database altered.

SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
PROD1     READ WRITE           PRIMARY

SQL>


Thanks!!!

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete

Translate >>