[2022-04-24] 删除PDB

当您想要将PDB移动到一个新的CDB或当您不再需要它时,这个时候就需要删除PDB。

When you drop a PDB, the control file of the CDB is modified to eliminate all references to the dropped PDB. Archived redo log files and backups associated with the PDB are not removed, but you can use Oracle Recovery Manager (RMAN) to remove them.
When dropping a PDB, you can either keep or delete the PDB's data files by using one of the following clauses of the DROP PLUGGABLE DATABASE statement:
KEEP DATAFILES, the default, retains the data files.
The PDB temp file is removed even when KEEP DATAFILES is specified because the temp file is no longer needed.
When KEEP DATAFILES is specified, the PDB must be unplugged.
INCLUDING DATAFILES removes the data files from disk.
If a PDB was created with the SNAPSHOT COPY clause, then you must specify INCLUDING DATAFILES when you drop the PDB.

删除PDB的时候,你可以选择是否保留数据文件,如果不是unplugged状态需要加上including datafiles,否则删除时会报如下错误:

SQL> drop pluggable database NCDB;
drop pluggable database NCDB
*
ERROR at line 1:
ORA-65179: cannot keep datafiles for a pluggable database that is not unplugged


SQL> 

删除PDB的需要PDB的状态为MOUNT或者unplugged

Prerequisites
The following prerequisites must be met
The PDB must be in mounted mode, or it must be unplugged.
See "Modifying the Open Mode of PDBs".
See "Unplugging a PDB from a CDB".
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.

如果是open状态则会提示如下错误:

ORA-65025: Pluggable database NCDB is not closed on all instances.

删除PDB

To drop a PDB:

In SQL*Plus, ensure that the current container is the CDB root, or, for an application PDB, the application root that contains the application 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 that application root or the CDB root.

If you are dropping 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.

Run the DROP PLUGGABLE DATABASE statement and specify the PDB to drop.

Example 11-3 Dropping PDB salespdb While Keeping Its Data Files

DROP PLUGGABLE DATABASE salespdb
  KEEP DATAFILES;
Example 11-4 Dropping PDB salespdb and Its Data Files

DROP PLUGGABLE DATABASE salespdb
  INCLUDING DATAFILES;
SQL> DROP PLUGGABLE DATABASE NCDB INCLUDING DATAFILES;

Pluggable database dropped.

SQL> 
SQL> 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值