Monday, June 17, 2019

Rename Pluggable Database

1. Find the Connected Container
SQL> sho con_name;

CON_NAME
----------------------
CDB$ROOT

2. Find the List of Pluggable Databases
SQL> sho pdbs;

 CON_ID      CON_NAME        OPEN MODE  RESTRICTED
-------     ---------        ---------  ----------
   2         PDB$SEED        READ ONLY   NO
   3 UATPDB          READ WRITE NO

3. Connect to Specific Pluggable DB which need to rename
SQL>  alter session set container=UATPDB;

Session altered. 

4. Shutdown the pluggable Database
SQL> alter pluggable database UATPDB close;

Pluggable database altered.

5. Startup in Restricted Mode
SQL> alter pluggable database UATPDB open restricted;

Pluggable database altered.

6. Rename the pluggable database
SQL> alter pluggable database UATPDB rename global_name to MIGPDB;

Pluggable database altered.

7. Shutdown and start the pluggable database
SQL> shutdown immediate;

Pluggable Database closed.


SQL> startup;

Pluggable Database opened.

8. Check the Pluggable Database name
SQL> sho con_name;

CON_NAME
----------------------------
MIGPDB

9. The directory does not get renamed according to the new pluggable Database name. Have to create appropriate directory and move the datafile. From 12c onward we can move the datafile online
SQL> alter database move datafile '/u02/oradata/MIG10CDB/UATPDB/system01.dbf' to '/u02/oradata/MIG10CDB/MIGPDB/system01.dbf';

Database altered.