[ORACLE] ORACLE 193 pdb 创建与pdb/cdba切换

Posted A running snail,little step ev

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[ORACLE] ORACLE 193 pdb 创建与pdb/cdba切换相关的知识,希望对你有一定的参考价值。

  1. 创建PDB
  2. PDB/CDB 切换

 

 

Container IDRows pertain to

0

Whole CDB, or non-CDB

1

CDB$ROOT

2

PDB$SEED

All Other IDs

User-Created PDBs

 

 https://docs.oracle.com/database/121/CNCPT/cdblogic.htm#CNCPT89459

1.创建PDB

SQL> select pdb_name,status from cdb_pdbs ; 

PDB_NAME                                                             STATUS
-------------------------------------------------------------------------------------------------------------------------------- ----------
D3CPDB                                                                 NORMAL
PDB$SEED                                                             NORMAL

SQL> create pluggable database D4CPDB admin user D4CPDB_admin identified by "12345678" roles=(dba) file_name_convert=(\'/oracle/D4C/oradata/D4CDB/pdbseed\',\'/oracle/D4C/oradata/D4CDB/D4CPDB\') ; 

Pluggable database created.

SQL> select pdb_name,status from cdb_pdbs ; 

PDB_NAME                                                             STATUS
-------------------------------------------------------------------------------------------------------------------------------- ----------
D3CPDB                                                                 NORMAL
PDB$SEED                                                             NORMAL
D4CPDB                                                                 NEW

SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;

    CON_ID     DBID NAME                                                                   OPEN_MODE
---------- ---------- -------------------------------------------------------------------------------------------------------------------------------- ----------
     2  482843019 PDB$SEED                                                                   READ ONLY
     3   50879882 D3CPDB                                                                   READ WRITE
     4 3947681941 D4CPDB                                                                   MOUNTED

SQL> alter PLUGGABLE database D4CPDB open;

Pluggable database altered.

SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;

    CON_ID     DBID NAME                                                                   OPEN_MODE
---------- ---------- -------------------------------------------------------------------------------------------------------------------------------- ----------
     2  482843019 PDB$SEED                                                                   READ ONLY
     3   50879882 D3CPDB                                                                   READ WRITE
     4 3947681941 D4CPDB                                                                   READ WRITE

SQL> alter PLUGGABLE database D4CPDB close;

Pluggable database altered.

SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;

    CON_ID     DBID NAME                                                                   OPEN_MODE
---------- ---------- -------------------------------------------------------------------------------------------------------------------------------- ----------
     2  482843019 PDB$SEED                                                                   READ ONLY
     3   50879882 D3CPDB                                                                   READ WRITE
     4 3947681941 D4CPDB                                                                   MOUNTED

2.PDB/CDB 切换

#切换PDB
SQL> alter session set container=D3CPDB; Session altered. SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs; CON_ID DBID NAME OPEN_MODE ---------- ---------- -------------------------------------------------------------------------------------------------------------------------------- ---------- 3 50879882 D3CPDB READ WRITE SQL> show con_name; CON_NAME ------------------------------ D3CPDB
#切换PDB#SEED SQL
> alter session set container=PDB$SEED; Session altered. SQL> show con_name; CON_NAME ------------------------------ PDB$SEED SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 D3CPDB READ WRITE NO 4 D4CPDB READ WRITE NO SQL> alter pluggable database all close immediate ; Pluggable database altered. SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 D3CPDB MOUNTED 4 D4CPDB MOUNTED SQL> alter session set container=D3CPDB; Session altered. SQL> show con_name CON_NAME ------------------------------ D3CPDB #切换CDB SQL> alter session set container=CDB$ROOT; Session altered. SQL> show con_name CON_NAME ------------------------------ CDB$ROOT

 

以上是关于[ORACLE] ORACLE 193 pdb 创建与pdb/cdba切换的主要内容,如果未能解决你的问题,请参考以下文章

如何对接oracle 建立pdb

oracle用PDB的管理用户登录后需要密码

oracle 12c连接pdb

oracle 12c 怎样配置TNS来访问PDB

Oracle12C新特性——cdb与pdb

oracle19c切换PDB服务器