Sie sind auf Seite 1von 10

Changing Your Database Name and Database

Identifier
Purpose
This module describes how you can change the name of your database and
your database identifier.
Topics
This module discusses the following:
Overview
Oracle9 i Release 2: Using the DB!"#D Utility
$hanging %our Database #dentifier &DB#D' Only
$hanging %our Database ame &DB()!' Only
$hanging Both %our Database ame and Database #dentifier
Oracle9 i Release * and !arlier: $hanging %our Database ame
Viewing Screenshots
Move your mouse over this icon to show a screenshots! You can aso
move your mouse over each individua icon to see ony the screenshot
associated with it!

"verview
Bac+ to ,ist of To-ics
#n this lesson you will learn how to change the name of your database.
#f you are using Oracle9i Database Release 2 or a later release of Oracle
Database. you can use the DB!"#D database utility to change the database
name &DB()!' and the internal database identifier &DB#D' for an o-erational
database.
#f you are using a release -rior to Oracle9i Database Release 2. you can
change the database name &DB()!' by re/creating the control file.
Refer to the a--ro-riate section below de-ending on the release of Oracle you
are using:
Using the DB!"#D Utility to $hange the Database
ame
$hanging the Database ame
Note# Oracle $or-oration recommends that your database name and
OR($,!01#D be set to the same value in a single instance environment.

"race$i %eease &# 'sing the D(N)*ID 'tiity
Bac+ to ,ist of To-ics
%ou can use the DB!"#D database utility to change the internal database
identifier &DB#D' and the database name &DB()!' for an o-erational
database. The DB!"#D database utility is available with Oracle9i Database
Release 2.
2rior to the introduction of the DB!"#D utility. you could manually create a
co-y of a database and give it a new database name &DB()!' by re/creating
the control file. 3owever. you could not give the database a new identifier
&DB#D'. The DB#D is an internal. uni4ue identifier for a database. Because
Recovery )anager &R)(' distinguishes databases by DB#D. you could not
register a seed database and a manually co-ied database together in the same
R)( re-ository. The DB!"#D utility solves this -roblem by allowing you to
change any of the following:
Only the DB#D of a database
Only the DB()! of a database
Both the DB()! and DB#D of a database
"hen the DB#D of a database is changed. all -revious bac+u-s and archived
logs of the database become unusable. (fter you change the DB#D. you must
o-en the database with the R!1!T,O51 o-tion. This re/creates the online
redo log files and resets their se4uence to *. $onse4uently. you should ma+e a
bac+u- of the whole database immediately after changing the DB#D.
$hanging the DB()! without changing the DB#D does not re4uire you to
o-en with the R!1!T,O51 o-tion. so database bac+u-s and archived logs are
not invalidated. 3owever. changing the DB()! does have conse4uences.
%ou must change the DB0()! initiali6ation -arameter after a database name
change to reflect the new name. (lso. you may have to re/create the Oracle
-assword file. #f you restore an old bac+u- of the control file &before the name
change'. then you should use the initiali6ation -arameter file and -assword file
from before the database name change.

Changing Your Database Identifier +D(ID, "ny
Bac+ to ,ist of To-ics
%ou can change the DB#D by com-leting the following ste-s:
-!
)a+e a whole database bac+u-.

&!
#nvo+e 17,82lus and connect as a user with 1%1DB( -rivileges.

.!
#ssue the following 4uery to determine the current DB#D:
SELECT dbid, name
FROM v$database;

/!
1hut down the instance using the NORMAL. IMMEDIATE. or TRANSACTIONAL
o-tions:
SHUTDOWN IMMEDIATE

0!
1tart the instance and mount the database. s-ecifying the -arameter file if you are
not using a server -arameter file or the te9t initiali6ation -arameter file is not in the
default location:
ST1%T'P M"'NT

2!
#nvo+e the DB!"#D utility on the command line. s-ecifying a valid user with the
1%1DB( -rivilege. The DB!"#D utility -erforms validations of the headers of the
data files and control files before attem-ting #:O to the files. #f validation is
successful. then DB!"#D -rom-ts you to confirm the o-eration unless you s-ecify
a log file. changes the DB#D for each data file &including offline normal and read/only
data files'. and then e9its. The database is left mounted but is not yet usable.
nid T1%3)T4SYS5secure67service8name9

:!
(fter DB!"#D successfully changes the DB#D. shut down the instance:
S;'TD"*N IMM)DI1T)

<!
$reate a new -assword file using the OR(2"D utility:
orapwd fie4orapw7SID9 password47your password9 entries4

$!
1tart the instance and mount the database:
ST1%T'P M"'NT=

->!
O-en the database with the R!1!T,O51 o-tion:
1?T)% D1T1(1S) "P)N %)S)T?"3S=

--!
;erify the change to the DB#D by issuing the following 4uery:
SELECT dbid, name
FROM v$database;

-&!
)a+e a new database bac+u-. Because you reset the online redo logs. the old
bac+u-s and archived logs are no longer usable in the current incarnation of the
database.

Changing Your Database Name +D(N1M), "ny
Bac+ to ,ist of To-ics
%ou can change the DB()! by com-leting the following ste-s:

-!
)a+e a whole database bac+u-.

&!
#nvo+e 17,82lus and connect as a user with 1%1DB( -rivileges.

.!
#ssue the following 4uery to determine the current database name:
SELECT name
FROM v$database;

/!
1hut down the instance using the NORMAL. IMMEDIATE. or TRANSACTIONAL
o-tions:
SHUTDOWN IMMEDIATE

0!
1tart the instance and mount the database. s-ecifying the -arameter file if you are
not using a server -arameter file or the te9t initiali6ation -arameter file is not in the
default location:
ST1%T'P M"'NT

2!
#nvo+e the DB!"#D utility on the command line. s-ecifying a valid user with the
1%1DB( -rivilege. %ou must s-ecify the DB()! -arameter and su--ly your new
database name. %ou must also s-ecify the YES value for the SETNAME -arameter to
indicate that only the DB()! is to be changed. DB!"#D -erforms validations of
the headers of the control files. but not the data files. before attem-ting #:O to the
files. #f validation is successful. then DB!"#D -rom-ts for confirmation. changes
the database name in the control files. and e9its. (fter DB!"#D com-letes
successfully. the database is left mounted but is not yet usable.
nid T1%3)T47username957password967servicename9
D(N1M)47newname9 S)TN1M)4Y)S

:!
(fter DB!"#D successfully changes the database name. shut down the instance:
S;'TD"*N IMM)DI1T)

<!
$hange the DB0()! initiali6ation -arameter to your new database name.

$!
$reate a new -assword file using the OR(2"D utility:
orapwd fie4orapw7SID9 password47your password9 entries4

->!
1tart the instance and o-en the database:
ST1%T'P

--!
;erify the change to the database name by issuing the following 4uery:
SELECT name
FROM v$database;

Changing (oth Your Database Name and Database Identifier
Bac+ to ,ist of To-ics
%ou can change the DB()! by com-leting the following ste-s:
-!
)a+e a whole database bac+u-.

&!
#nvo+e 17,82lus and connect as a user with 1%1DB( -rivileges.

.!
#ssue the following 4uery to determine the current database identifier and database
name:
SELECT dbid, name
FROM v$database;

/!
1hut down the instance using the NORMAL. IMMEDIATE. or TRANSACTIONAL
o-tions:
SHUTDOWN IMMEDIATE

0!
1tart the instance and mount the database. s-ecifying the -arameter file if you are
not using a server -arameter file or the te9t initiali6ation -arameter file is not in the
default location:
ST1%T'P M"'NT

2!
#nvo+e the DB!"#D utility on the command line. s-ecifying a valid user with the
1%1DB( -rivilege. %ou must s-ecify the DB()! -arameter and su--ly your new
database name. DB!"#D -erforms validations of the headers of the control files
and the data files before attem-ting #:O to the files. #f validation is successful. then
DB!"#D -rom-ts you to confirm the o-eration unless you s-ecify a log file.
changes the DB#D for each data file &including offline normal and read only files'.
changes the database name in the control file. and e9its. (fter DB!"#D com-letes
successfully. the database is left mounted but is not yet usable.
nid T1%3)T47username957password967service name9 D(N1M)47new
name9

:!
(fter DB!"#D successfully changes the database identifier and database name.
shut down the instance:
S;'TD"*N IMM)DI1T)

<!
$hange the DB0()! initiali6ation -arameter to your new database name.

$!
$reate a new -assword file using the OR(2"D utility:
orapwd fie4orapw7SID9 password47your password9 entries4

->!
1tart the instance and mount the database:
ST1%T'P M"'NT

--!
O-en the database with the RESETLOGS o-tion:
1?T)% D1T1(1S) "P)N %)S)T?"3S=

--!
;erify the change to the database name and database identifier by issuing the
following 4uery:
SELECT name, dbid
FROM v$database;

-&!
)a+e a new database bac+u-. Because you reset the online redo logs. the old
bac+u-s and archived logs are no longer usable in the current incarnation of the
database.

"race$i %eease - and )arier# Changing the Database Name
Bac+ to ,ist of To-ics
%ou can change the Database ame by com-leting the following ste-s:
-!
#nvo+e 17,82lus and connect as a user with 1%1DB( -rivilege.

&!
#ssue the following 4uery to determine the current database name:
SELECT name
FROM v$database;

.!
#ssue the following command to force a chec+-oint:
ALTER SYSTEM CHEC!OINT;

/!
#ssue the following command to create a trace file containing the statements to re/
create the control file:
ALTER DATA"ASE "ACU! CONTROLFILE TO TRACE RESETLO#S;

0!
,ocate the trace file created in ste- <. The trace file will be in the location s-ecified
by the USER_DUMP_DEST initiali6ation -arameter. The file will be named
ora_NNNN.trc. %ou can find the value of USER_DUMP_DEST by issuing the
following command:
S;"* P1%1M)T)% 'S)%8D'MP8D)ST

2!
$hange the value of the DB_NAME initiali6ation -arameter to your new database
name.


:!
1hut down the instance using the NORMAL. IMMEDIATE. or TRANSACTIONAL
o-tions:
S;'TD"*N IMM)DI1T)

<!
$o-y the contents of the trace file beginning with the STARTUP NOMOUNT command
to a new file. =or the -ur-oses of this e9am-le. assume you have named the new
file ccf.sql.

$!
!dit your ccf.sql file and ma+e the following changes:
Remove all of the comment lines. %our scri-t should begin with the CREATE
CONTROLFILE statement.
$hange:
CREATE CONTROLFILE REUSE DATABASE "ol!"a#$" RESETLOGS
To:
CREATE CONTROLFILE SET DATABASE "ne$dbname" RESETLOGS
Remove the RECO%ER DATABASE USING BAC&UP CONTROLFILE statement:

->!
Rename your e9isting control files to -rovide a bac+u-.

--!
#nvo+e 17,82lus and connect as a user with 1%1DB( -rivileges.

-&!
!9ecute your ccf.sql scri-t to re/create the control file. The scri-t starts the
instance in O)OUT mode and re/creates the control file. The scri-t o-ens the
database.
%&&' (E)e&*ta+,- a man- . t+as ,a ent+ada RECO/ER DATA"ASE
USIN# "ACU! CONTROLFILE in&,*i+ ,a +*ta de *n- de ,-s
+ed-,-0s1

-.!
$hange your global database name if re4uired by issuing the following command.
ALTER DATA"ASE
RENAME #LO"AL2NAME t- 3ne$dbname453d-main4;

-/!
;erify your changes by issuing the following 4uery to find the current value of
DB_NAME:
SELECT name FROM v$database;

-0!
)a+e a whole consistent &full or com-lete' database bac+u- using Recovery
)anager &R)(' or o-erating system commands.

Move your mouse over this icon to hide a screenshots

Das könnte Ihnen auch gefallen