How to Change the PDB Name in Oracle Database

Pluggable Databases (PDBs) in Oracle provide a flexible and efficient way to manage databases in a multi-tenant architecture. Following are the steps involved for changing the name of a PDB.

Prerequisites

  • You have administrative access to the Container Database (CDB).
  • The PDB is in a closed state.
  • A backup of the database exists in case of errors.

Steps to Rename a PDB

Step 1: Close the PDB

Log in as a privileged user and close the PDB:

ALTER PLUGGABLE DATABASE <old_pdb_name> CLOSE IMMEDIATE;

Step 2: Rename the PDB

Using the ALTER PLUGGABLE DATABASE command, rename the PDB:

ALTER PLUGGABLE DATABASE <old_pdb_name> RENAME TO <new_pdb_name>;

Step 3: Identify Existing Datafile Locations

Query the DBA_DATA_FILES view to check the current location of the PDB’s datafiles:

SELECT FILE_NAME FROM DBA_DATA_FILES WHERE CON_ID = (SELECT CON_ID FROM DBA_PDBS WHERE PDB_NAME = '<new_pdb_name>');

Step 4: Relocate Datafiles

If the datafiles need to be moved, execute the following steps:

Place the PDB in MOUNT state:

ALTER PLUGGABLE DATABASE <new_pdb_name> MOUNT;

Use the ALTER DATABASE command to relocate each datafile:

ALTER DATABASE MOVE DATAFILE '<current_path>/<datafile_name>' TO '<new_path>/<datafile_name>';

Step 5: Open the PDB

ALTER PLUGGABLE DATABASE <new_pdb_name> OPEN;

Step 6: Verify the New Name

Query the DBA_PDBS view to confirm the name change

SELECT PDB_ID, PDB_NAME, STATUS FROM DBA_PDBS;

Step 7: Verify the datafiles location:

SELECT FILE_NAME FROM DBA_DATA_FILES WHERE CON_ID = (SELECT CON_ID FROM DBA_PDBS WHERE PDB_NAME = '<new_pdb_name>');

Leave a Reply