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

[oracle@rhel59 ~]$ 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> 


你可能感兴趣的:(Oracle,DB,12c,Oracle,DB,Oracle,DB,12c新特性)