Skip to main content

Oracle DBNEWID Utility: How to Change a Database Name

Oracle DBNEWID utility for changing database name overview

Introduction

DBNEWID (nid) is an Oracle utility that changes the internal database identifier (DBID) and the database name (DBNAME) of an operational database. This is useful when cloning or duplicating a database that needs to coexist with the original, since two databases with the same DBID and name can cause conflicts in areas like RMAN cataloging and Data Guard. This guide walks through using DBNEWID to change a database name, step by step.

Ramifications of Changing the DBID and DBNAME

Before changing the DBID and DBNAME of a database with DBNEWID, review Oracle's official guidelines. Once you change the DBID or DBNAME, existing backups and archived logs taken before the change can no longer be used to recover the database, since they were created under the old identity. Plan for a fresh backup immediately afterward.

Syntax

  • To change both DBID and DBNAME: nid TARGET=sys/password@orcl DBNAME=orcl2
  • To change only the DBNAME: nid TARGET=sys/password@orcl DBNAME=orcl2 SETNAME=YES
  • To change only the DBID: nid TARGET=sys/password@orcl

Prerequisites

  • Plan for roughly 30 minutes of database downtime.
  • Take a full RMAN backup beforehand, so you can roll back if something goes wrong mid-process.

Environment Used in This Guide

  • Hostname: apex
  • IP: 192.168.101.7
  • ORACLE_SID: APEXDB
  • DB Name: APEX (before the change)

The rest of this guide walks through changing only the DBNAME, using the SETNAME=YES syntax from above.

Step 1: Check the Current DB Status and Create a Pfile

Confirm the database's current DBID and name before making any changes, and create a pfile from the spfile. We'll need this pfile in Step 4 to update the db_name parameter after DBNEWID completes.


SQL> select DBID, NAME, open_mode, database_role from v$database;

DBID        NAME      OPEN_MODE    DATABASE_ROLE
----------- --------- ------------ ---------------
3003259501  APEX      READ WRITE   PRIMARY

SQL> create pfile='/home/oracle/pfilebkp.ora' from spfile;
File created.

SQL> exit

Step 2: Shut Down and Start the Database in Mount Mode

DBNEWID needs the database mounted but not open, since it rewrites identifying information in the control files and datafile headers while the database is offline.


SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount
ORACLE instance started.
Total System Global Area 1560280200 bytes
Fixed Size                  9178248 bytes
Variable Size            1342177280 bytes
Database Buffers          201326592 bytes
Redo Buffers                7598080 bytes
Database mounted.

SQL> select DBID, NAME, open_mode, database_role from v$database;
DBID        NAME      OPEN_MODE    DATABASE_ROLE
----------- --------- ------------ ----------------
3003259501  APEX      MOUNTED      PRIMARY

SQL>

Step 3: Run NID to Change the Database Name

Here we change the database name from APEX to APEXDB using SETNAME=YES, which changes only the name and leaves the DBID untouched. DBNEWID rewrites the name into the control files and every datafile header, you can see it working through each file below.


[oracle@apex ~]$ nid TARGET=/ DBNAME=apexdb SETNAME=YES

DBNEWID: Release 19.0.0.0.0 - Production on Thu Mar 6 20:28:05 2025

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

Connected to database APEX (DBID=3003259501)

Connected to server version 19.24.0
Control Files in database:
    /u02/app/oracle/oradata/APEXDB/control01.ctl
    /u02/app/oracle/fast_recovery_area/APEXDB/control02.ctl

Change database name of database APEX to APEXDB? (Y/[N]) => Y
Proceeding with operation
Changing database name from APEX to APEXDB
    Control File /u02/app/oracle/oradata/APEXDB/control01.ctl - modified
    Control File /u02/app/oracle/fast_recovery_area/APEXDB/control02.ctl - modified
    Datafile /u02/app/oracle/oradata/APEXDB/system01.db - wrote new name
    Datafile /u02/app/oracle/oradata/APEXDB/sysaux01.db - wrote new name
    Datafile /u02/app/oracle/oradata/APEXDB/undotbs01.db - wrote new name
    Datafile /u02/app/oracle/oradata/APEXDB/pdbseed/system01.db - wrote new name
    Datafile /u02/app/oracle/oradata/APEXDB/pdbseed/sysaux01.db - wrote new name
    Datafile /u02/app/oracle/oradata/APEXDB/users01.db - wrote new name
    Datafile /u02/app/oracle/oradata/APEXDB/pdbseed/undotbs01.db - wrote new name
    Datafile /u02/app/oracle/oradata/APEXDB/apexpdb/system01.db - wrote new name
    Datafile /u02/app/oracle/oradata/APEXDB/apexpdb/sysaux01.db - wrote new name
    Datafile /u02/app/oracle/oradata/APEXDB/apexpdb/undotbs01.db - wrote new name
    Datafile /u02/app/oracle/oradata/APEXDB/apexpdb/users01.db - wrote new name
    Datafile /u02/app/oracle/oradata/APEXDB/apexpdb/apex232_01.db - wrote new name
    Datafile /u02/app/oracle/oradata/APEXDB/apexpdb/apex241_01.db - wrote new name
    Datafile /u02/app/oracle/oradata/APEXDB/apexpdb/test01.db - wrote new name
    Datafile /u02/app/oracle/oradata/APEXDB/apexpdb/statpack01.db - wrote new name
    Datafile /u02/app/oracle/oradata/APEXDB/temp01.db - wrote new name
    Datafile /u02/app/oracle/oradata/APEXDB/pdbseed/temp012024-09-25_00-10-37-758-AM.db - wrote new name
    Datafile /u02/app/oracle/oradata/APEXDB/apexpdb/temp01.db - wrote new name
    Control File /u02/app/oracle/oradata/APEXDB/control01.ctl - wrote new name
    Control File /u02/app/oracle/fast_recovery_area/APEXDB/control02.ctl - wrote new name
    Instance shut down

Database name changed to APEXDB.
Modify parameter file and generate a new password file before restarting.
Successfully changed database name.
DBNEWID - Completed successfully.

Notice the closing message: DBNEWID explicitly tells you to modify the parameter file and generate a new password file before restarting. The next two steps do exactly that.

Step 4: Update the Pfile and Start With It

Edit the pfile you created in Step 1, changing db_name from the old value to the new one, then start the instance directly from this pfile to confirm the change took effect before making it permanent.


[oracle@apex ~]$ cat pfilebkp.ora
apexdb.__data_transfer_cache_size=0
apexdb.__db_cache_size=150994944
apexdb.__inmemory_ext_roarea=0
apexdb.__inmemory_ext_rwarea=0
apexdb.__java_pool_size=184549376
apexdb.__large_pool_size=16777216
apexdb.__oracle_base='/u02/app/oracle' #ORACLE_BASE set from environment
apexdb.__pga_aggregate_target=536870912
apexdb.__sga_target=1023410176
apexdb.__shared_io_pool_size=50331648
apexdb.__shared_pool_size=603979776
apexdb.__streams_pool_size=0
apexdb.__unified_pga_pool_size=0
*.archive_lag_target=1200
*.audit_file_dest='/u02/app/oracle/admin/apexdb/adump'
*.audit_trail='db'
*.compatible='19.0.0'
*.control_files='/u02/app/oracle/oradata/APEXDB/control01.ctl','/u02/app/oracle/fast_recovery_area/APEXDB/control02.ctl'
*.db_block_size=8192
*.db_file_name_convert='/u02','/u01'
*.db_name='apexdb'
*.db_recovery_file_dest='/u02/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=12732m
*.db_unique_name='APEXDBDC'
*.diagnostic_dest='/u02/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=apexdbXDB)'
*.enable_pluggable_database=true
*.log_archive_max_processes=30
*.memory_target=1476m
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'

[oracle@apex ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Thu Mar 6 20:30:19 2025
Version 19.24.0.0.0

Copyright (c) 1982, 2024, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup pfile='/home/oracle/pfilebkp.ora';
ORACLE instance started.

Total System Global Area 1560280200 bytes
Fixed Size                  9178248 bytes
Variable Size            1342177280 bytes
Database Buffers          201326592 bytes
Redo Buffers                7598080 bytes
Database mounted.
Database opened.

SQL> select DBID, NAME, open_mode, database_role from v$database;

DBID        NAME      OPEN_MODE            DATABASE_ROLE
----------- --------- -------------------- ----------------
3003259501  APEXDB    READ WRITE           PRIMARY

SQL>

The DBID stayed the same (3003259501), only the name changed, exactly as expected since we used SETNAME=YES rather than the default full-change syntax.

Step 5: Create an Spfile and Restart With It

Once you've confirmed the pfile works correctly, generate an spfile from it so the change persists cleanly across future restarts, rather than continuing to rely on a pfile long-term.


SQL> create spfile from pfile='/home/oracle/pfilebkp.ora';

File created.

SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup
ORACLE instance started.

Total System Global Area 1560280200 bytes
Fixed Size                  9178248 bytes
Variable Size            1342177280 bytes
Database Buffers          201326592 bytes
Redo Buffers                7598080 bytes
Database mounted.
Database opened.

SQL> select DBID, NAME, open_mode, database_role from v$database;

DBID        NAME      OPEN_MODE            DATABASE_ROLE
----------- --------- -------------------- ----------------
3003259501  APEXDB    READ WRITE           PRIMARY

SQL>

Step 6: Update Network Configuration and Take a Fresh Backup

Finally, update the database name references in listener.ora and tnsnames.ora, then reload the listener so client connections resolve correctly under the new name. Just as important, take a full database backup now, since anything backed up before this change is tied to the old database identity and won't be usable for recovery going forward.

Thank you for reading!

I hope this content has been helpful to you. Your feedback and suggestions are always welcome. Feel free to leave a comment or reach out with any queries.

Abhishek Shrivastava

Oracle DBA with hands-on experience managing production Data Guard, RAC, GoldenGate, and APEX environments. I write practical, tested installation and troubleshooting guides based on real deployment work.

📧 Email: oraeasyy@gmail.com
🌐 Website: www.oraeasy.com

Follow Us

Comments