Oracle12c_PDB的拔插與刪除
這里簡單介紹了拔出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/中