Oracle Database -
Enterprise Edition - Version 12.1.0.2 and later
Information in this document applies to any platform.
How to change the
name of a PDB, along with the respective directories, in 12c.
NOTE: In the images and/or the document content below, the
user information and data used represents fictitious data from the Oracle
sample schema(s) or Public Documentation delivered with an Oracle database
product. Any similarity to actual persons, living or dead, is purely
coincidental and not intended in any manner.
Please go through
the following steps for that:
Connect to the CDB and check the information about the PDB first:
select name, open_mode, restricted from v$pdbs;
select name, con_id, dbid,con_uid,guid from v$containers order by con_id;
select service_id,name,network_name,creation_date,pdb,con_id from
cdb_services;
Assuming the name of your PDB is PDB1,the steps could be like this:
Put the PDB in RESTRICTED mode for a rename operation:
alter pluggable database PDB1 close;
alter pluggable database PDB1 open restricted;
select name, open_mode, restricted from v$pdbs;
Then connect to the PDB and rename it:
alter session set container=PDB1;
alter pluggable database rename global_name to <NEW_PDB_NAME>;
Close the PDB.
alter pluggable database close immediate;
Open the PDB in read/write mode.
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.
Connect to the CDB
and check the information again:
alter session set container=CDB$ROOT;
select name, open_mode, restricted from v$pdbs;
select name, con_id, dbid,con_uid,guid from v$containers order by con_id;
select service_id,name,network_name,creation_date,pdb,con_id from
cdb_services;
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 session set container=’testpdb’;
SQL> alter database move datafile '/u01/oradata/CDB1/pdb1/system01.dbf'
to '/u01/oradata/CDB1/<NEW_PDB_NAME>/system01.dbf'
To rename Oracle
Managed Files (OMFs), Please follow the below document.
How to rename Oracle-Managed Files (OMFs) (Doc ID
191574.1)
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/<NEW_PDB_NAME>/temp01.dbf' size 10M reuse;
|
No comments:
Post a Comment