天天看點

每日一記:oracle 12c手工建立新pdb:create pluggable database newpdbname from oldpdbname...

在12c中,可以像sql server一樣在一個執行個體中建立多個資料庫,oracle的這種資料庫叫“可插拔資料庫”。

作為一名合格的dba必須要學會手動建立pdb,掌握其原理。

確定目前位于根容器(cdb$root)中:

SQL> show con_name

CON_NAME

------------------------------

CDB$ROOT

根據舊pdb(oldpdbname)建立新pdb(newpdbname),必要參數file_name_convert,值的格式為('舊pdb資料檔案目錄','新pdb資料檔案目錄');

最簡的建立語句:

create pluggable database newpdbname from oldpdbname

file_name_convert =('E:\app\oracle\oradata\orcl\oldpdbname','E:\app\oracle\oradata\orcl\newpdbname');

當然,我們可以充分利用12c的新特性storage,可以限制這個新pdb資料庫的所有資料檔案和臨時檔案的總大小(MAXSIZE)和共享臨時表空間的大小(MAX_SHARED_TEMP_SIZE )。如果省略此參數,或指定STORAGE UNLIMITED,則PDB沒有存儲限制。這相當于指定STORAGE(MAXSIZE UNLIMITED MAX_SHARED_TEMP_SIZE UNLIMITED)。

如:

create pluggable database newpdbname from oldpdbname

file_name_convert =('E:\app\oracle\oradata\orcl\oldpdbname','E:\app\oracle\oradata\orcl\newpdbname') 

storage (maxsize 30g max_shared_temp_size 200m);