天天看點

oracle12c多租戶管理(pdb名字更改)

改變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

[[email protected] ~]# su - oracle

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

[[email protected] ~]$ 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.