Oracle PDB库下连接用户

pdb下查询service_name

SQL>alter session set container=orcl;(进入pdb)
SQL>show con_name;
SQL> select name,pdb from v$services;(查询service_name)

编辑tnsnames文件

vi tnsnames.ora  编辑tnsnames文件,添加下面内容
ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)       把查询到pdb对应的service_name写到这里
    )
  )

测试

SQL> conn scott/oracle@ORCL
Connected.
SQL> show user
USER is "SCOTT"
连接成功!

你可能感兴趣的:(数据库,linux,oracle)