Renaming a Pluggable Database (PDB) in Oracle 19c is not something we do every day—but when we do, it needs to be done right. Whether you’re standardizing your naming convention, consolidating environments, or simply cleaning things up, Oracle 19c makes it relatively straightforward.
In this blog post, we’ll walk through two supported methods for renaming a PDB in Oracle 19c, along with tips, gotchas, and real-world examples.
Why Rename a PDB?
You might want to rename a PDB in Oracle 19c for reasons like:
- Fixing inconsistent naming conventions (e.g., PDBTEST1 to HRPDB)
- Standardizing naming during migrations or refreshes
- Rebranding or aligning with environment labels (e.g., STAGEPDB to PRODPDB)
Whatever the use case, renaming makes your environment more readable and manageable.
Method 1: Rename PDB from CDB Level (Using SQL*Plus or SQL Developer)
This is the most direct method and can be performed from the container (CDB) level. It's suitable for simple renames where you manage the PDB from the CDB root.
Steps:
- Close the PDB
ALTER PLUGGABLE DATABASE NEP1 CLOSE IMMEDIATE;
- Rename the PDB
ALTER PLUGGABLE DATABASE NEP1 RENAME TO NEP;
- Open the PDB
ALTER PLUGGABLE DATABASE NEP OPEN;
Method 2: Rename Global Name from Within the PDB
Alternatively, if you're working within the pluggable database, you can use the RENAME GLOBAL_NAME clause. This method is often preferred or necessary in specific scenarios, such as after cloning a PDB where you want to update its logical name without changing its original identity from the CDB perspective during the clone operation.
Steps:
- Close the PDB and Open in Restricted Mode (from CDB Root)
ALTER PLUGGABLE DATABASE PDBNEP CLOSE IMMEDIATE; ALTER PLUGGABLE DATABASE PDBNEP OPEN RESTRICTED;
- Switch to the PDB Session
ALTER SESSION SET CONTAINER=PDBNEP;
- Rename the PDB Global Name (from within the PDB)
ALTER PLUGGABLE DATABASE RENAME GLOBAL_NAME TO ECODB;
- Restart the PDB (from CDB Root)
First, switch back to the CDB root:
SQL> alter pluggable database close immediate; Pluggable database altered. SQL> alter pluggable database open; Pluggable database altered. SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ----------------- ---------- ---------- 3 ECODB READ WRITE NO
Tip: Choosing the Right Method
The ALTER PLUGGABLE DATABASE <old_pdb_name> RENAME TO <new_pdb_name> command (Method 1) is ideal for straightforward administrative renaming at the CDB level. It performs a complete rename, updating all necessary internal structures.
The ALTER PLUGGABLE DATABASE RENAME GLOBAL_NAME TO command (Method 2) is particularly useful when you've cloned a PDB and want to update its logical global name to reflect its new purpose or environment, without affecting the original PDB or its physical paths on the OS (if applicable).
Conclusion
Renaming a PDB in Oracle 19c is simple but powerful. Whether you're restructuring your database environment or aligning with naming conventions, just follow the right steps and validate afterward. By understanding both supported methods, DBAs can choose the most appropriate approach for their specific scenario.
Please feel free to ask if you have any questions. Thank you! 🙂
Toufique Khan
No comments:
Post a Comment