oracle 12c连接cdb&pdb

-- 连接cdb
[oracle@centos7 admin]$ echo $ORACLE_SID
cdb1
[oracle@centos7 admin]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Oct 31 20:21:28 2017

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> col name for a30
SQL> col pdb for a30

SQL> select name,pdb from v$services order by 1;

NAME                           PDB
------------------------------ ------------------------------
SYS$BACKGROUND                 CDB$ROOT
SYS$USERS                      CDB$ROOT
cdb1                           CDB$ROOT
cdb1XDB                        CDB$ROOT
cdb1pdb                        CDB1PDB
pdb2                           PDB2

6 rows selected.

SQL> !lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 31-OCT-2017 20:22:50

Copyright (c) 1991, 2016, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=centos7)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                31-OCT-2017 19:36:42
Uptime                    0 days 0 hr. 46 min. 8 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.2.0.1/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/centos7/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=centos7)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "4d36dd6030861816e0537700a8c0d04c" has 1 instance(s).
  Instance "cdb1", status READY, has 1 handler(s) for this service...
Service "51a5f71f3ca751d9e0537700a8c0a651" has 1 instance(s).
  Instance "cdb1", status READY, has 1 handler(s) for this service...
Service "cdb1" has 1 instance(s).
  Instance "cdb1", status READY, has 1 handler(s) for this service...
Service "cdb1XDB" has 1 instance(s).
  Instance "cdb1", status READY, has 1 handler(s) for this service...
Service "cdb1pdb" has 1 instance(s).
  Instance "cdb1", status READY, has 1 handler(s) for this service...
Service "pdb2" has 1 instance(s).
  Instance "cdb1", status READY, has 1 handler(s) for this service...
The command completed successfully

SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@centos7 admin]$ sqlplus system/china@192.168.0.119:1521/cdb1

SQL*Plus: Release 12.2.0.1.0 Production on Tue Oct 31 20:23:18 2017

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Last Successful login time: Tue Oct 31 2017 20:17:04 +08:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SQL> 

-- 切换打开pdb,连接pdb

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SQL> SELECT SYS_CONTEXT('USERENV','CON_NAME') FROM   dual;

SYS_CONTEXT('USERENV','CON_NAME')
--------------------------------------------------------------------------------
CDB$ROOT

SQL> select con_id, dbid,guid, name , open_mode from v$pdbs;

    CON_ID       DBID GUID
---------- ---------- --------------------------------
NAME                           OPEN_MODE
------------------------------ ----------
         2 1332940455 4D36A3DE5D8FBD86E0537700A8C06944
PDB$SEED                       READ ONLY

         3 2399964300 4D36DD6030861816E0537700A8C0D04C
CDB1PDB                        MOUNTED

         4 4096555049 51A5F71F3CA751D9E0537700A8C0A651
PDB2                           MOUNTED


SQL> alter session set container=pdb2;

Session altered.

SQL> show con_name;

CON_NAME
------------------------------
PDB2
SQL> alter database pdb2 open;

Database altered.

SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@centos7 ~]$ >sqlplus system/china@192.168.0.119:1521/pdb2
-bash: system/china@192.168.0.119:1521/pdb2: No such file or directory
[oracle@centos7 ~]$ sqlplus system/china@192.168.0.119:1521/pdb2

SQL*Plus: Release 12.2.0.1.0 Production on Tue Oct 31 20:27:45 2017

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Last Successful login time: Tue Oct 31 2017 20:23:18 +08:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

朝闻道-夕死可矣

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值