1.用sys用戶登錄orcl;
查詢pdb
show pdbs;
2.打開指定pdb
alter pluggable database
PDBNAME open ;
3.這里修改tnsname.ora這個文件,添加一個pdb的記錄,就可以連接pdb:
# tnsnames.ora Network Configuration File: D:\app\yrh\virtual\product\12.2.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
#cdb
MYORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
(CONNECT_DATA =
# (SERVER = DEDICATED) #我的文件中這一行加上會報錯
(SERVICE_NAME = orcl) #cdb的db_name
)
)
#pdb 這里主要是加上pdb的記錄
ORCLPDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
# (SERVER = DEDICATED)
#我的文件中這一行加上會報錯
(SERVICE_NAME =
orclpdb)
#與查詢的pdb對應
)
)
4.SQL> create user yrhtest identified by ******;
用戶已創建。
SQL> grant connect to yrhtest;
授權成功。
SQL> conn yrhtest/******@
orclpdb;
#用創建的pdb記錄進行連接
已連接。
