pdb的plug、unplug、drop---oracle 12c 學習(2)

lsq_008發表於2014-12-09
---將pdb plug到新cdb中
1.在源資料庫建立pdb的xml檔案

BEGIN
  DBMS_PDB.DESCRIBE(
    pdb_descr_file => '/home/oracle/xjny.xml',
    pdb_name       => 'XJNY');
END;
/

2.在目標資料庫檢查pdb的xml是否與目標庫相容
SET SERVEROUTPUT ON
DECLARE
  compatible CONSTANT VARCHAR2(3) := 
    CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(
           pdb_descr_file => '/home/oracle/xjny.xml',
           pdb_name       => 'SALESPDB')
    WHEN TRUE THEN 'YES'
    ELSE 'NO'
END;
BEGIN
  DBMS_OUTPUT.PUT_LINE(compatible);
END;
/

3. 將pdb資料庫plug到新的cdb中,在新cdb中執行

CREATE PLUGGABLE DATABASE ebs USING '/home/oracle/xjny.xml' 
  NOCOPY 
  TEMPFILE REUSE;

4.開啟新的pdb
alter pluggable database ebs open;

------將pdb從cdb中unplug

SQL> alter pluggable database ebs close;

Pluggable database altered.

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

Pluggable database altered.

SQL> select pdb_id,pdb_name,dbid,con_uid,status,con_id from dba_pdbs;


    PDB_ID PDB_NAME         DBID    CON_UID STATUS        CON_ID
---------- ---------- ---------- ---------- --------- ----------
         3 XJNY       3977202490 3977202490 NORMAL             3
         2 PDB$SEED   4264868981 4264868981 NORMAL             2
         4 WAPDB      4211777660 4211777660 NORMAL             4
         5 MBS        1281880106 1281880106 NORMAL             5
         6 EBS        1440704945 1440704945 UNPLUGGED          6

如果不再需要pdb,或者要將pdb plug到新的cdb中,需要drop 掉cdb

SQL> DROP PLUGGABLE DATABASE ebs INCLUDING DATAFILES;

Pluggable database dropped.

SQL> select pdb_id,pdb_name,dbid,con_uid,status,con_id from dba_pdbs;

    PDB_ID PDB_NAME         DBID    CON_UID STATUS        CON_ID
---------- ---------- ---------- ---------- --------- ----------
         3 XJNY       3977202490 3977202490 NORMAL             3
         2 PDB$SEED   4264868981 4264868981 NORMAL             2
         4 WAPDB      4211777660 4211777660 NORMAL             4
         5 MBS        1281880106 1281880106 NORMAL             5

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10972173/viewspace-1361997/,如需轉載,請註明出處,否則將追究法律責任。

相關文章