oracle12c 多租户管理四(容器连接切换)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle12c 多租户管理四(容器连接切换)相关的知识,希望对你有一定的参考价值。
一、本地连接
1.1、说明
alter session 切换容器的语法
ALTER SESSION SET CONTAINER = container_name [SERVICE = service_name]
For container_name, specify one of the following:
? CDB$ROOT to switch to the CDB root
? PDB$SEED to switch to the CDB seed
? A PDB name to switch to the PDB
When the current container is the root, you can view the names of the PDBs in a CDB by querying the DBA_PDBS view
1.2、连接cdb
[oracle@oracle18c1 admin]$ ps -ef |grep pmon
oracle 3739 1 0 20:39 ? 00:00:00 ora_pmon_mycdb
oracle 9642 3635 0 22:03 pts/0 00:00:00 grep --color=auto pmon
[oracle@oracle18c1 admin]$ export ORACLE_SID=mycdb
[oracle@oracle18c1 admin]$ sqlplus / as sysdba
SQL*Plus: Release 18.0.0.0.0 - Production on Sat May 16 22:03:11 2020
Version 18.3.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
2 PDB$SEED READ ONLY NO
3 MYPDB1 READ WRITE NO
4 MYPDB2 READ WRITE NO
5 YOUPDB MOUNTED
1.3、cdb和pdb间的切换
1、切换到seed容器
SQL> alter session set container=PDB$SEED;
Session altered.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
2 PDB$SEED READ ONLY NO
2、由seed容器切换到mypdb1
SQL> alter session set container=mypdb1;
Session altered.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
3 MYPDB1 READ WRITE NO
3、由mypdb1切换到根cdb
SQL> alter session set container=CDB$ROOT;
Session altered.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
2 PDB$SEED READ ONLY NO
3 MYPDB1 READ WRITE NO
4 MYPDB2 READ WRITE NO
5 YOUPDB MOUNTED
二、远程连接
1、连接cdb
[oracle@oracle18c1 admin]$ sqlplus sys/Pa44w0rd@192.168.5.40:1521/mycdb as sysdba
SQL*Plus: Release 18.0.0.0.0 - Production on Sat May 16 22:10:58 2020
Version 18.3.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
2 PDB$SEED READ ONLY NO
3 MYPDB1 READ WRITE NO
4 MYPDB2 READ WRITE NO
5 YOUPDB MOUNTED
2、连接mypdb1
[oracle@oracle18c1 admin]$ sqlplus sys/Pa44w0rd@192.168.5.40:1521/mypdb1 as sysdba
SQL*Plus: Release 18.0.0.0.0 - Production on Sat May 16 22:10:42 2020
Version 18.3.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
3 MYPDB1 READ WRITE NO
以上是关于oracle12c 多租户管理四(容器连接切换)的主要内容,如果未能解决你的问题,请参考以下文章