[2022-04-24]插拔PDB

拔PDB可以参考文档:Unplugging a PDB from a CDB

Unplug a PDB with a ALTER PLUGGABLE DATABASE ... UNPLUG INTO statement.
Prerequisites
The following prerequisites must be met:
The current user must have SYSDBA or SYSOPER administrative privilege, and the privilege must be either commonly granted or locally granted in the PDB. The user must exercise the privilege using AS SYSDBA or AS SYSOPER at connect time.
The PDB must have been opened at least once.
Note:If you are unplugging a PDB that includes data that was encrypted with Transparent Data Encryption, then follow the instructions in Oracle Database Advanced Security Guide.
To unplug a PDB:
In SQL*Plus, ensure that the current container is the root of the PDB.
If the PDB is plugged into the CDB root, then the current container must be the CDB root. If the PDB is plugged into an application root, then the current container must be the application root.
If you are unplugging an application container, then the current container must be the CDB root, and the application container must not have any application PDBs plugged into it.
Close the PDB.
In an Oracle Real Application Clusters (Oracle RAC) environment, the PDB must be closed on all instances.
Run the ALTER PLUGGABLE DATABASE statement with the UNPLUG INTO clause, and specify the PDB to unplug and the name and location of the PDB's XML metadata file or .pdb file.
Example 11-1 Unplugging PDB salespdb Into an XML Metadata File
This ALTER PLUGGABLE DATABASE statement unplugs the PDB salespdb and creates the salespdb.xml metadata file in the /oracle/data/ directory:
ALTER PLUGGABLE DATABASE salespdb UNPLUG INTO '/oracle/data/salespdb.xml';
Example 11-2 Unplugging PDB salespdb Into an Archive File
This ALTER PLUGGABLE DATABASE statement unplugs the PDB salespdb and creates the sales.pdb archive file in the /oracle/data/ directory. The sales.pdb archive file is a compressed file that includes the XML metadata file and the PDB’s files (such as the data files and wallet file).
ALTER PLUGGABLE DATABASE salespdb UNPLUG INTO '/oracle/data/sales.pdb';

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB01                          READ WRITE NO
         4 PDB02                          READ WRITE NO

把PDB02从容器中拔出

SQL> ALTER PLUGGABLE DATABASE PDB02 UNPLUG INTO  '/home/oracle/PDB02.xml';

Pluggable database altered.

SQL> 
SQL> select pdb_name,status from dba_pdbs;

PDB_NAME                       STATUS
------------------------------ ----------
PDB01                          NORMAL
PDB$SEED                       NORMAL
PDB02                          UNPLUGGED

被拔出的PDB无法open


SQL> alter PLUGGABLE DATABASE PDB02 open;
alter PLUGGABLE DATABASE PDB02 open
*
ERROR at line 1:
ORA-65086: cannot open/close the pluggable database

插回PDB可以参考:Plugging In an Unplugged PDB

使用PROD02.xml创建一个新的PDB,或者删除旧的PDB保留数据文件, 然后重新创建PDB

SQL> drop pluggable database PDB02 keep datafiles;

Pluggable database dropped.

SQL> 
SQL> create pluggable database PDB02 as clone using '/home/oracle/PDB02.xml' nocopy tempfile reuse;

Pluggable database created.

SQL> alter pluggable database  PDB02 open;

Pluggable database altered.

SQL> 

或者创建一个新的PDB

SQL>  create pluggable database PDB022 as clone using '/home/oracle/PDB02.xml' copy FILE_NAME_CONVERT = ('/oracle/app/oradata/PRODPDB02','/oracle/app/oradata/PRODPDB');

Pluggable database created.

SQL> 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值