Oracle12c多租戶如何連接到CDB或PDB、CDB與PDB容器切換
Oracle 數據庫 12 c 多租戶選項允許單個容器數據庫 (CDB) 來承載多個單獨的可插拔數據庫 (PDB)。
那麽我們如何連接到容器數據庫 (CDB) 和可插拔數據庫 (PDB)。
1. V$SERVICES視圖可以顯示數據庫中的可用服務。
SQL> col pdb for a40
SQL> col name for a30;
SELECT name, pdb FROM v$services ORDER BY name;SQL>
NAME PDB
------------------------------ ----------------------------------------
SYS$BACKGROUND CDB$ROOT
SYS$USERS CDB$ROOT
andycdb CDB$ROOT
andycdbXDB CDB$ROOT
pdb01 PDB01
-- lsnrctl實用程序顯示可用的服務。
[[email protected]
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=12c01)(PORT=1521)))
Services Summary...
Service "4ecf8621e3da38eee0531019640aa598" has 1 instance(s).
Instance "andycdb", status READY, has 1 handler(s) for this service...
Service "andycdb" has 1 instance(s).
Instance "andycdb", status READY, has 1 handler(s) for this service...
Service "andycdbXDB" has 1 instance(s).
Instance "andycdb", status READY, has 1 handler(s) for this service...
Service "pdb01" has 1 instance(s).
Instance "andycdb", status READY, has 1 handler(s) for this service...
The command completed successfully
2.直接連接到一個容器數據庫 (CDB)
連接到數據庫的根容器和連接以前版本的單個數據庫實例相同。在數據庫服務器上,您可以使用操作系統身份驗證。
方法一:
[[email protected] ~]$ sqlplus / as sysdba
方法二:
或者 tnsnames.ora 文件配置
ANDYCDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 12c01)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = andycdb)
)
)
C:\Users\andy>sqlplus [email protected]