1. 程式人生 > >oracle 18c 18.3 學習之四 create pdb

oracle 18c 18.3 學習之四 create pdb

os: centos 7.4
db: oracle 18c(18.3)

使用 dbca 建庫時建立的是CDB,順帶建立了一個 pdbpeiyb,現在再建立如下幾個pdb。

pdbshenz
pdbguangz
pdbdongg

使用了幾種方式建立pdb,大同小異。

使用 dbca 建立 pdbshenz

# xhost +
# su - oracle
$ export DISPLAY=:0.0
$ xhost +
$ dbca

點選步驟
“Manage Pluggable databases”
“Create a Pluggable database”
如果 OS based authentication 禁止了,就需要輸入 使用者名稱,密碼。
“Create a new Pluggable database from another PDB” 選擇 PDB$SEED
“Pluggable database name” 輸入 pdbshenz,“Administrator user name” 輸入 pdbadminshenz,密碼自己設定。
“PDB storage options” 沒有需要修改的就使用預設設定,主要勾選中 “Create default user tablespace”
最後會有個提示
“Pluggable database pdbshenz plugged successfully”

OK,pdbshenz 就算建立好了。
使用 dbca 方式就是簡單快捷,圖形頁面鉤鉤點點就搞定了。

$ sqlplus / as sysdba;

SQL*Plus: Release 18.0.0.0.0 - Production on Sat Nov 24 05:07:49 2018
Version 18.3.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.


Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0

SQL> show pdbs;

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 PDBPEIYB			  READ WRITE NO
	 4 PDBSHENZ			  READ WRITE NO
SQL> 

使用 sqlplus using seed 建立 pdbguangz

$ sqlplus / as sysdba;

SQL> CREATE PLUGGABLE DATABASE pdbguangz 
ADMIN USER pdbadminguangz IDENTIFIED BY rootroot 
ROLES=(DBA) 
DEFAULT TABLESPACE users LOGGING
        DATAFILE '/u01/app/oracle/oradata/ORCL/pdbguangz/users01.dbf' SIZE 250M REUSE AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED  EXTENT MANAGEMENT LOCAL  SEGMENT SPACE MANAGEMENT  AUTO
file_name_convert=('/u01/app/oracle/oradata/ORCL/pdbseed/',
                   '/u01/app/oracle/oradata/ORCL/pdbguangz/')  
STORAGE ( MAXSIZE UNLIMITED 
          MAX_SHARED_TEMP_SIZE UNLIMITED
		 )
PATH_PREFIX = '/u01/app/oracle/oradata/ORCL/pdbguangz/';
      
 
SQL> alter pluggable database pdbguangz open;

SQL> show pdbs;

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 PDBPEIYB			  READ WRITE NO
	 4 PDBSHENZ			  READ WRITE NO
	 5 PDBGUANGZ			  READ WRITE NO
	 

建立成功。

使用 sqlplus cloning 建立 pdbdongg

以 pdbpeiyb 為源 克隆,必須確保 pdbpeiyb 為 open 狀態
from 形式


$ sqlplus / as sysdba;


SQL> CREATE PLUGGABLE DATABASE pdbdongg FROM pdbpeiyb
FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/ORCL/pdbpeiyb/', 
                     '/u01/app/oracle/oradata/ORCL/pdbdongg/')
STORAGE UNLIMITED                      
PATH_PREFIX = '/u01/app/oracle/oradata/ORCL/pdbdongg/';

SQL> alter pluggable database pdbdongg open;

SQL> show pdbs;

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 PDBPEIYB			  READ WRITE NO
	 4 PDBSHENZ			  READ WRITE NO
	 5 PDBGUANGZ			  READ WRITE NO
	 6 PDBDONGG			  READ WRITE NO

或者 as clone 形式

SQL> CREATE PLUGGABLE DATABASE pdbdongg as clone
using  '/u01/app/oracle/unplug_pdb/PDBPEIYB.xml'
copy
FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/ORCL/pdbpeiyb/', 
                     '/u01/app/oracle/oradata/ORCL/pdbdongg/')
STORAGE UNLIMITED 
PATH_PREFIX = '/u01/app/oracle/oradata/ORCL/pdbdongg/';

SQL> alter pluggable database pdbdongg open;

參考:
https://docs.oracle.com/en/database/oracle/oracle-database/18/sqlrf/CREATE-PLUGGABLE-DATABASE.html#GUID-F2DBA8DD-EEA8-4BB7-A07F-78DC04DB1FFC
https://docs.oracle.com/en/database/oracle/oracle-database/18/sqlrf/ALTER-PLUGGABLE-DATABASE.html#GUID-A29491AD-8F0F-4E52-9D94-57FC3FF8FBC7