How to Rename a Pluggable Database (PDB) in Oracle Database 19c (Multitenant)

How to rename pluggable database in Oracle database 19c

Table of Contents

    We needed to rename a pluggable database from EBSDB to EBSPDB as part of standardizing naming across environments. It looks like a two-command job at first glance, but the rename has a strict sequence — close, reopen restricted, switch container, rename, then close and reopen from the root — and skipping or reordering a step either fails outright or leaves the PDB in a state where the new name doesn’t fully take. Here is the exact sequence we used, what each command does, and what a rename does and doesn’t touch.

    Environment Details

    DatabaseOracle Database 19c (Multitenant / CDB-PDB architecture)
    CDB NameCDB1
    Old PDB NameEBSDB
    New PDB NameEBSPDB
    DB Server Nodemydb

    Understanding the Concepts

    CDB, PDB, and What “Name” Actually Means

    In the multitenant architecture, a single Container Database (CDB) hosts one or more Pluggable Databases (PDBs). The CDB owns the instance, the SPFILE, the control file, and the background processes; each PDB is a self-contained set of tablespaces and a data dictionary that plugs into that instance. A PDB has its own name, but that name is metadata stored in the CDB’s dictionary (visible via v$pdbs, v$containers, and DBA_PDBS) — it is not baked into the PDB’s datafiles or its physical files in any way. That is precisely why a rename is safe and fast: you are updating a row of metadata in the root container, not touching a single byte of the PDB’s own data.

    Why GLOBAL_NAME, Not Just “NAME”

    Every PDB has two related but distinct identifiers: its container name (the CON_NAME shown by show pdbs, used for administrative commands like ALTER SESSION SET CONTAINER) and its global name, which is what ALTER PLUGGABLE DATABASE … RENAME GLOBAL_NAME actually changes. In practice, for a PDB that is not using a DB_DOMAIN suffix, the two end up being the same string — which is why the command reads as a full rename rather than a narrower operation. The command also drives the PDB’s default database service, which is derived from this same name and is what client connect strings actually resolve against at the listener.

    Why the PDB Must Be Closed and Reopened Restricted

    A rename changes an identity that is cached in multiple places — the shared pool, the listener’s service registration, and any session that has already resolved the old name. Oracle requires the PDB to be closed first so there is no live state referencing the old identity when the change is made. Reopening in RESTRICTED mode rather than fully open is a safety measure: it lets the DBA (a RESTRICTED SESSION-privileged connection) get in to perform the rename while ordinary application sessions are locked out, so nobody can establish a new connection against the soon-to-be-stale name mid-operation.

    Why the Rename Command Must Run Inside the PDB

    ALTER SESSION SET CONTAINER = <pdb> doesn’t just change a label in your prompt — it moves your session’s container context so that subsequent DDL is scoped to that PDB rather than to CDB$ROOT. RENAME GLOBAL_NAME is deliberately scoped this way (rather than being expressed as, say, ALTER PLUGGABLE DATABASE EBSDB RENAME TO EBSPDB from the root) because a global name change is conceptually an operation the PDB performs on itself, consistent with how DB_DOMAIN/global name renames have always worked for non-CDB databases with ALTER DATABASE RENAME GLOBAL_NAME — multitenant reuses the same underlying mechanism, just scoped to a container.

    Why You Reference the PDB by Its New Name Immediately After

    Once the rename commits, the old identifier is gone from the CDB’s dictionary — there’s no grace period or alias left behind. Any subsequent ALTER PLUGGABLE DATABASE, connect string, or lsnrctl service check has to use the new name, because the old one no longer maps to anything in the control file or the dictionary. This is also why the final CLOSE/OPEN pair in the sequence uses EBSPDB and not EBSDB: it isn’t a cosmetic choice, it’s the only name Oracle recognizes at that point.

    Renaming the PDB

    1 Check the Current DBA Status

    SQL> show pdbs;
    
        CON_ID CON_NAME                       OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
             2 PDB$SEED                       READ ONLY  NO
             4 EBSDB                          READ WRITE NO

    Note: Always confirm the PDB’s current open mode before touching it — a rename requires the PDB to be closed first.

    2 Close the PDB Before Renaming

    SQL> ALTER PLUGGABLE DATABASE EBSDB CLOSE IMMEDIATE;
    
    Pluggable database altered.

    Note: A PDB’s global name cannot be changed while it is open. CLOSE IMMEDIATE is the standard way to bring it down cleanly for maintenance.

    3 Reopen Restricted and Switch Into the PDB

    SQL> ALTER PLUGGABLE DATABASE EBSDB OPEN RESTRICTED;
    
    Pluggable database altered.
    
    SQL> ALTER SESSION SET CONTAINER = EBSDB;
    
    Session altered.

    Note: RESTRICTED mode keeps ordinary sessions out while the rename is in progress. The rename command itself must be issued from inside the PDB, not from CDB$ROOT.

    4 Rename the Global Name

    SQL> ALTER PLUGGABLE DATABASE EBSDB RENAME GLOBAL_NAME TO EBSPDB;
    
    Pluggable database altered.

    Note: This is the actual rename. Run while connected to the PDB itself, it updates the PDB’s name in the CDB dictionary — not just a DB_DOMAIN-style string — so v$pdbs.name and every future show pdbs report the new name.

    5 Return to the Root Container and Reopen

    SQL> ALTER SESSION SET CONTAINER = CDB$ROOT;
    
    Session altered.
    
    SQL> ALTER PLUGGABLE DATABASE EBSPDB CLOSE IMMEDIATE;
    
    Pluggable database altered.
    
    SQL> ALTER PLUGGABLE DATABASE EBSPDB OPEN;
    
    Pluggable database altered.

    Note: Reference the PDB by its NEW name once back at CDB$ROOT — EBSDB no longer resolves to anything. Opening normally (not RESTRICTED) at the end lets application sessions back in.

    What This Rename Does and Doesn’t Do

    The PDB is renamed in the CDB dictionary — show pdbs and v$pdbs.name report EBSPDB from now on, and that is the name every future connect descriptor must use.

    Datafile paths, redo/archive destinations, and any PDB-specific SPFILE parameters are untouched — nothing on the filesystem moves. The default database service that clients connect through is also renamed to match, but a custom (non-default) service you created yourself is not renamed automatically.

    Why a Custom Service Doesn’t Follow the Rename

    Oracle only auto-manages the PDB’s default service — the one it creates for you the moment the PDB is created, sharing the PDB’s name. Any service you created afterward with DBMS_SERVICE.CREATE_SERVICE is a separate object registered in the dictionary with its own name and its own PDB association by CON_ID, not by name-matching. A rename updates the PDB’s CON_ID’s associated name; it doesn’t walk the list of services and rename ones that happen to reference the old string. This is a common surprise for DBAs coming from single-instance (non-CDB) databases, where a global name rename and the database’s connect identity were effectively the same thing.

    6 Verify the Rename and the Service Registration

    SQL> show pdbs;
    
        CON_ID CON_NAME                       OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
             2 PDB$SEED                       READ ONLY  NO
             4 EBSPDB                         READ WRITE NO
    
    $ lsnrctl status
    
    Service "EBSPDB" has 1 instance(s).
      Instance "CDB1", status READY, has 1 handler(s) for this service...

    Note: Dynamic registration usually picks up the renamed PDB’s default service with the listener within about a minute of the final OPEN. If you use a custom (non-default) service name, drop and recreate it explicitly with DBMS_SERVICE.CREATE_SERVICE / START_SERVICE — it won’t follow the rename on its own.

    Test Connectivity Under the New Name

    $ tnsping EBSPDB
    
    $ sqlplus system/<pwd>@//oradb01t:1521/EBSPDB
    
    SQL> select sys_context('userenv','con_name') from dual;
    
    CON_NAME
    -----------
    EBSPDB

    Note: EBSDB no longer resolves to anything at the listener or dictionary level — any client, tnsnames entry, script, or connect string still pointing at the old name will fail to connect from this point forward.

    Rename Impact Summary

    ComponentStatusDetail
    PDB Global NameRenamedEBSDB → EBSPDB via ALTER PLUGGABLE DATABASE
    PDB DatafilesUnchangedPaths and filenames untouched by the rename
    Default DB ServiceRenamedFollows the PDB name automatically
    Custom (Non-Default) ServicesMust RecreateNot renamed automatically — recreate with DBMS_SERVICE
    Listener Service RegistrationVerifyDynamic registration usually updates within ~60 seconds
    tnsnames.ora / Client Connect StringsMust UpdateStill reference EBSDB until edited manually

    Key Takeaways for Oracle DBAs

    • ALTER PLUGGABLE DATABASE … RENAME GLOBAL_NAME must be run while connected inside the PDB (after ALTER SESSION SET CONTAINER), not from CDB$ROOT.
    • The PDB must be closed, reopened RESTRICTED, renamed, then closed and reopened normally — and referenced by its new name immediately afterward.
    • Only the PDB’s name and its default service change. Datafile paths, redo/archive destinations, and SPFILE settings are completely unaffected.
    • Custom (non-default) services you created for the PDB do not follow the rename automatically — recreate them with DBMS_SERVICE against the new PDB name.
    • Once the rename completes, the old name stops resolving immediately — test connectivity under the new name before considering the change finished.

    Commands Quick Reference

    CommandPurpose
    show pdbs;Check current PDB status
    ALTER PLUGGABLE DATABASE <pdb> CLOSE IMMEDIATE;Close the PDB before renaming
    ALTER PLUGGABLE DATABASE <pdb> OPEN RESTRICTED;Reopen in restricted mode
    ALTER SESSION SET CONTAINER = <pdb>;Switch the session into the PDB
    ALTER PLUGGABLE DATABASE <pdb> RENAME GLOBAL_NAME TO <new>;Perform the rename
    ALTER SESSION SET CONTAINER = CDB$ROOT;Return to the root container
    ALTER PLUGGABLE DATABASE <new> CLOSE IMMEDIATE;Close the PDB under its new name
    ALTER PLUGGABLE DATABASE <new> OPEN;Reopen normally under the new name
    lsnrctl statusConfirm the renamed service registered
    tnsping <service>Validate the new service name resolves

    FAQs

    Does RENAME GLOBAL_NAME rename the PDB itself, or just a global-name string?

    When run while connected inside the PDB, it renames the PDB itself — show pdbs and v$pdbs.name at CDB$ROOT report the new name afterward, not just an updated DB_DOMAIN-style string.

    Do I need to move the PDB’s datafiles as part of a rename?

    No. Renaming only changes the PDB’s name and its default service; datafile paths and filenames are untouched unless you separately relocate them.

    Can I rename the PDB without closing it first?

    No. The PDB must be closed and reopened in RESTRICTED mode before the rename — ALTER PLUGGABLE DATABASE … RENAME GLOBAL_NAME fails if the PDB is open normally.

    What happens to sessions and services still using the old name after the rename?

    The old name stops resolving as soon as the rename commits. Existing connections aren’t retroactively broken, but any new connection attempt, tnsnames entry, or custom database service still referencing the old name will fail until it’s updated to the new name.

    Why does the rename command have to run from inside the PDB rather than from CDB$ROOT?

    A global-name rename is the same underlying mechanism as ALTER DATABASE RENAME GLOBAL_NAME on a traditional non-CDB database — conceptually the database (or here, the PDB) renames itself. Multitenant preserves that model, just scoped to a container, which is why ALTER SESSION SET CONTAINER has to happen first.

    Is the PDB’s name the same thing as its database service name?

    They start out the same — Oracle creates a default service matching the PDB’s name automatically — but they’re separate objects in the dictionary. The rename updates the PDB’s name and its default service together; any additional service you created yourself is tracked by CON_ID, not by name, so it keeps its original name and has to be recreated by hand if you want it to match.