Skip to main content

Change CDB and PDB names in 12c

Change CDB name from DEVCDB to TESTCDB

*********************************************
Backup database before performing this action
*********************************************



	

SQL> SHUTDOWN IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> STARTUP MOUNT
ORACLE instance started.
Total System Global Area 2.0133E+10 bytes
Fixed Size                  3721176 bytes
Variable Size            2684356648 bytes
Database Buffers         1.7381E+10 bytes
Redo Buffers               63385600 bytes
Database mounted.
SQL> exit

[oracle@hostname ~]$ nid TARGET=/ DBNAME=TESTCDB
DBNEWID: Release 12.1.0.2.0 - Production on Fri Jul 1 12:44:48 2022
Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.
Connected to database DEVCDB (DBID=2721637057)
Connected to server version 12.1.0
Control Files in database:
    /oradata/devcdb/oradata/DEVCDB/controlfile/o1_mf_kcx8zx9n_.ctl
    /oradata/devcdb/fast_recovery_area/DEVCDB/controlfile/o1_mf_kcx8zxcj_.ctl
Change database ID and database name DEVCDB to TESTCDB? (Y/[N]) => Y
Proceeding with operation
Changing database ID from 2721637057 to 2850317248
Changing database name from DEVCDB to TESTCDB
    Control File /oradata/devcdb/oradata/DEVCDB/controlfile/o1_mf_kcx8zx9n_.ctl - modified
    Control File /oradata/devcdb/fast_recovery_area/DEVCDB/controlfile/o1_mf_kcx8zxcj_.ctl - modified
    Datafile /oradata/devcdb/oradata/DEVCDB/datafile/o1_mf_system_kcx8xpcx_.db - dbid changed, wrote new name
    Datafile /oradata/devcdb/oradata/DEVCDB/datafile/o1_mf_sysaux_kcx8wm74_.db - dbid changed, wrote new name
    Datafile /oradata/devcdb/oradata/DEVCDB/datafile/o1_mf_undotbs1_kcx8ytp3_.db - dbid changed, wrote new name
    Datafile /oradata/devcdb/oradata/DEVCDB/datafile/o1_mf_system_kcx9039v_.db - dbid changed, wrote new name
    Datafile /oradata/devcdb/oradata/DEVCDB/datafile/o1_mf_users_kcx8yslq_.db - dbid changed, wrote new name
    Datafile /oradata/devcdb/oradata/DEVCDB/datafile/o1_mf_sysaux_kcx9039r_.db - dbid changed, wrote new name
    Datafile /oradata/devcdb/oradata/DEVCDB/E2BA8506A8CF2123E053052AA8C092B1/datafile/o1_mf_system_kcx9b6cy_.db - dbid changed, wrote new name
    Datafile /oradata/devcdb/oradata/DEVCDB/E2BA8506A8CF2123E053052AA8C092B1/datafile/o1_mf_sysaux_kcx9b6d3_.db - dbid changed, wrote new name
    Datafile /oradata/devcdb/oradata/DEVCDB/E2BA8506A8CF2123E053052AA8C092B1/datafile/o1_mf_users_kcx9bb00_.db - dbid changed, wrote new name
    Datafile /oradata/devcdb/oradata/DEVCDB/datafile/o1_mf_temp_kcx901k3_.tm - dbid changed, wrote new name
    Datafile /oradata/devcdb/oradata/DEVCDB/datafile/pdbseed_temp012022-07-01_11-37-02-AM.db - dbid changed, wrote new name
    Datafile /oradata/devcdb/oradata/DEVCDB/E2BA8506A8CF2123E053052AA8C092B1/datafile/o1_mf_temp_kcx9b6d3_.db - dbid changed, wrote new name
    Control File /oradata/devcdb/oradata/DEVCDB/controlfile/o1_mf_kcx8zx9n_.ctl - dbid changed, wrote new name
    Control File /oradata/devcdb/fast_recovery_area/DEVCDB/controlfile/o1_mf_kcx8zxcj_.ctl - dbid changed, wrote new name
    Instance shut down
Database name changed to TESTCDB.
Modify parameter file and generate a new password file before restarting.
Database ID for database TESTCDB changed to 2850317248.
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.
[oracle@hostname ~]$

SQL> startup nomount;
ORACLE instance started.
Total System Global Area 2.0133E+10 bytes
Fixed Size                  3721176 bytes
Variable Size            2684356648 bytes
Database Buffers         1.7381E+10 bytes
Redo Buffers               63385600 bytes

SQL> alter system set db_name='TESTCDB' scope=spfile;
System altered.

SQL> SHUTDOWN IMMEDIATE;
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> exit

[oracle@hostname ~]$ export ORACLE_SID=TESTCDB

SQL> STARTUP MOUNT
ORACLE instance started.
Total System Global Area 2.0133E+10 bytes
Fixed Size                  3721176 bytes
Variable Size            2684356648 bytes
Database Buffers         1.7381E+10 bytes
Redo Buffers               63385600 bytes
Database mounted.
SQL>

SQL> ALTER DATABASE OPEN RESETLOGS;
Database altered.

SQL> show pdbs
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 DEVPDB                         MOUNTED

SQL> alter pluggable database DEVPDB open;
Pluggable database altered.

SQL> show pdbs
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 DEVPDB                         READ WRITE NO

SQL> select name from v$database;
NAME
---------
TESTCDB

SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
TESTCDB

SQL> show parameter db_name
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_name                              string      TESTCDB



    


Change PDB name from DEVPDB to TESTPDB (NON TDE Environment)

*********************************************
Backup database before performing this action
*********************************************


	

SQL> alter pluggable database DEVPDB close;
Pluggable database altered.

SQL> alter pluggable database DEVPDB unplug into '/orabin/app/product/12.1.0/dbs/DEVPDB_meta.xml';
Pluggable database altered.

SQL> drop pluggable database DEVPDB;
Pluggable database dropped.

SQL> create pluggable database TESTPDB using '/orabin/app/product/12.1.0/dbs/DEVPDB_meta.xml' NOCOPY;
Pluggable database created.

SQL> show pdbs
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 TESTPDB                        MOUNTED

SQL> alter pluggable database TESTPDB open;
Pluggable database altered.

SQL> show pdbs
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 TESTPDB                        READ WRITE NO

SQL> alter pluggable database all save state instances=all;
Pluggable database altered.

SQL> show pdbs
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 TESTPDB                        READ WRITE NO

SQL> show parameter service
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      TESTCDB


SQL> exit

Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
[oracle@hostname ~]$



    


Change PDB name from DEVPDB to TESTPDB (TDE Environment)

*********************************************
Backup database before performing this action
*********************************************

In RAC Environment run the below commands from only one node, close the PDB on other nodes using below commands



	

alter pluggable database DEVPDB close immediate instances=all ;

alter pluggable database DEVPDB open restricted ;

alter session set container=DEVPDB ;

alter pluggable database rename global_name to TESTPDB ;

alter pluggable database close immediate ;

alter pluggable database open instances=all ;


    





Comments

Popular posts from this blog

Data Safe - Introduction

Oracle Data Safe - Practical Guide Oracle Data Safe learner guide Oracle Data Safe Assess risk, discover sensitive data, audit activity, and mask safely It focuses on what Data Safe helps you do operationally: review security posture, find risky identities, centralize auditing, locate sensitive data, and produce safer non-production copies. Contents 01 Why Data Safe matters 02 Where it fits 03 Capability map 04 Assessments 05 Activity Auditing 06 Discovery and Masking 07 Operating model 08 First 30 days 09 Knowledge check Section 01 Why Data Safe matters Database security work is often fragmented. One process checks configuration drift, another stores audit logs, another team scans for PII, and another team writes masking logic for test refreshes. Data Safe is useful because it turns those separate jobs into one security workflow. Key idea The best way to think about Data Safe is as a control plane for database security posture: assess the target, identify risky accounts, d...

Testing Different Access Paths : Concatenated Index

Oracle Concatenated Indexes - Practical Deep Dive Oracle concatenated index deep dive Concatenated Indexes How composite indexes really work, why column order matters, and when skip scan changes the story Concatenated indexes, also called composite indexes, are easy to explain badly and surprisingly rich to explain well. The usual summary is “Oracle can use the index only when the leading column is present,” but that is only the starting point. To design them properly, you need to think about leading portions, equality versus range predicates, ordering requirements, skip scan eligibility, covering behavior, and whether one composite index can replace several single-column indexes in a given workload. Contents 01 What concatenated indexes are 02 Leading edge and leading portion 03 Why column order matters 04 Skip scan and when it helps 05 Access patterns and plan reading 06 Covering and sort elimination 07 Design rules that actually hold 08 Common mistakes 09 End-to-end demo 1...

Database Replay - Real Application Testing (RAT)

Oracle Database Replay and RAT - Practical Deep Dive Oracle Database Replay deep dive Database Replay and Real Application Testing How to validate upgrades, patches, migrations, and risky changes with real workload behavior Database Replay is one of the most practical risk-reduction tools in the Oracle DBA toolbox. Instead of trusting synthetic benchmarks, isolated SQL tests, or intuition, you capture a real production workload, restore a test system to the same logical starting point, replay that workload, and analyze whether performance, errors, timing, and transactional behavior still look safe. Contents 01 What RAT actually is 02 Why Database Replay matters 03 End-to-end workflow 04 Capture design and prerequisites 05 Preprocess, calibrate, replay 06 Reading the results well 07 Pitfalls and unreplayable work 08 Database Replay vs SPA 09 Practical playbooks 10 Knowledge check Section 01 What Real Application Testing actually is Real Application Testing, usually shortened...