cdb与pdb的一些常用查询命令

Posted msdnchina

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了cdb与pdb的一些常用查询命令相关的知识,希望对你有一定的参考价值。

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Sat Mar 5 19:57:04 2016

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SQL> select name,cdb from v$database;--->>>检查一个db是不是cdb

NAME	  CDB
--------- ---
ORCL	  YES

SQL> 


--->>>检查pdb的状态
SQL> SELECT con_id,NAME,OPEN_MODE,restricted from v$PDBS;

    CON_ID NAME 			  OPEN_MODE  RES
---------- ------------------------------ ---------- ---
	 2 PDB$SEED			  READ ONLY  NO
	 3 PN1				  MOUNTED
	 4 PN2				  MOUNTED

SQL> 

--->>>检查一个pdb内可用的services
SQL> SELECT con_id,NAME,OPEN_MODE,restricted from v$PDBS;

    CON_ID NAME 			  OPEN_MODE  RES
---------- ------------------------------ ---------- ---
	 2 PDB$SEED			  READ ONLY  NO
	 3 PN1				  MOUNTED
	 4 PN2				  MOUNTED

SQL> show con_name 

CON_NAME
------------------------------
CDB$ROOT
SQL> alter session set container=pn1;

Session altered.
SQL> alter pluggable database pn1 open;

Pluggable database altered.

SQL> SELECT con_id,NAME,OPEN_MODE,restricted from v$PDBS;

    CON_ID NAME 			  OPEN_MODE  RES
---------- ------------------------------ ---------- ---
	 3 PN1				  READ WRITE NO

SQL> set lines 100
SQL> col name format a20
SQL> col network_name format a20
SQL> col pdb format a20
SQL>select service_id,name,network_name,global_service,pdb,enabled from dba_services;
SERVICE_ID NAME 		NETWORK_NAME	     GLO PDB		      ENA
---------- -------------------- -------------------- --- -------------------- ---
	 6 pn1			pn1		     NO  PN1		      NO

SQL> 


--->>>从cdb中查看service的情况:
SQL>  alter session set container=CDB$ROOT;

Session altered.

SQL> select service_id, name,pdb from v$services;

SERVICE_ID NAME 		PDB
---------- -------------------- --------------------
	 0 pn2			PN2
	 6 pn1			PN1
	 3 orclXDB		CDB$ROOT
	 4 orcl 		CDB$ROOT
	 1 SYS$BACKGROUND	CDB$ROOT
	 2 SYS$USERS		CDB$ROOT

6 rows selected.

SQL> 


以上是关于cdb与pdb的一些常用查询命令的主要内容,如果未能解决你的问题,请参考以下文章

Oracle 12c 多租户配置和修改 CDB 和 PDB 参数

Oracle 12c 多租户 CDB 与 PDB 备份

Oracle 12c 命令行创建PDB

Oracle 12C CDBPDB常用管理命令

Oracle12c中配置实例参数和修改容器数据库(CDB)及可插拔数据库(PDB)

Oracle12C新特性——CDB与PDB(待补充)