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 viewsql

1.二、鏈接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 sysdbasession

SQL*Plus: Release 18.0.0.0.0 - Production on Sat May 16 22:03:11 2020
Version 18.3.0.0.0oracle

Copyright (c) 1982, 2018, Oracle. All rights reserved.ide

Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0code

SQL> show pdbs;ci

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和pdb間的切換
一、切換到seed容器
SQL> alter session set container=PDB$SEED;it

Session altered.io

SQL> show pdbs;class

CON_ID CON_NAME           OPEN MODE  RESTRICTED

2 PDB$SEED                 READ ONLY  NO

二、由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

三、由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

2、遠程鏈接

一、鏈接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

二、鏈接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
相關文章
相關標籤/搜索