The connection between CDB and PDB
1. Connect
Sqlplus system/xxxxx@10.8.5.206:1521/pdbtest
ALTER SESSION SET CONTAINER = PDB$SEED
two。 Switch connections in CDB
C:\ Users\ Administrator > sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Friday December 15 09:33:39 2017
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connect to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0-64bit Production
SQL > show con_name
CON_NAMECDB$ROOT
SQL > select name from v$pdbs
NAME
PDB$SEED
PDBTEST
CLONEPDB_PLUG
SQL > alter session set container=PDBTEST
The session has changed.
SQL > select name from v$pdbs
NAME
-PDBTEST
SQL > show con_name
CON_NAME
PDBTEST
SQL > alter session set container=CLONEPDB_PLUG
The session has changed.
SQL > show con_name
CON_NAME
-- CLONEPDB_PLUG
3.CDB instance shutdown and startup
3.1 close
C:\ Users\ Administrator > sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Friday December 15 09:40:41 2017
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connect to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0-64bit Production
SQL > shutdown immediate
The database has been closed.
Database has been uninstalled
The ORACLE routine has been closed.
3.2 Startup channel nomount status
The SQL > startup nomount ORACLE routine has been started.
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
No rows selected
3.3.Open to mount status
SQL > alter database mount
The database has changed.
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 Open the database
SQL > alter database open
The database has changed.
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 on and off
4.1 Open a
SQL > alter pluggable database pdbtest open read write
The plug-in database has changed.
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 close a
5.SQL > alter pluggable database pdbtest close
The plug-in database has changed.
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 turn all on / off
SQL > alter pluggable database all open read write
The plug-in database has changed.
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
The plug-in database has changed.
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 platoon, open it.
SQL > alter pluggable database all except PDBTEST open read write
The plug-in database has changed.
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
The plug-in database has changed.
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. Change the state of 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
The plug-in database has changed.
SQL > show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
2 PDB$SEED READ ONLY NO 3 PDBTEST MOUNTED 4 CLONEPDB_PLUG MOUNTED