Thursday 13 February 2020

How to change database DB name using NID utility

Hi DBA-Mates, Hope you all are doing Well!!!
We are back with how to change database DB name using NID utility.

Thank you all a lot for yours email as I was away for times because of some personal works.
It is very easy and simple but we are sure that very few people may have performed this activity, so it will be useful for those who has only read.

Note: If not sure about sys password, it can be set as either orapwd file or below command:

$sqlplus '/as sysdba'

SQL> alter user sys identified by sys;
User altered.

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

SQL> startup mount;
ORACLE instance started.

Total System Global Area  456146944 bytes
Fixed Size                  1344840 bytes
Variable Size             356518584 bytes
Database Buffers           92274688 bytes
Redo Buffers                6008832 bytes
Database mounted.
SQL>

SQL> select name,open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
ORCL      MOUNTED

SQL>

Command:

[oracle@localhost bin]$ nid TARGET=sys/<sys password>@<Service/old_dbname> DBNAME=<DB New Name> SETNAME=YES

Query:

[oracle@localhost bin]$ nid TARGET=sys/sys@ORCL DBNAME=ORCLNEW SETNAME=YES

DBNEWID: Release 11.2.0.2.0 - Production on Sat Feb 1 22:41:13 2020

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

Connected to database ORCL (DBID=1229390655)

Connected to server version 11.2.0

Control Files in database:
    /home/oracle/app/oracle/oradata/orcl/control01.ctl
    /home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl

Change database name of database ORCL to ORCLNEW? (Y/[N]) => Y

Proceeding with operation
Changing database name from ORCL to ORCLNEW
    Control File /home/oracle/app/oracle/oradata/orcl/control01.ctl - modified
    Control File /home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl - modified
    Datafile /home/oracle/app/oracle/oradata/orcl/system01.db - wrote new name
    Datafile /home/oracle/app/oracle/oradata/orcl/sysaux01.db - wrote new name
    Datafile /home/oracle/app/oracle/oradata/orcl/undotbs01.db - wrote new name
    Datafile /home/oracle/app/oracle/oradata/orcl/users01.db - wrote new name
    Datafile /home/oracle/app/oracle/oradata/orcl/example01.db - wrote new name
    Datafile /home/oracle/app/oracle/oradata/orcl/APEX_1930613455248703.db - wrote new name
    Datafile /home/oracle/app/oracle/oradata/tbs1.db - wrote new name
    Datafile /home/oracle/app/oracle/oradata/tbs2.db - wrote new name
    Datafile /home/oracle/app/oracle/oradata/orcl/temp01.db - wrote new name
    Control File /home/oracle/app/oracle/oradata/orcl/control01.ctl - wrote new name
    Control File /home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl - wrote new name
    Instance shut down

Database name changed to ORCLNEW.
Modify parameter file and generate a new password file before restarting.
Succesfully changed database name.
DBNEWID - Completed succesfully.

[oracle@localhost bin]$

Change db name in pfile:

[oracle@localhost dbs]$ vi initorcl.ora

*.db_name='ORCLNEW'


SQL> startup mount
ORACLE instance started.

Total System Global Area  456146944 bytes
Fixed Size                  1344840 bytes
Variable Size             356518584 bytes
Database Buffers           92274688 bytes
Redo Buffers                6008832 bytes
Database mounted.

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01139: RESETLOGS option only valid after an incomplete database recovery


SQL> alter database open;

Database altered.

SQL>

SQL> select name,open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
ORCLNEW   READ WRITE

Hope this may helpful and useful.
Regards,