Please go through the following steps to change the name of a PDB, along with the respective directories, in 12c.
1. Connect to the CDB and check the information about the PDB first:
sql> select name, open_mode, restricted from v$pdbs; sql> select name, con_id, dbid,con_uid,guid from v$containers order by con_id; sql> select service_id,name,network_name,creation_date,pdb,con_id from cdb_services;
2. Assuming the name of your PDB is PDB1, the steps could be like this:
Put the PDB in RESTRICTED mode for a rename operation:
sql> alter pluggable database PDB1 close; sql> alter pluggable database PDB1 open restricted; sql> select name, open_mode, restricted from v$pdbs;
3. Then connect to the PDB and rename it:
sql> alter session set container=PDB1; sql> alter pluggable database rename global_name to [NEW_PDB_NAME];
4. Close the PDB.
sql> alter pluggable database close immediate;
5. Open the PDB in read/write mode.
sql> 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.
6. Connect to the CDB and check the information again:
sql> alter session set container=CDB$ROOT; sql> select name, open_mode, restricted from v$pdbs; sql> select name, con_id, dbid,con_uid,guid from v$containers order by con_id; sql> select service_id,name,network_name,creation_date,pdb,con_id from cdb_services;
7. 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 database move datafile '/u01/oradata/CDB1/pdb1/system01.dbf' to '/u01/oradata/CDB1/[NEW_PDB_NAME]/system01.dbf'
8. To rename Oracle Managed Files (OMFs), Please follow the below document.
9. 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/
/temp01.dbf' size 10M reuse;