Oracle 11g is a widely used relational database management system known for its stability and robustness. One common question among DBAs and developers is whether the global database name can be changed after the database has been created.
The global database name is a key identifier for the database instance and is critical for network connectivity and database operations.
a detailed step-by-step guide on how to perform the change safely if it is possible.
What is the Global Database Name?
The global database name is a unique name used to identify an Oracle database across a network. It is composed of two parts:
- Database name (DB_NAME): The primary name of the database.
- Database domain (DB_DOMAIN): The domain or network location.
Combined, the global database name usually looks like this: DB_NAME.DB_DOMAIN.
The global database name is stored in the
DB_NAMEandDB_DOMAINinitialization parameters and is used internally by Oracle to manage network connections and database uniqueness.
Location and Usage
The global database name appears in various places including:
- The
GLOBAL_NAMEparameter in the database. - The
TNSNAMES.ORAfiles used for client connection configuration. - Oracle Net services and listener configurations.
It is fundamental to Oracle’s distributed database architecture and must be unique for each database in a network.
Can You Change the Global Database Name in Oracle 11g?
Short answer: Yes, it is possible to change the global database name in Oracle 11g, but it requires careful steps and planning.
Changing the global database name is not a trivial operation because it affects:
- Database identification
- Network connectivity
- Replication and distributed database setups
- Backup and recovery configurations
Improper changes can lead to connectivity errors, service disruptions, or data inconsistencies.
Reasons to Change the Global Database Name
| Reason | Description |
|---|---|
| Rebranding | Company or project name changes requiring database identifiers to be updated. |
| Environment Cloning | Creating test or development copies of a database with unique names. |
| Domain Changes | Network restructuring or domain migrations affecting database domain names. |
| Consolidation | Merging databases or realigning naming conventions. |
Important Considerations Before Proceeding
Before changing the global database name, consider the following points carefully:
- Backup your database: Always take a full backup including control files, datafiles, and parameter files.
- Identify dependencies: Applications, services, and scripts might depend on the current global database name.
- Check network configurations: TNS and listener files must be updated accordingly after the change.
- Test in a non-production environment: Validate the procedure on a test system before applying in production.
- Inform stakeholders: Notify users and other teams about planned downtime or service interruptions.
Step-by-Step Guide to Changing the Global Database Name in Oracle 11g
The process involves several key steps, including updating initialization parameters, recreating control files, and modifying network configuration files.
Verify Current Global Database Name
Connect to the database as SYSDBA and run the following query:
SELECT * FROM global_name;
This will return the current global database name (e.g., ORCL.example.com).
Shutdown the Database
It is important to stop the database cleanly before making any changes:
SQL> SHUTDOWN IMMEDIATE;
Backup Existing Files
Backup the following files:
- Parameter files (
init.oraorspfile.ora) - Control files
- Datafiles
- Redo log files
Update Initialization Parameter for DB_NAME and DB_DOMAIN
The global database name is formed by concatenating the DB_NAME and DB_DOMAIN parameters.
To check current values, run:
SHOW PARAMETER db_name;
SHOW PARAMETER db_domain;
To change these parameters, you need to edit the initialization parameter file (if using a text init.ora file) or create a new server parameter file (spfile) with updated values.
Example:
DB_NAME=NEWDB
DB_DOMAIN=example.com
Important: You cannot change these parameters dynamically; they must be set before database startup.
Create a New Control File
The control file contains the database name. You must recreate control files to reflect the new global database name.
Steps:
- Start the database in
MOUNTmode:
SQL> STARTUP MOUNT;
- Generate the new control file creation script:
SQL> ALTER DATABASE BACKUP CONTROLFILE TO TRACE;
This command writes a control file creation script into the trace directory.
- Edit the generated trace file:
Locate the CREATE CONTROLFILE statement and modify the DATABASE clause to use the new database name:
CREATE CONTROLFILE REUSE DATABASE "NEWDB" NORESETLOGS NOARCHIVELOG
...
Also, update all file paths if needed.
- Shutdown the database:
SQL> SHUTDOWN IMMEDIATE;
- Start the database in nomount mode:
SQL> STARTUP NOMOUNT;
- Run the edited control file creation script from SQL*Plus.
@/path/to/edited_controlfile_script.sql
- Open the database with the
RESETLOGSoption:
SQL> ALTER DATABASE OPEN RESETLOGS;
Update the GLOBAL_NAME Parameter
Once the database is open, update the GLOBAL_NAME to reflect the new global database name:
SQL> ALTER SYSTEM SET GLOBAL_NAME='NEWDB.example.com' SCOPE=BOTH;
Verify the change:
SELECT * FROM global_name;
Update Network Configuration Files
To ensure client connectivity, update the following files:
tnsnames.ora: Update service names to use the new global database name.listener.ora: Ensure the listener recognizes the new database name.- Any connection strings or application configurations referencing the old name.
Restart Listener and Test Connections
Restart the Oracle Listener to apply new configurations:
lsnrctl stop
lsnrctl start
Test connectivity from client machines:
tnsping NEWDB
sqlplus user/password@NEWDB
Summary of Key Commands
| Action | Command / Description |
|---|---|
| Check current global name | SELECT * FROM global_name; |
| Shutdown database | SHUTDOWN IMMEDIATE; |
| Backup control file to trace | ALTER DATABASE BACKUP CONTROLFILE TO TRACE; |
| Start database in mount mode | STARTUP MOUNT; |
| Create control file script (edit) | Edit CREATE CONTROLFILE with new DB name |
| Create control file | Start in nomount and run script |
| Open database with resetlogs | ALTER DATABASE OPEN RESETLOGS; |
| Set global_name | ALTER SYSTEM SET GLOBAL_NAME='NEWDB.example.com' SCOPE=BOTH; |
| Restart listener | lsnrctl stop/start |
Common Issues and Troubleshooting
Database Won’t Open After Control File Recreation
This usually happens if the control file script was not edited correctly or if file paths are incorrect. Double-check the control file creation script for correct database name and paths.
Clients Cannot Connect
Ensure that tnsnames.ora and listener.ora files are updated, and that the listener service is running. Also, confirm that the new service name matches the changed global database name.
ORA-12154: TNS:could not resolve the connect identifier specified
This error indicates a naming resolution problem. Verify the client tnsnames.ora file and make sure the new database name is properly defined.
Additional Tips
- Use a text
init.orafile for easier editing instead of anspfileif unfamiliar withspfileoperations. - Document every change step and maintain logs for audit and rollback purposes.
- Consider downtime windows carefully to minimize impact on users.
- Review Oracle support notes and patches related to database renaming for your exact Oracle 11g version.
Expert advice: Always test the entire renaming procedure on a cloned test database before performing it on production systems.
Conclusion
Changing the global database name in Oracle 11g is achievable but requires a clear understanding of Oracle internals and careful execution. The process involves updating initialization parameters, recreating control files with the new database name, adjusting network configurations, and performing thorough testing.
Given the complexity and risks, ensure that you have full backups, inform stakeholders, and ideally practice the procedure in a test environment. By following the structured approach outlined above, database administrators can successfully rename their Oracle 11g global database name without disrupting business operations.
If in doubt, consult Oracle’s official documentation or seek assistance from Oracle support to avoid potential pitfalls.