Steps To Change DB NAME And DBID


STEP 1: Create blackout for the database

STEP 2: Set cluster_database parameter to false

SQL> show parameter cluster_database

NAME                                            TYPE      VALUE

------------------------------------ ----------- ------------------------------

cluster_database                boolean  TRUE

cluster_database_instances       integer   2

SQL> alter system set cluster_database=false scope=spfile sid='*';

System altered.

SQL> show parameter db_unique_name

NAME                                            TYPE      VALUE

------------------------------------ ----------- ------------------------------

db_unique_name                                   string     ORA_PRIM


STEP 3: Start only one instance in mount mode

[oracle@oratest1 ~]$ srvctl stop database -d ORA_PRIM

[oracle@oratest1 ~]$ srvctl status database -d ORA_PRIM

Instance ORAPRIM1 is not running on node oratest2

Instance ORAPRIM2 is not running on node oratest1

[oracle@oratest1 ~]$ sqlplus "/as sysdba"

 SQL*Plus: Release 19.0.0.0.0 - Production on Sun Sep 29 10:47:57 2024

Version 19.3.0.0.0

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

 Connected to an idle instance.

 SQL> startup mount

ORACLE instance started.

Total System Global Area 2751459792 bytes

Fixed Size                 9138640 bytes

Variable Size                    637534208 bytes

Database Buffers 2097152000 bytes

Redo Buffers                      7634944 bytes

Database mounted.


STEP 4: Execute nid utility to change the DBNAME

[oracle@oratest1 ~]$ nid TARGET=SYS DBNAME=UK_PRIM

 DBNEWID: Release 19.0.0.0.0 - Production on Sun Sep 29 10:50:48 2024

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

Password:

Connected to database ORA_PRIM (DBID=750851884)

Connected to server version 19.3.0

Control Files in database:

    +DATA/ORA_PRIM/CONTROLFILE/current.264.1180617197

    +DATA/ORA_PRIM/CONTROLFILE/current.263.1180617197

Change database ID and database name ORA_PRIM to UK_PRIM? (Y/[N]) => Y

Proceeding with operation

Changing database ID from 750851884 to 846718669

Changing database name from ORA_PRIM to UK_PRIM

    Control File +DATA/ORA_PRIM/CONTROLFILE/current.264.1180617197 - modified

    Control File +DATA/ORA_PRIM/CONTROLFILE/current.263.1180617197 - modified

    Datafile +DATA/ORA_PRIM/DATAFILE/system.259.118061707 - dbid changed, wrote new name

    Datafile +DATA/ORA_PRIM/DATAFILE/sysaux.260.118061710 - dbid changed, wrote new name

    Datafile +DATA/ORA_PRIM/DATAFILE/undotbs1.261.118061713 - dbid changed, wrote new name

    Datafile +DATA/ORA_PRIM/86B637B62FE07A65E053F706E80A27CA/DATAFILE/system.270.118061740 - dbid changed, wrote new name

    Datafile +DATA/ORA_PRIM/86B637B62FE07A65E053F706E80A27CA/DATAFILE/sysaux.271.118061740 - dbid changed, wrote new name

    Datafile +DATA/ORA_PRIM/DATAFILE/users.262.118061713 - dbid changed, wrote new name

    Datafile +DATA/ORA_PRIM/86B637B62FE07A65E053F706E80A27CA/DATAFILE/undotbs1.272.118061740 - dbid changed, wrote new name

    Datafile +DATA/ORA_PRIM/DATAFILE/undotbs2.274.118061767 - dbid changed, wrote new name

    Datafile +DATA/ORA_PRIM/22EDFFF300C9602EE0630701A8C01F01/DATAFILE/system.283.118061816 - dbid changed, wrote new name

    Datafile +DATA/ORA_PRIM/22EDFFF300C9602EE0630701A8C01F01/DATAFILE/sysaux.284.118061816 - dbid changed, wrote new name

    Datafile +DATA/ORA_PRIM/22EDFFF300C9602EE0630701A8C01F01/DATAFILE/undotbs1.282.118061816 - dbid changed, wrote new name

    Datafile +DATA/ORA_PRIM/22EDFFF300C9602EE0630701A8C01F01/DATAFILE/undo_2.286.118061819 - dbid changed, wrote new name

    Datafile +DATA/ORA_PRIM/22EDFFF300C9602EE0630701A8C01F01/DATAFILE/users.287.118061819 - dbid changed, wrote new name

    Datafile +DATA/ORA_PRIM/TEMPFILE/temp.269.118061721 - dbid changed, wrote new name

    Datafile +DATA/ORA_PRIM/22EDD25528C83F07E0630701A8C0B617/TEMPFILE/temp.273.118061742 - dbid changed, wrote new name

    Datafile +DATA/ORA_PRIM/22EDFFF300C9602EE0630701A8C01F01/TEMPFILE/temp.285.118061816 - dbid changed, wrote new name

    Control File +DATA/ORA_PRIM/CONTROLFILE/current.264.1180617197 - dbid changed, wrote new name

    Control File +DATA/ORA_PRIM/CONTROLFILE/current.263.1180617197 - dbid changed, wrote new name

    Instance shut down

Database name changed to UK_PRIM.

Modify parameter file and generate a new password file before restarting.

Database ID for database UK_PRIM changed to 846718669.

All previous backups and archived redo logs for this database are unusable.

Database is not aware of previous backups and archived logs in Recovery Area.

Database has been shutdown, open database with RESETLOGS option.

Succesfully changed database name and ID.

DBNEWID - Completed succesfully.

NOTE: If we type ‘Y’ while asking for DBID change then only in that case the nid utility change the DBID too and we usually perform this activity whenever we perform the DB refresh which basically copies the DB_NAME,DBID,DB_UNIQUE_NAME to from source environment.

STEP 5: Start only one instance in nomount mode and change db_name parameter

SQL> startup nomount

ORACLE instance started.

Total System Global Area 2751459792 bytes

Fixed Size                 9138640 bytes

Variable Size                    637534208 bytes

Database Buffers 2097152000 bytes

Redo Buffers                      7634944 bytes

 SQL> show parameter DB_NAME

NAME                                            TYPE      VALUE

------------------------------------ ----------- ------------------------------

db_name                             string     ORA_PRIM

SQL> alter system set db_name=UK_PRIM scope=spfile sid='*';

System altered.

STEP 6: Start only one instance in mount mode and open the database with resetlogs option

SQL> startup mount

ORACLE instance started.

Total System Global Area 2751459792 bytes

Fixed Size                 9138640 bytes

Variable Size                    637534208 bytes

Database Buffers 2097152000 bytes

Redo Buffers                      7634944 bytes

Database mounted.

SQL> alter database open resetlogs;

Database altered.


 STEP 7: Set cluster_database parameter to true and bring down the database

 SQL> alter system set cluster_database=true scope=spfile sid='*';

System altered.

SQL> shut immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

STEP 8: modify db_name at cluster level using srvctl

[oracle@oratest1 ~]$ srvctl modify database -db ORA_PRIM -dbname UK_PRIM

[oracle@oratest1 ~]$ 

[oracle@oratest1 ~]$ srvctl config database -db ORA_PRIM | grep -i "Database name"

Database name: UK_PRIM

STEP 9: Start database using srvctl utility

[oracle@oratest1 ~]$ srvctl start database -d ORA_PRIM

[oracle@oratest1 ~]$

[oracle@oratest1 ~]$ srvctl status database -d ORA_PRIM

Instance ORAPRIM1 is running on node oratest2

Instance ORAPRIM2 is running on node oratest1

 SQL> select inst_id,name,open_mode,status from v$database,gv$instance;

   INST_ID NAME      OPEN_MODE            STATUS

---------- --------- -------------------- ------------

      1 UK_PRIM   READ WRITE   OPEN

      2 UK_PRIM   READ WRITE   OPEN

 STEP 10:  Validate Remote Connectivity

STEP 11: Start L0 backup immediately

STEP 12: Remove Blackout

 


 

 

 

 

 

 

 

Post a Comment

Previous Post Next Post