In this Post I'm going to rename my pluggable database ORCL to SRPDB.
For renaming a PDB we need to open the pdb in restricted mode.
[oracle@orcldb01:~ ] $ sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 7 21:32:46 2021
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCL READ WRITE NO
SQL> alter pluggable database ORCL close ;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCL MOUNTED
SQL> alter pluggable database ORCL open restricted;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCL READ WRITE YES
SQL> alter pluggable database ORCL rename global_name to SRPDB;
alter pluggable database ORCL rename global_name to SRPDB
*
ERROR at line 1:
ORA-65046: operation not allowed from outside a pluggable database
SQL> alter session set container=ORCL;
Session altered.
SQL>
The datafile directory does not get renamed after PDB rename.
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------------------------------------
/u01/app/oracle/oradata/srcdb/SRCDB/49BFF8A6BB912582E0530100007F8BE4/datafile/o1_mf_system_hzb8ojfj_.dbf
/u01/app/oracle/oradata/srcdb/SRCDB/49BFF8A6BB912582E0530100007F8BE4/datafile/o1_mf_sysaux_hzb8j0hb_.dbf
/u01/app/oracle/oradata/srcdb/SRCDB/49BFF8A6BB912582E0530100007F8BE4/datafile/o1_mf_undotbs1_hzb8j0gv_.dbf
/u01/app/oracle/oradata/srcdb/SRCDB/49BFF8A6BB912582E0530100007F8BE4/datafile/o1_mf_users_hzb8ojmo_.dbf
/u01/app/oracle/oradata/srcdb/SRCDB/49BFF8A6BB912582E0530100007F8BE4/datafile/o1_mf_apex_199_hzb8j0rb_.dbf
/u01/app/oracle/oradata/srcdb/SRCDB/49BFF8A6BB912582E0530100007F8BE4/datafile/o1_mf_apex_199_hzb8j0vf_.dbf
6 rows selected.
SQL>
SQL> alter pluggable database ORCL rename global_name to SRPDB;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
3 SRPDB READ WRITE YES
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------------------------------------
/u01/app/oracle/oradata/srcdb/SRCDB/49BFF8A6BB912582E0530100007F8BE4/datafile/o1_mf_system_hzb8ojfj_.dbf
/u01/app/oracle/oradata/srcdb/SRCDB/49BFF8A6BB912582E0530100007F8BE4/datafile/o1_mf_sysaux_hzb8j0hb_.dbf
/u01/app/oracle/oradata/srcdb/SRCDB/49BFF8A6BB912582E0530100007F8BE4/datafile/o1_mf_undotbs1_hzb8j0gv_.dbf
/u01/app/oracle/oradata/srcdb/SRCDB/49BFF8A6BB912582E0530100007F8BE4/datafile/o1_mf_users_hzb8ojmo_.dbf
/u01/app/oracle/oradata/srcdb/SRCDB/49BFF8A6BB912582E0530100007F8BE4/datafile/o1_mf_apex_199_hzb8j0rb_.dbf
/u01/app/oracle/oradata/srcdb/SRCDB/49BFF8A6BB912582E0530100007F8BE4/datafile/o1_mf_apex_199_hzb8j0vf_.dbf
6 rows selected.
SQL>
Close and open the PDB to take it away from restricted mode.
SQL> alter pluggable database SRPDB close ;
Pluggable database altered.
SQL> alter pluggable database SRPDB open;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 SRPDB READ WRITE NO
SQL>
[oracle@orcldb01:~ ] $ lsnrctl status listener
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 07-JAN-2021 21:42:06
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 07-JAN-2021 21:04:28
Uptime 0 days 0 hr. 37 min. 38 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Default Service orcl12c
Listener Parameter File /u01/app/oracle/product/12.2/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/orcldb01/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.103)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=orcldb01)(PORT=8081))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "49bff8a6bb912582e0530100007f8be4" has 1 instance(s).
Instance "SRCDB", status READY, has 2 handler(s) for this service...
Service "SRCDB" has 1 instance(s).
Instance "SRCDB", status READY, has 2 handler(s) for this service...
Service "orcl12c" has 1 instance(s).
Instance "orcl12c", status UNKNOWN, has 1 handler(s) for this service...
Service "srpdb" has 1 instance(s).
Instance "SRCDB", status READY, has 2 handler(s) for this service...
The command completed successfully
[oracle@orcldb01:~ ] $
No comments:
Post a Comment