Monday 11 May 2015

RENAMING AN ORACLE DATABASE STEP BY STEP PROCEDURE :

If the database instance runs on same node when nid.exe runs you don't need to use @:

C:\>sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Fri Dec 14 19:51:42 2012

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

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

Total System Global Area 1610612736 bytes
Fixed Size                  2077904 bytes
Variable Size             385878832 bytes
Database Buffers         1207959552 bytes
Redo Buffers               14696448 bytes
Database mounted.
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

C:\>nid target=sys/oracle dbname=test

DBNEWID: Release 10.2.0.5.0 - Production on Fri Dec 14 19:52:24 2012

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

Connected to database 10GR2 (DBID=1672979762)

Connected to server version 10.2.0

Control Files in database:
    C:\ORACLE\PRODUCT\10.2.0\ORADATA\10GR2\CONTROL01.CTL
    C:\ORACLE\PRODUCT\10.2.0\ORADATA\10GR2\CONTROL02.CTL
    C:\ORACLE\PRODUCT\10.2.0\ORADATA\10GR2\CONTROL03.CTL

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

Proceeding with operation
Changing database ID from 1672979762 to 2100191993
Changing database name from 10GR2 to TEST
    Control File C:\ORACLE\PRODUCT\10.2.0\ORADATA\10GR2\CONTROL01.CTL - modified
    Control File C:\ORACLE\PRODUCT\10.2.0\ORADATA\10GR2\CONTROL02.CTL - modified
    Control File C:\ORACLE\PRODUCT\10.2.0\ORADATA\10GR2\CONTROL03.CTL - modified
    Datafile C:\ORACLE\PRODUCT\10.2.0\ORADATA\10GR2\SYSTEM01.DBF - dbid changed, wrote new name
    Datafile C:\ORACLE\PRODUCT\10.2.0\ORADATA\10GR2\UNDOTBS01.DBF - dbid changed, wrote new name
    Datafile C:\ORACLE\PRODUCT\10.2.0\ORADATA\10GR2\SYSAUX01.DBF - dbid changed, wrote new name
    Datafile C:\ORACLE\PRODUCT\10.2.0\ORADATA\10GR2\USERS01.DBF - dbid changed, wrote new name
    Datafile C:\ORACLE\PRODUCT\10.2.0\ORADATA\10GR2\TEMP01.DBF - dbid changed, wrote new name
    Control File C:\ORACLE\PRODUCT\10.2.0\ORADATA\10GR2\CONTROL01.CTL - dbid changed, wrote new name
    Control File C:\ORACLE\PRODUCT\10.2.0\ORADATA\10GR2\CONTROL02.CTL - dbid changed, wrote new name
    Control File C:\ORACLE\PRODUCT\10.2.0\ORADATA\10GR2\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 2100191993.
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.

But you need additional steps (ORADIM is only for Windows):
- changing ORACLE_SID
- renaming init. file
- changing DB_NAME instance parameter
- opening database with RESETLOGS option.

C:>oradim -new -sid test
Instance created.

C:\>set ORACLE_SID=TEST

C:\>cd c:\oracle\product\10.2.0\db_1\database

C:\oracle\product\10.2.0\db_1\database>rename init10GR2.ora initTEST.ora

C:\>sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Fri Dec 14 20:00:24 2012

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
SQL> startup nomount
ORACLE instance started.

Total System Global Area 1610612736 bytes
Fixed Size                  2077904 bytes
Variable Size             385878832 bytes
Database Buffers         1207959552 bytes
Redo Buffers               14696448 bytes
SQL> alter system set db_name=TEST scope=spfile;

System altered.

SQL> startup force
ORACLE instance started.

Total System Global Area 1610612736 bytes
Fixed Size                  2077904 bytes
Variable Size             385878832 bytes
Database Buffers         1207959552 bytes
Redo Buffers               14696448 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

SQL> alter database open resetlogs;

Database altered.

SQL> startup force
ORACLE instance started.

Total System Global Area 1610612736 bytes
Fixed Size                  2077904 bytes
Variable Size             385878832 bytes
Database Buffers         1207959552 bytes
Redo Buffers               14696448 bytes
Database mounted.
Database opened.

SQL> select name from v$database;

NAME
---------
TEST

SQL>

No comments:

Post a Comment