改变pdb名字


一、说明


1.1、更改的前提条件

  •     当前用户必须具有ALTER DATABASE系统权限;

  •    pdb必须打开到读写受限模式  alter pluggable database xxx open restricted;

  •    必须在pdb中操作,及当前容器必须是pdb;

  •    rac中只能一个实例上的pdb处于open状态,其它实例上该pdb需要关闭。

  

1.2、注意事项:

  •    new global database name must be different from that of any container in the CDB

  •    该pdb上不能有流动会话

   

1.3、更改语句

      ALTER PLUGGABLE DATABASE RENAME GLOBAL_NAME TO statement




二、例子 更改pdb名字BJSYSY为BJSYSY_BAK


[root@saas-db1 ~]# su - oracle

Last login: Tue Jul  7 01:00:02 CST 2020

[oracle@saas-db1 ~]$ sqlplus / as sysdba


SQL*Plus: Release 18.0.0.0.0 - Production on Tue Jul 7 17:03:22 2020

Version 18.3.0.0.0


Copyright (c) 1982, 2018, Oracle.  All rights reserved.



Connected to:

Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production

Version 18.3.0.0.0


SQL> show pdbs;


    CON_ID          CON_NAME               OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

   2                PDB$SEED               READ ONLY    NO

   22               BJSYSY                 READ WRITE   NO

   23               BXHL                   READ WRITE   NO


SQL> archive log list;

Database log mode        Archive Mode

Automatic archival        Enabled

Archive destination        /backup/archive

Oldest online log sequence     55336

Next log sequence to archive   55341

Current log sequence        55341



SQL> alter pluggable database BJSYSY close immediate;


Pluggable database altered.



SQL> alter pluggable database BJSYSY open restricted;


Pluggable database altered.




SQL> show pdbs;


    CON_ID        CON_NAME                OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

   2              PDB$SEED                  READ ONLY  NO

   22             BJSYSY                    READ WRITE YES

   23             BXHL                      READ WRITE NO


SQL> alter pluggable database BJSYSY rename global_name to BJSYSY_BAK;

Pluggable database altered.


SQL> show pdbs;


    CON_ID               CON_NAME          OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

      22                 BJSYSY_BAK        READ WRITE YES

SQL> 



SQL> conn / as sysdba     

Connected.


SQL> alter pluggable database BJSYSY_BAK close immediate;


Pluggable database altered.


SQL> alter pluggable database BJSYSY_BAK open;


Pluggable database altered.