oracle pdb模式创建用户连接
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记录进行连接
已连接。