Search This Blog

Monday, April 2, 2007

Changing Only the Database Name

Database : 10gr1
OS PLATFORM : Windows
Archive Log : Enable
Non Distributed Database System.


SQL> select NAME from v$database;

NAME
---------
ORA101



STEP
1.Ensure that you have a recoverable whole database backup.

2.Ensure that the target database is mounted but not open.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area 171966464 bytes
Fixed Size 787988 bytes
Variable Size 145488364 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
Database mounted.


3.Invoke the utility on the command line, specifying a valid user with the SYSDBA privilege. You must specify both the DBNAME and SETNAME parameters. This example changes the name to ORA10G.


C:\>nid TARGET=SYS/oracle@ORA101 DBNAME=ORA10G SETNAME=YES
DBNEWID: Release 10.1.0.2.0 - Production
Copyright (c) 2001, 2004, Oracle. All rights reserved.

Connected to database ORA101 (DBID=13875087)

Connected to server version 10.1.0

Control Files in database:
C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORA101\CONTROL01.CTL
C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORA101\CONTROL02.CTL
C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORA101\CONTROL03.CTL

Change database name of database ORA101 to ORA10G? (Y/[N]) => Y

Proceeding with operation
Changing database name from ORA101 to ORA10G
Control File C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORA101\CONTROL01.CTL - modifie
d
Control File C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORA101\CONTROL02.CTL - modifie
d
Control File C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORA101\CONTROL03.CTL - modifie
d
Datafile C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORA101\SYSTEM01.DBF - wrote new na
me
Datafile C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORA101\UNDOTBS01.DBF - wrote new n
ame
Datafile C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORA101\SYSAUX01.DBF - wrote new na
me
Datafile C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORA101\USERS01.DBF - wrote new nam
e
Datafile C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORA101\EXAMPLE01.DBF - wrote new n
ame
Datafile C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORA101\TEMP01.DBF - wrote new name

Control File C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORA101\CONTROL01.CTL - wrote n
ew name
Control File C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORA101\CONTROL02.CTL - wrote n
ew name
Control File C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORA101\CONTROL03.CTL - wrote n
ew name
Instance shut down

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


If validation is not successful, then DBNEWID terminates and leaves the target database intact.

4.Set the DB_NAME initialization parameter in the initialization parameter file (PFILE) to the new database name.



C:\>sqlplus sys as sysdba

SQL*Plus: Release 10.1.0.2.0 - Production on Mon Apr 2 17:57:39 2007

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

Enter password:
Connected to an idle instance.

SQL> -- if PFILE not created file create and edit DB_NAME parameter.
SQL> create PFILE from SPFILE;

File created.

SQL> --After edit db_name in PFILE create new SPFILE.
SQL> create SPFILE from PFILE;

File created.


5.Create a new password file.

C:\>orapwd file=c:\oracle\product\10.1.0\db_1\database\PWDora101.ora password=or
acle entries=5 force=y


6.startup database for normal use.

C:\>sqlplus sys as sysdba

SQL*Plus: Release 10.1.0.2.0 - Production on Mon Apr 2 18:09:07 2007

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

Enter password:
Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 171966464 bytes
Fixed Size 787988 bytes
Variable Size 145488364 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
Database mounted.
Database opened.
SQL> select NAME from v$database;

NAME
---------
ORA10G



Instance Name or Database Name is different. in above example we changed just DATABASE NAME not INSTANCE_NAME.

SQL> select NAME from v$database;

NAME
---------
ORA10G

SQL> select INSTANCE_NAME from v$instance;

INSTANCE_NAME
----------------
ora101

No comments: