"What
befalls the earth befalls all the sons of the earth. This we
know: the earth does not belong to man, man belongs to the
earth. All things are connected like the blood that unites us
all. Man does not weave this web of life. He is merely a
strand of it. Whatever he does to the web, he does to
himself."
-Chief
Seattle (1786-1866)
|
How to change or
rename a database name
The following are steps to rename a
database name:
1. Login to sqlplus and backup the controlfile to trace.
$ sqlplus /nolog
$ SQL> connect / as sysdba
$ SQL> alter database backup controlfile to trace;
2. Shutdown your databse.
$ SQL> connect / as sysdba
$ SQL> shutdown immediate;
3. Copy the content of your backup
controlfile to a file and
call it "rename-my-database.sql" or rename it.
4. Rename all your controlfiles.
$ mv /u02/oradata/mydb/control_01
.ctl /u02/oradata/mydb/control_01
.ctl.old
$ mv /u03/oradata/mydb/control_02
.ctl /u03/oradata/mydb/control_02
.ctl.old
Rename all your controlfiles you have. To find their location, do
the following:
$ SQL> connect / as sysdba
$ SQL> select name from v$controlfile;
NAME
------------------------------
------------------------------
--------------------
/u06/oradata/mydb/control01.ctl
/u02/oradata/mydb/control02.ctl
/u03/oradata/mydb/control03.ctl
5. Change the folloing parameter in your
CREATE CONTROLFILE statement.
you may have something like this:
CREATE CONTROLFILE REUSE DATABASE "mydb" NORESETLOGS
ARCHIVELOG
changs:
CREATE CONTROLFILE SET DATABASE
"mynewdb" RESETLOGS
ARCHIVELOG
6. Make sure your init file points to
your new database and instance.
*.db_name='mynewdb'
*.instance_name='mynewdb'
7. Connect to sqlplus as sysdba and then
run the "rename-my-database.sql" script.
$ SQL> connect / as sysdba
$ SQL> startup nomount pfile=
init.ora
$ SQL> @rename-my-database.sql
How to clone a
database from my server to another to a different server
The following are steps to clone a database from one server to
another:
1. Login to sqlplus and backup the controlfile to trace, data files,
tempfile, and redolog files.
$ sqlplus /nolog
$ SQL> connect / as sysdba
$ SQL> alter database backup controlfile to trace;
SQL> select name from v$datafile;
NAME
------------------------------
-------------------
/u04/oradata/mydb/system01.dbf
/u04/oradata/mydb/indx01.dbf
...
SQL> select member from v$logfile;
MEMBER
------------------------------
-------------------
/u02/oradata/servicet/redo03
.log
/u02/oradata/servicet/redo02
.log
...
SQL> select name from v$tempfile;
NAME
------------------------------
-------------------
/u02/oradata/servicet/temp01
.dbf
Now, you can shutdown down your database and do your cold backup.
$ SQL> connect / as sysdba
$ SQL> shutdown immediate
Copy all above files to your remote server and locat host where you
want to
have your clone.
Then, start your database.
$ SQL> connect / as sysdba
$ SQL> startup
2. Shutdown your database.
$ SQL> connect / as sysdba
$ SQL> shutdown immediate;
3. Now, you can repeat the process the same as renaming a database.
|