Saturday 20 February 2016

NID - Easy way to change DB name

Hi Guys,


SQL> startup mount
ORACLE instance started.

Total System Global Area  595591168 bytes
Fixed Size                  1220748 bytes
Variable Size             209719156 bytes
Database Buffers          377487360 bytes
Redo Buffers                7163904 bytes
Database mounted.
SQL>


Options that we have:

[oracle@papa ~]$ nid

DBNEWID: Release 10.2.0.1.0 - Production on Thu Jul 21 11:52:54 2011

Copyright (c) 1982, 2005, Oracle.  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@papa ~]$ nid target=sys/oracle@catalog as sysdba dbname=catalog1

DBNEWID: Release 10.2.0.1.0 - Production on Thu Jul 21 12:19:19 2011

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

Password:
Connected to database CATALOG (DBID=604182317)

Connected to server version 10.2.0

Control Files in database:
    /u01/app/oracle/catalog/controlfile/control01.ctl
    /u01/app/oracle/catalog/controlfile/control02.ctl
    /u01/app/oracle/catalog/controlfile/control03.ctl

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

Proceeding with operation
Changing database ID from 604182317 to 3902868108
Changing database name from CATALOG to CATALOG1
Control File /u01/app/oracle/catalog/controlfile/control01.ctl - modified
Control File /u01/app/oracle/catalog/controlfile/control02.ctl - modified
Control File /u01/app/oracle/catalog/controlfile/control03.ctl - modified
Datafile /u01/app/oracle/catalog/system100.dbf - dbid changed, wrote new name
Datafile /u01/app/oracle/catalog/myundo.dbf - dbid changed, wrote new name
Datafile /u01/app/oracle/catalog/sysaux100.dbf - dbid changed, wrote new name
Datafile /u01/app/oracle/catalog/tspapa01.dbf - dbid changed, wrote new name
Datafile /u01/app/oracle/catalog/tspapa02.dbf - dbid changed, wrote new name
Datafile /u01/app/oracle/catalog/users01.dbf - dbid changed, wrote new name
Datafile /u01/app/oracle/catalog/users02.dbf - dbid changed, wrote new name
Datafile /u01/ivants.dbf - dbid changed, wrote new name
Datafile /u01/app/oracle/pri_rman.dbf - dbid changed, wrote new name
Datafile /u01/app/oracle/rman_moni.dbf - dbid changed, wrote new name
Datafile /u01/app/oracle/catalog/temp01.dbf - dbid changed, wrote new name
Control File /u01/app/oracle/catalog/controlfile/control01.ctl - dbid changed, wrote new name
Control File /u01/app/oracle/catalog/controlfile/control02.ctl - dbid changed, wrote new name
Control File /u01/app/oracle/catalog/controlfile/control03.ctl - dbid changed, wrote new name
    Instance shut down

Database name changed to CATALOG1.
Modify parameter file and generate a new password file before restarting.
Database ID for database CATALOG1 changed to 3902868108.
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.
Now we need to change our parameter file:

[oracle@papa ~]$ cd $ORACLE_HOME/dbs
[oracle@papa dbs]$ mv initcatalog.ora initcatalog1.ora
[oracle@papa dbs]$ vi initcatalog1.ora

Alter the parameter DB_NAME=<newdbname>

[oracle@papa dbs]$ export ORACLE_SID=catalog1
[oracle@papa dbs]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jul 21 12:24:15 2011

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

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  595591168 bytes
Fixed Size                  1220748 bytes
Variable Size             163581812 bytes
Database Buffers          423624704 bytes
Redo Buffers                7163904 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> alter database open resetlogs;

Database altered.

SQL> create spfile from pfile;

File created.

Just to check if is everything ok in the initialization:

SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  595591168 bytes
Fixed Size                  1220748 bytes
Variable Size             163581812 bytes
Database Buffers          423624704 bytes
Redo Buffers                7163904 bytes
Database mounted.
Database opened.
SQL>

Done.

No comments:

Post a Comment