|
|
Re: rename a database?????? [message #59486 is a reply to message #59485] |
Wed, 26 November 2003 06:17 |
Thiru
Messages: 1089 Registered: May 2002
|
Senior Member |
|
|
Maheer
that does not rename the database, just the global_name.
For eg)
-- Get the database name
thiru@9.2.0:SQL>select name from v$Database;
NAME
------------------------------
THIRU
-- GEt the Global_name
thiru@9.2.0:SQL>select global_name from global_name;
GLOBAL_NAME
--------------------------------------------------------------------------
THIRU.US.ORACLE.COM
-- Change the global_name to TEST
thiru@9.2.0:SQL>alter database rename global_name to TEST;
Database altered.
thiru@9.2.0:SQL>select global_name from global_name;
GLOBAL_NAME
--------------------------------------------------------------------------
TEST.US.ORACLE.COM
-- The database name remains the same
thiru@9.2.0:SQL>select name from v$Database;
NAME
------------------------------
THIRU
-- Now I can change the global_name back to default
thiru@9.2.0:SQL>alter database rename global_name to THIRU;
Database altered.
thiru@9.2.0:SQL>select global_name from global_name;
GLOBAL_NAME
--------------------------------------------------------------------------
THIRU.US.ORACLE.COM
Changing the database name in 8i and prior involved a number of steps.
Feng, see Mahesh Rajendran's earlier post about those steps. Basically you recreate the controlfile with SET DATABASE clause to update the controlfile and the datafiles , to perform the rename.
If you are in 9i, you can use the NID utility to change the database name easily.
Here's an extract from the documentation of how to do this :
--------------------------------------------------
The following steps describe how to change the database name without changing the DBID.
Ensure that you have a recoverable whole database backup.
Ensure that the target database is mounted but not open, and that it was shut down consistently prior to mounting. For example:
SHUTDOWN IMMEDIATE
STARTUP MOUNT
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 test_db2:
% nid TARGET=SYS/oracle@test_db DBNAME=test_db2 SETNAME=YES
DBNEWID performs validations in the headers of the control files (not the datafiles) before attempting I/O to the files. If validation is successful, then DBNEWID prompts for confirmation, changes the database name in the control files, and exits. After DBNEWID completes successfully, the database is left mounted but is not yet usable.
DBNEWID: Release 9.2.0.1.0
(c) Copyright 2002 Oracle Corporation. All rights reserved.
Connected to database TEST_DB (DBID=3942196782)
Control Files in database:
/oracle/dbs/cf1.f
/oracle/dbs/cf2.f
Change database name of database TEST_DB to TEST_DB2? (Y/[[N]]) => Y
Proceeding with operation
Database name changed from TEST_DB to TEST_DB2 - database needs to be
shutdown.
Modify parameter file and generate a new password file before restarting.
DBNEWID - Successfully changed database name
If validation is not successful, then DBNEWID terminates and leaves the target database intact. You can open the database, fix the error, and then either resume the DBNEWID operation or continue using the database without changing the database name.
Shut down the database. For example:
SHUTDOWN IMMEDIATE
Set the DB_NAME initialization parameter in the initialization parameter file to the new database name.
Create a new password file.
Start up the database and resume normal use. For example:
STARTUP
------------------------------------------
-Thiru
|
|
|
|
|