Steps to change PDB name in Primary and Standby in Dataguard environment Oracle

Following are the steps involved in rename the PDB database on Primary Server:

1) Connect with the CDB database and run the following commands: (Primary Server)

select name, open_mode, restricted from v$pdbs;

select name, con_id, dbid,con_uid,guid from v$containers;

select service_id,name,network_name,creation_date,pdb,con_id from cdb_services;

2) If you want to rename the PDB_OLD to PDB_NEW database name, then put the PDB_OLD database in restricted mode first: (Primary Server)

alter pluggable database PDB_OLD close;

alter pluggable database PDBOLD open restricted;

-- Verify
select name, open_mode, restricted from v$pdbs; 

3) On Standby, Close the PDB database (Standby Server):

-- Login with Standby CDB
alter pluggable database PDB_OLD close;

-- Verify
select name, open_mode, restricted from v$pdbs;

4) When you perform the DDL RENAME of a PDB in Primary, the changes get propagated to the Standby db via log shipping/apply.

5) Change the name of PDB database on primary server with alter command:

alter session set container=PDB_OLD;
alter pluggable database rename PDB_OLD to PDB_NEW;

6) Restart the PDB database on Primary:

alter pluggable database close immediate;
alter pluggable database open;

7) If you want to change the location of datafiles, then create new folder on both Primary and Standby server then use the following move command to move the datafiles, it automatic reflect on Standby server:

alter database move datafile '/u01/oradata/CDB1/pdb_old/system01.dbf' to '/u01/oradata/CDB1/pdb_new/system01.dbf'

-- Repeat it for all datafiles:
select file_name from dba_Data_Files;

8) Open the PDB database on Standby Server in recover mode.

Leave a Reply