-- 连接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>
oracle 12c连接cdb&pdb
最新推荐文章于 2024-05-16 15:33:38 发布