码迷,mamicode.com
首页 > 数据库 > 详细

oracle12c 多租户管理四(容器连接切换)

时间:2020-05-17 10:34:11      阅读:91      评论:0      收藏:0      [点我收藏+]

标签:rod   mod   nta   roo   switch   cdb   租户   sysdba   rac   

一、本地连接
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 多租户管理四(容器连接切换)

标签:rod   mod   nta   roo   switch   cdb   租户   sysdba   rac   

原文地址:https://blog.51cto.com/jiujian/2495905

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!