본문 바로가기

Database/Oracle

14 - [Oracle 19C] Pluggable database - open, save

 

 

 

[oracle@test ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Nov 15 12:52:25 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle.  All rights reserved.
Connected to an idle instance.


SQL> startup;
ORACLE instance started.

Total System Global Area 1526723608 bytes
Fixed Size		    9135128 bytes
Variable Size		  889192448 bytes
Database Buffers	  620756992 bytes
Redo Buffers		    7639040 bytes
Database mounted.
Database opened.


SQL>
SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 ORCLPDB			  MOUNTED
SQL>


SQL> alter pluggable database orclpdb open;

Pluggable database altered.


SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 ORCLPDB			  READ WRITE NO
SQL>

 

 

to open/close the pluggable database 

 

SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 ORCLPDB			  MOUNTED

# to open orclpdb
SQL> alter pluggable database orclpdb open;

Pluggable database altered.

SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 ORCLPDB			  READ WRITE NO


# to open all pluggable database 
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 ORCLPDB			  READ WRITE NO

# to close orclpdb
SQL> alter pluggable database orclpdb close;

Pluggable database altered.

SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 ORCLPDB			  MOUNTED
SQL>

 

 

 

특정 pluggable database 로 이동하기

 

SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 ORCLPDB			  MOUNTED
SQL>
SQL>
SQL> alter session set container=orclpdb;

Session altered.

SQL> show con_name

CON_NAME
------------------------------
ORCLPDB
SQL>
SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 3 ORCLPDB			  MOUNTED
SQL>

 

 

특정 root 로 이동하기

 

SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 3 ORCLPDB			  MOUNTED
SQL>
SQL>
SQL> alter session set container=cdb$root
  2  ;

Session altered.

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 ORCLPDB			  MOUNTED
SQL>

 

 

디비상태 저장하기

 

-- 현재는 ORCLPDB 디비만 open 상태로 저장되어 있음
SQL> select con_name, state from dba_pdb_saved_states;

CON_NAME	     STATE
-------------------- --------------
ORCLPDB 	     OPEN


-- 특정 디비의 상태를 저장해서 인스턴스가 시작할때 저장된 상태로 시작함
-- pdb10 의 상태를 저장함, 현재 open 상태로 저장됨
SQL> alter pluggable database pdb10 save state;

Pluggable database altered.


-- pdb10 디비가 새로 추가됨을 확인, 상태는 open 으로 저장됨.
SQL> select con_name, state from dba_pdb_saved_states;

CON_NAME	     STATE
-------------------- --------------
ORCLPDB 	     OPEN
PDB10		     OPEN

 

 

 

 

 

'Database > Oracle' 카테고리의 다른 글

16 - [Oracle 19C] connecting using tnsnames.ora  (0) 2023.11.16
15 - [Oracle 19C] Easy connect method  (0) 2023.11.16
13 - [Oracle 19C] Listener  (0) 2023.11.15
12 - [Oracle 19C] Connecting sys user  (0) 2023.11.15
11 - [Oracle 19C] SQL Developer  (0) 2023.11.15