Published by : Obay Salah , November 19, 2024

 Have you ever thought about changing the name of your database? No doubt you have thought about it, but how do you do it? Actually, it is very easy. Changing the name of the database requires modifying two files, the Parameter File and the Control File. Here are the steps:-

1- Verify the database name now by using the following query:

SELECT NAME FROM V$DATABASE;

The database name is now OBAY.


2- Now we change the database name to the File Control file. But the problem is that this file is not a text file so we can modify it,

It is a binary file, so we can resort to making a backup copy of this file as a Trace File

The result of this backup Trace File is a text file that contains code that can be used to create a new Control File,

It is also possible to modify this code. So we change the database name.

This file is located in the path defined in the variable user_dump_dest.

Now we perform the backup process.

ALTER DATABASE BACKUP CONTROLFILE TO TRACE; 

When you open this file, it will look like this:



What we care about in this file is what we have shaded, now we make a copy of this shaded part and save it in a new file and let's assume its name is Control.trc.

Of course, if we back up the Control File in the above way and then change the database configurations, for example, adding a Tablespace or Data File, we need to modify the Trace File with the new modifications if we use it to create a Control File.

The Control.trc file format is as follows:



This is the Control.trc file that we will use to create the new Control File, but before that we need to modify what you have highlighted as follows:-

Reuse -----SET

(OBAY -----TEST (NEW DATABASE NAME

NORESTLOGS ------RESTLOGS

After making these modifications we need to save.

3- We close the database.

SHUT IMMEDIATE;

4- Change the database name to the INITobay.ora file, which is the variables file (PFILE) that the current database works with.



Change the database name db_name from OBAY to TEST then save the changes.

5- Delete the current Control Files in the database.

6- Run the database in NOMOUNT mode.

STARTUP NOMOUNT; 

7- Now we create the File Control using the Trace File that we created previously.

SQL> @C:\CONTROL.TRC; 

8- Open the database in RESETLOGS mode.

ALTER DATABASE OPEN RESETLOGS; 

9- To make sure the database name is changed.

SELECT NAME FROM V$DATABASE; 

It should be remembered that the name of the INSTANCE has not changed. What we have changed is the name of the database.

Tags : Database

You May Also Like

Comments

no comment yet!