- Backup the database.
- Mount the database after a clean shutdown.
SQL> shutdown immediate
SQL> startup mount
ORACLE instance started.
Total System Global Area 1887350784 bytes
Fixed Size
2227592 bytes
Variable Size 1090519672 bytes
Database Buffers
788529152 bytes
Redo Buffers
6074368 bytes
Database mounted.
- Invoke the DBNEWID utility (nid) specifying
the new DBNAME from the command line using a user with SYSDBA privilege.
bash-3.2$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 10-FEB-2015
00:16:27
Copyright (c) 1991, 2010, Oracle.
All rights reserved.
TNS-01106: Listener using listener name LISTENER has already been
started
bash-3.2$ nid TARGET=sys/mydb@mydb DBNAME=orcl
DBNEWID: Release 11.2.0.2.0 - Production on Tue Feb 10 00:16:31
2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to database MYDB (DBID=2785549275)
Connected to server version 11.2.0
Control Files in database:
/u01/app/oracle/oradata/mydb/control01.ctl
/u01/app/oracle/fast_recovery_area/mydb/control02.ctl
Change database ID and database name MYDB to ORCL? (Y/[N]) => y
Proceeding with operation
Changing database ID from 2785549275 to 1399081567
Changing database name from MYDB to ORCL
Control File
/u01/app/oracle/oradata/mydb/control01.ctl - modified
Control File
/u01/app/oracle/fast_recovery_area/mydb/control02.ctl - modified
Datafile
/u01/app/oracle/oradata/mydb/system1a.db - dbid changed, wrote new name
Datafile
/u01/app/oracle/oradata/mydb/sysaux1a.db - dbid changed, wrote new name
Datafile
/u01/app/oracle/oradata/mydb/undotbs1a.db - dbid changed, wrote new name
Datafile
/u01/app/oracle/oradata/mydb/user01.db - dbid changed, wrote new name
Datafile
/u01/app/oracle/oradata/mydb/user.db - dbid changed, wrote new name
Datafile
/u01/app/oracle/oradata/mydb/ts1.db - dbid changed, wrote new name
Datafile
/u01/app/oracle/oradata/mydb/temp1a.db - dbid changed, wrote new name
Control File
/u01/app/oracle/oradata/mydb/control01.ctl - dbid changed, wrote new name
Control File
/u01/app/oracle/fast_recovery_area/mydb/control02.ctl - dbid changed, wrote new
name
Instance shut down
Database name changed to ORCL.
Modify parameter file and generate a new password file before
restarting.
Database ID for database ORCL changed to 1399081567.
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.
For Windows:
C:\app\oracle\dup\bin>nid
TARGET=sys/mydb@mydb DBNAME=mydb
- Shutdown the database.
SQL>
shutdown immediate
-bash-3.2$ export ORACLE_BASE=/u01/app/oracle
-bash-3.2$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
-bash-3.2$ export PATH=$ORACLE_HOME/bin:$PATH
-bash-3.2$ export ORACLE_SID=orcl
-bash-3.2$ sqlplus '/ as sysdba'
SQL*Plus: Release 11.2.0.2.0 Production on Tue Feb 10 00:21:49
2015
Copyright (c) 1982, 2010, Oracle.
All rights reserved.
Connected to an idle instance.
- Modify the DB_NAME parameter in the
initialization parameter file. The startup will result in an error but
proceed anyway.
SQL> startup mount
pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initorcl.ora'
ORACLE instance started.
Total System Global Area 1887350784 bytes
Fixed Size
2227592 bytes
Variable Size 1090519672 bytes
Database Buffers
788529152 bytes
Redo Buffers
6074368 bytes
Database mounted.
SQL> create spfile from pfile;
File created.
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
- Create a new password file.
bash-3.2$ orapwd
file=/u01/app/oracle/product/11.2.0/db_1/dbs/orapworcl password=orcl entries=10
If you are using Windows you must recreate the service so the
correct name and parameter file are used.
oradim -delete -sid mydb
oradim
-new -sid orcl -intpwd orcl -startmode a -pfile
c:\app\oracle\dup\database\spfileorcl.ora
- Alter the listener.ora and tnsnames.ora
setting to match the new database name and restart the listener.
bash-3.2$ lsnrctl reload
LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 10-FEB-2015
00:38:40
Copyright (c) 1991, 2010, Oracle.
All rights reserved.
Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully
- Open the database with RESETLOGS.
SQL> startup mount
ORACLE instance started.
Total System Global Area 1887350784 bytes
Fixed Size
2227592 bytes
Variable Size
1090519672 bytes
Database Buffers
788529152 bytes
Redo Buffers 6074368 bytes
Database mounted.
SQL> alter database open resetlogs;
Database altered.
- Check the database.
SQL> select name,open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
ORCL READ WRITE