這篇文章主要介紹CDB和PDB的基本管理,資料來源oracle官方。
基本概念:
Multitenant Environment:多租戶環境
CDB(Container Database):資料庫容器
PD(Pluggable Database):可插拔資料庫
CDB與PDB關係圖
COMMON USERS(普通使用者):經常建立在CDB層,使用者名稱以C##或c##開頭;
LOCAL USERS(本機使用者):僅建立在PDB層,建立的時候得指定CONTAINER。
在oracle 12c中,使用了一個container(容器)的概念,讓我們先看看官方的對它的介紹,為了保留最原始的意思,這裡引用英文而不翻譯了。
The data dictionary in each container in a CDB is separate, and the current container is the container whose data dictionary is used for name resolution and for privilege authorization. The current container can be the root or a PDB. Each session has exactly one current container at any point in time, but it is possible for a session to switch from one container to another.
Each container has a unique ID and name in a CDB. You can use the CON_ID and CON_NAME parameters in the USERENV namespace to determine the current container ID and name with the SYS_CONTEXT function.
1、查看Oracle 12c的版本
SQL> select * from v$version;
SQL>select sys_context ('USERENV', 'CON_NAME') from dual; SYS_CONTEXT('USERENV','CON_NAME') ---------------------------------------------------------------------------------------------------- CDB$ROOT
2、我們可以通過ALTER SESSION SET CONTAINER 指定其他容器
SQL>select con_id,dbid,NAME,OPEN_MODE from v$pdbs;
3、將Pdb open:
SQL> alter pluggable database pdborcl open;
4、查看容器
SQL>select con_id,dbid,NAME,OPEN_MODE from v$pdbs;
5、切換容器到pdb
SQL> alter session set container=PDBORCL;
6、查看當前使用容器
SQL>select sys_context ('USERENV', 'CON_NAME') from dual;
7、建立使用者
SQL>create user informix identified by gmgl;SQL>grant dba to informix;