Oracle Multitenant 5 PDB全削除

```
SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 ORCLPDB1$SEED                  MOUNTED
         4 ORCLPDB1                       READ WRITE NO
         5 ORCLPDB2                       MOUNTED

SQL> select p.con_id, p.name pname, d.name dname from v$pdbs p, v$datafile d where p.con_id = d.con_id and d.name like '%system%' group by p.con_id, p.name, d.name order by 1

    CON_ID PNAME           DNAME
---------- --------------- ------------------------------------------------------------
         2 PDB$SEED        /opt/oracle/oradata/ORCLCDB/pdbseed/system01.dbf
         3 ORCLPDB1$SEED   /opt/oracle/oradata/ORCLCDB/orclpdb2/system01.dbf
         4 ORCLPDB1        /opt/oracle/oradata/ORCLCDB/orclpdb1/system01.dbf
         5 ORCLPDB2        /opt/oracle/oradata/ORCLCDB/orclpdb3/system01.dbf
```

クローズしていないものをクローズ

```
SQL> alter pluggable database orclpdb1 close;

Pluggable database altered.
```

```
SQL> alter pluggable database orclpdb1$seed unplug into '/opt/oracle/oradata/ORCLCDB/orclpdb2/orclpdb2.xml';

Pluggable database altered.

SQL> alter pluggable database orclpdb1 unplug into '/opt/oracle/oradata/ORCLCDB/orclpdb1/orclpdb1-20200116.xml';

Pluggable database altered.

SQL> alter pluggable database orclpdb2 unplug into '/opt/oracle/oradata/ORCLCDB/orclpdb3/orclpdb3.xml';


Pluggable database altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 ORCLPDB1$SEED                  MOUNTED
         4 ORCLPDB1                       MOUNTED
         5 ORCLPDB2                       MOUNTED

SQL> col pdb_name for a15
SQL> select PDB_ID, PDB_NAME, STATUS from dba_pdbs

    PDB_ID PDB_NAME        STATUS
---------- --------------- ----------
         2 PDB$SEED        NORMAL
         3 ORCLPDB1$SEED   UNPLUGGED
         4 ORCLPDB1        UNPLUGGED
         5 ORCLPDB2        UNPLUGGED
```

drop

```
SQL> DROP PLUGGABLE DATABASE orclpdb1$seed KEEP DATAFILES;

Pluggable database dropped.

SQL> DROP PLUGGABLE DATABASE orclpdb1 KEEP DATAFILES;
DROP PLUGGABLE DATABASE orclpdb1 KEEP DATAFILES
*
ERROR at line 1:
ORA-65265: PDB cannot be dropped or unplugged.


SQL> DROP PLUGGABLE DATABASE orclpdb2 KEEP DATAFILES;

Pluggable database dropped.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         4 ORCLPDB1                       MOUNTED
SQL>
SQL> select PDB_ID, PDB_NAME, APPLICATION_ROOT, APPLICATION_PDB, APPLICATION_SEED, IS_PROXY_PDB, REFRESH_MODE, SNAPSHOT_MODE from dba_pdbs;
  PDB_ID PDB_NAME   APPLICATION_ROOT   APPLICATION_PDB   APPLICATION_SEED   IS_PROXY_PDB   REFRESH_MODE   SNAPSHOT_MODE
       2 PDB$SEED   NO                 NO                NO                 NO             NONE           MANUAL
       4 ORCLPDB1   YES                NO                NO                 NO             NONE           MANUAL
```

アプリケーションルート消せない??
でもリファレンス見てもアプリケーションルートだからって特別なやり方はない
あれ、もう一回やったら消せた
なんだろう

```
SQL> DROP PLUGGABLE DATABASE orclpdb1 KEEP DATAFILES;

Pluggable database dropped.

SQL> show pdbs
  CON_ID CON_NAME   OPEN MODE   RESTRICTED
       2 PDB$SEED   READ ONLY   NO
```