1.啟動CDB和PDB數(shù)據庫
創(chuàng)新互聯(lián)成都網站建設定制網站制作,是成都網站營銷公司,為社區(qū)文化墻提供網站建設服務,有成熟的網站定制合作流程,提供網站定制設計服務:原型圖制作、網站創(chuàng)意設計、前端HTML5制作、后臺程序開發(fā)等。成都網站維護熱線:18982081108
SQL> select con_id,dbid,name,open_mode from v$pdbs;
CON_ID DBID NAME OPEN_MODE
---------- ---------- ------------------------------ ----------
2 1226396669 PDB$SEED READ ONLY
3 411454583 DB12CCD MOUNTED
SQL> alter pluggable database all open;
Pluggable database altered.
SQL> select con_id,dbid,name,open_mode from v$pdbs;
CON_ID DBID NAME OPEN_MODE
---------- ---------- ------------------------------ ----------
2 1226396669 PDB$SEED READ ONLY
3 411454583 DB12CCD READ WRITE
2.創(chuàng)建PDB數(shù)據庫
SQL> select name,cdb from v$database;
NAME CDB
--------- ---
DB12C YES
SQL> select pdb_id,pdb_name,dbid,status,creation_scn from dba_pdbs;
PDB_ID PDB_NAME DBID STATUS CREATION_SCN
---------- -------------------- ---------- --------- ------------
3 DB12CCD 411454583 NORMAL 1744330
2 PDB$SEED 1226396669 NORMAL 1594399
SQL> create pluggable database test admin user test identified by test file_name_convert=('/u01/app/oracle/oradata/cdb/pdbseed/','/u01/app/oracle/oradata/cdb/test/');
Pluggable database created.
create pluggable database test1 admin user test1 identified by test1 file_name_convert=('/u01/app/oracle/oradata/cdb/test/','/u01/app/oracle/oradata/cdb/test1/');
3.建立連接
--進入cdb
sqlplus / as sysdba
sqlplus sys/sys@192.168.10.32:1521/cdb as sysdba
--進入pdb
3.1)通過tns方式用創(chuàng)建的admin user登錄
[oracle@ora12cA ~]$ sqlplus sys/oracle@192.168.10.32:1521/test as sysdba
SQL> show con_name
CON_NAME
------------------------------
TEST
--查看admin user擁有的權限
SQL> select * from session_privs;
PRIVILEGE
----------------------------------------
SET CONTAINER
CREATE PLUGGABLE DATABASE
CREATE SESSION
3.2)通過set container來連接pdb
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB MOUNTED
4 TEST READ WRITE NO
SQL> alter session set container=test;
Session altered.
SQL> show con_name
CON_NAME
------------------------------
TEST
4.打開和關閉pdb
SQL>alter pluggable database all close immediate;
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB MOUNTED
4 TEST MOUNTED
--打開單個pdb
SQL> alter pluggable database pdb open;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB READ WRITE NO
4 TEST MOUNTED
--打開所有pdb
SQL> alter pluggable database all open;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB READ WRITE NO
4 TEST READ WRITE NO
--關閉所有pdb
SQL> alter pluggable database all close immediate;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB MOUNTED
4 TEST
5.創(chuàng)建用戶。
1).概述
在cdb默認是container=all,在cdb中只能創(chuàng)建全局用戶;
在pdb默認是container=current,在pdb只能創(chuàng)建本地用戶。
http://dovelauren.blog.51cto.com/9876026/1719310
如果在cdb中創(chuàng)建用戶會在cdb和所有的pdb中創(chuàng)建該用戶,但是pdb中的全局用戶需要另外授權才能夠在pdb中訪問)。
2).創(chuàng)建全局用戶
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> create user c##t identified by t;
User created.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB READ WRITE NO
4 PDB1 READ WRITE NO
3).創(chuàng)建本地用戶
SQL> alter session set container=pdb1;
Session altered.
SQL> create user t identified by t;
User created.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
4 PDB1 READ WRITE NO
6.用戶授權
用戶授權默認情況下是只會給當前container,在cdb中也可以指定container=all,對所有open的pdb且存在該用戶都進行授權
Connected.
SQL> grant connect,resource to c##t;
Grant succeeded.
SQL> grant connect,resource to c##t container=all;
Grant succeeded.
7.修改參數(shù)
在cdb中修改,pdb會繼承進去;如果在pdb中修改會覆蓋pdb從cdb中繼承的參數(shù)含義
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> show parameter open_cursors
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
open_cursors integer 300
SQL> alter system set open_cursors=500;
System altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB READ WRITE NO
4 PDB1 READ WRITE NO
SQL> alter session set container=pdb1;
Session altered.
SQL> show parameter open_cursors
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
open_cursors integer 500
SQL> alter system set open_cursors=100;
System altered.
SQL> show parameter open_cursors
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
open_cursors integer 100
SQL> show con_name
CON_NAME
------------------------------
PDB1
SQL> alter session set container=CDB$ROOT;
Session altered.
SQL> show parameter open_cursors
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
open_cursors integer 500