Thursday, August 14, 2008

"Refreshed" database files naming

I have been doing many "refreshes" last days.
One of scenarios is to refresh a development
or test database from backup of production database.
The databases are on ASM and names consist dev
or test or prod in them.

Nothing difficult about it - get backup restored to disk,
start instance in nomount mode, restore controlfiles,
catalog backupsets, restore and recover database and open it.
And rename a database after the procedure using nid utility.

But the thing is that if you restore a database from
backup to OMF destination as ASM or file system,
oracle will use database name (if db_unique_name
is not set to something different) to name folders
where datafiles are going to be.
That means files will appear in folders named as source database
and will have "prod" or "prd" (or whatever the pattern is)
in folder names.

It can be nothing bad with it, but if you are going to restore
the same database under different name on the same server
you will get problem. Not to mention violation of all standards.
And also even after successful open of restored database
and its renaming you will have all files staying at the same place.

So if you would like to avoid it put db_name as source one
to you initialization file and add db_unique_name set to the name
of what database will be renamed to later. This will help
to restore datafiles to right location and you will need
just to rename the database afterwards.

Have a good day!

No comments: