1、默认登陆到CDB
<roidb01:cdb:/home/oracle>$sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Sat Jan 20 11:01:46 2018
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to an idle instance.
2、启动CDB
SQL> startup
ORACLE instance started.
Total System Global Area 1560281088 bytes
Fixed Size 2924784 bytes
Variable Size 956305168 bytes
Database Buffers 587202560 bytes
Redo Buffers 13848576 bytes
Database mounted.
Database opened.
3、查看容器名
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
4、查看pdb
默认会有一个PDB$SEED,PDB1是通过模版创建的。
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1 MOUNTED
5、默认pdb未启动,手动启动pdb
SQL> alter pluggable database all open;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1 READ WRITE NO
6、关闭pdb
SQL> alter pluggable database pdb1 close;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1 MOUNTED
7、pdb只读打开
SQL> alter pluggable database pdb1 open read only;
Pluggable database altered.
8、切换到pdb1
SQL> alter session set container=pdb1 ;
Session altered.
SQL> show con_name
CON_NAME
------------------------------
PDB1
9、也可以这样启动pdb
SQL> shutdown immediate;
Pluggable Database closed.
SQL> startup
Pluggable Database opened.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
3 PDB1 READ WRITE NO
10、切换到cdb,关闭cdb的同时,pdb也会跟着关闭
SQL> alter session set container=CDB$ROOT;
Session altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
原文地址:http://blog.51cto.com/roidba/2063116