• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to rename a Pluggable Database, along with the respective directories, in Oracle 12c

by admin

Please go through the following steps to change the name of a PDB, along with the respective directories, in 12c.

1. Connect to the CDB and check the information about the PDB first:

sql> select name, open_mode, restricted from v$pdbs;
sql> select name, con_id, dbid,con_uid,guid from v$containers order by con_id;
sql> select service_id,name,network_name,creation_date,pdb,con_id from cdb_services;

2. Assuming the name of your PDB is PDB1, the steps could be like this:

Put the PDB in RESTRICTED mode for a rename operation:

sql> alter pluggable database PDB1 close;
sql> alter pluggable database PDB1 open restricted;
sql> select name, open_mode, restricted from v$pdbs;

3. Then connect to the PDB and rename it:

sql> alter session set container=PDB1;
sql> alter pluggable database rename global_name to [NEW_PDB_NAME];

4. Close the PDB.

sql> alter pluggable database close immediate;

5. Open the PDB in read/write mode.

sql> alter pluggable database open;

Please note that it is important to perform the last two steps (close and open the PDB). You must close the PDB and open it in read/write mode for Oracle Database to complete the integration of the new PDB service name into the CDB.

6. Connect to the CDB and check the information again:

sql> alter session set container=CDB$ROOT;
sql> select name, open_mode, restricted from v$pdbs;
sql> select name, con_id, dbid,con_uid,guid from v$containers order by con_id;
sql> select service_id,name,network_name,creation_date,pdb,con_id from cdb_services;

7. However, the directories corresponding to the PDB do not get renamed. If originally your PDB’s files were present in something like ‘/u01/oradata/CDB1/pdb1’ it does not get moved into a directory reflecting the new name. If you would want to move the files to a new directory matching with the name of the NEW_PDB_NAME, then you would have to create the new directory manually and then move the files using the ONLINE MOVE facility of the 12c database:

$ mkdir '/u01/oradata/CDB1/[NEW_PDB_NAME]
SQL> alter database move datafile '/u01/oradata/CDB1/pdb1/system01.dbf' to '/u01/oradata/CDB1/[NEW_PDB_NAME]/system01.dbf'

8. To rename Oracle Managed Files (OMFs), Please follow the below document.

How to rename Oracle-Managed Files (OMFs)

9. The tempfiles of the temporary tablespace cannot be moved by the ‘online move’ command though, so you would have to drop the tempfile associated with the temp tablespace and recreate a new tempfile in the new directory.

SQL> alter database tempfile '/u01/oradata/CDB1/pdb1/temp01.dbf' drop including datafiles;
SQL> alter tablespace TEMP add tempfile '/u01/oradata/CDB1//temp01.dbf' size 10M reuse;

Filed Under: oracle, oracle 12c

Some more articles you might also be interested in …

  1. How to Change sys password in oracle 12c on RAC and dataguard
  2. Oracle Grid 12c: Read Only Instances on Leaf Nodes
  3. Oracle RMAN – Restore and Recovery of a Noarchivelog Database
  4. Oracle Database 12c : Creating a Scheduler Job in a Multitenant Database
  5. ASM disk addition/deletion hung with no rebalancing
  6. Oracle Database: Redo log operations (Add/Drop/Change Location)
  7. How to Monitor Process Memory Usage on Oracle Pluggable Databases
  8. How to set udev rule for setting the disk permission on ASM disks when using multipath on CentOS/RHEL 6
  9. How To Recover From Lost SYS Password in Oracle Database
  10. Undo Modes in 12.2 Multitenant Databases – Local and Shared Modes

You May Also Like

Primary Sidebar

Recent Posts

  • aws ec2: CLI for AWS EC2 (Command Examples)
  • aws cur – Create, query, and delete AWS usage report definitions (Command Examples)
  • aws configure – Manage configuration for the AWS CLI (Command Examples)
  • aws cognito-idp: Manage Amazon Cognito user pool and its users and groups using the CLI

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright