成都网站建设设计

将想法与焦点和您一起共享

CDB与PDB的连接

1.连接
sqlplus system/xxxxx@10.8.5.206:1521/pdbtest
ALTER SESSION SET CONTAINER = PDB$SEED;
2.再CDB中切换连接
C:\Users\Administrator>sqlplus / as sysdba

创新互联2013年至今,是专业互联网技术服务公司,拥有项目成都网站制作、成都做网站、外贸营销网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元怀柔做网站,已为上家服务,为怀柔各地企业和个人服务,联系电话:028-86922220

SQL*Plus: Release 12.2.0.1.0 Production on 星期五 12月 15 09:33:39 2017
Copyright (c) 1982, 2016, Oracle. All rights reserved.

连接到:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> show con_name
CON_NAME

CDB$ROOT
SQL> select name from v$pdbs;
NAME

PDB$SEED
PDBTEST
CLONEPDB_PLUG
SQL> alter session set container=PDBTEST;

会话已更改。
SQL> select name from v$pdbs;

NAME
-------------------------------------------------------------------------------- PDBTEST

SQL> show con_name

CON_NAME

PDBTEST
SQL> alter session set container=CLONEPDB_PLUG;

会话已更改。

SQL> show con_name

CON_NAME
------------------------------ CLONEPDB_PLUG
3.CDB实例关闭与启动
3.1关闭
C:\Users\Administrator>sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on 星期五 12月 15 09:40:41 2017

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

连接到:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> shutdown immediate
数据库已经关闭。
已经卸载数据库
ORACLE 例程已经关闭。
3.2 启动道nomount状态
SQL> startup nomount ORACLE 例程已经启动。

Total System Global Area 2768240640 bytes
Fixed Size 8922760 bytes Variable Size 704645496 bytes Database Buffers 2046820352 bytes Redo Buffers 7852032 bytes
SQL> set line 200
SQL> col con_id format A40
SQL> col name format A20
SQL> col open_mode format A20
SQL> select con_id,name,open_mode from v$pdbs;

未选定行
3.3打开到mount状态
SQL> alter database mount;

数据库已更改。

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

CON_ID NAME                 OPEN_MODE                                                                               ---------- -------------------- --------------------

########## PDB$SEED MOUNTED
########## PDBTEST MOUNTED
########## CLONEPDB_PLUG MOUNTED
3.3打开数据库
SQL> alter database open;

数据库已更改。

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

CON_ID NAME                 OPEN_MODE

########## PDB$SEED READ ONLY
########## PDBTEST MOUNTED
########## CLONEPDB_PLUG MOUNTED
4.PDB打开与关闭
4.1打开一个
SQL> alter pluggable database pdbtest open read write;

插接式数据库已变更。

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

CON_ID NAME                 OPEN_MODE

########## PDB$SEED READ ONLY
########## PDBTEST READ WRITE
########## CLONEPDB_PLUG MOUNTED
4.2关闭一个
5.SQL> alter pluggable database pdbtest close;

插接式数据库已变更。

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

CON_ID NAME                 OPEN_MODE

########## PDB$SEED READ ONLY
########## PDBTEST MOUNTED
########## CLONEPDB_PLUG MOUNTED
4.3全部打开/关闭
SQL> alter pluggable database all open read write;

插接式数据库已变更。

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

CON_ID NAME                 OPEN_MODE

########## PDB$SEED READ ONLY
########## PDBTEST READ WRITE
########## CLONEPDB_PLUG READ WRITE
SQL> alter pluggable database all close;

插接式数据库已变更。

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

CON_ID NAME                 OPEN_MODE

########## PDB$SEED READ ONLY
########## PDBTEST MOUNTED
########## CLONEPDB_PLUG MOUNTED
4.4排他打开
SQL> alter pluggable database all except PDBTEST open read write;

插接式数据库已变更。

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

CON_ID NAME                 OPEN_MODE

########## PDB$SEED READ ONLY
########## PDBTEST MOUNTED
########## CLONEPDB_PLUG READ WRITE
SQL> alter pluggable database all except PDBTEST close;

插接式数据库已变更。

SQL> select con_id,name,open_mode from v$pdbs;
CON_ID NAME OPEN_MODE


########## PDB$SEED READ ONLY
########## PDBTEST MOUNTED
########## CLONEPDB_PLUG MOUNTED

5.改变PDB状态
SQL> col con_id format 999999
SQL> col name format A20
SQL> col open_mode format A20
SQL> set line 100
SQL> select con_id,name,open_mode from v$pdbs;

CON_ID NAME OPEN_MODE


  2 PDB$SEED             READ ONLY
  3 PDBTEST              MOUNTED
  4 CLONEPDB_PLUG        MOUNTED

SQL> alter pluggable database PDBTEST open restricted;
SQL> select con_id,name,open_mode from v$pdbs;

CON_ID NAME OPEN_MODE ------- -------------------- -------------------- 2 PDB$SEED READ ONLY 3 PDBTEST READ WRITE 4 CLONEPDB_PLUG MOUNTED
SQL> show pdbs

CON_ID CON_NAME                       OPEN MODE  RESTRICTED

     2 PDB$SEED                       READ ONLY  NO
     3 PDBTEST                        READ WRITE YES
     4 CLONEPDB_PLUG                  MOUNTED

SQL> alter pluggable database PDBTEST close;

插接式数据库已变更。

SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED


     2 PDB$SEED                       READ ONLY  NO
     3 PDBTEST                        MOUNTED                                                                                4 CLONEPDB_PLUG                  MOUNTED

分享题目:CDB与PDB的连接
文章源于:http://chengdu.cdxwcx.cn/article/ggihco.html