Oracle12c_PDB的拔插與刪除

shilei1發表於2017-08-23
這裡簡單介紹了拔出PDB,刪除PDB,插入PDB的操作方法:

1、unplug PDB

檢視PDB資訊:

SQL> select name,open_mode from v$pdbs;

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PDB_1                          READ WRITE
PDB_2                          READ WRITE
PDB_3                          READ WRITE
PDB_4                          READ WRITE

SQL> show con_name;

CON_NAME
------------------------------
CDB$ROOT

拔出PDB_4(必須連線到CDB$ROOT):

首先關閉PDB_4

SQL> alter pluggable database pdb_4 close immediate;

Pluggable database altered.

然後就可以unplug

SQL>  alter pluggable database pdb_4 unplug into '/home/oracle/unplugged_pdbs/pdb_4.xml';

Pluggable database altered.

XML檔案中包含了每個資料檔案的位置,以及初始化引數等資訊。

2、drop PDB

關閉並且拔出PDB後才可以進行刪除,刪除時可以一起刪除資料檔案:

同樣需要連線到CDB$ROOT容器,執行下列語句:

SQL> drop pluggable database pdb_4 keep datafiles;  

Pluggable database dropped.

SQL> select name,open_mode from v$pdbs;

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PDB_1                          READ WRITE
PDB_2                          READ WRITE
PDB_3                          READ WRITE

這裡使用了keep datafiles保留了PDB_4的資料檔案。另外,也可以使用inluding datafiles徹底刪除PDB的資料檔案。

3、plug an unplugged PDB

plug PDB_4:

SQL> create pluggable database pdb_4_replug using '/home/oracle/unplugged_pdbs/pdb_4.xml' nocopy tempfile reuse;

Pluggable database created.

SQL> select name from v$pdbs;

NAME
------------------------------
PDB$SEED
PDB_1
PDB_2
PDB_3
PDB_4_REPLUG

SQL> select name,open_mode from v$pdbs;

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PDB_1                          READ WRITE
PDB_2                          READ WRITE
PDB_3                          READ WRITE
PDB_4_REPLUG                   MOUNTED

上述create pluggable database語句中,因為資料檔案都在xml檔案指定的位置,且仍使用原來的位置作為新

的pdb的資料檔案的儲存位置,因此沒有包含其他子句。

另外一條plug PDB的語句也可能如下:

CREATE PLUGGABLE DATABASE pdbname
USING '/location/filename.xml'
SOURCE_FILE_NAME_CONVERT=('/location1/','/location2/')
MOVE
FILE_NAME_CONVERT=('/location2/','/location3/')
PATH_PREFIX='/location3/'
STORAGE (MAXSIZE 2G MAX_SHARED_TEMP_SIZE 100M);

這裡xml檔案中指示資料檔案在/location1/中,而實際上資料檔案在/location2/中,且最終我們要將資料檔案

放在/location3/中

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

相關文章