【跟我学oracle18c】第二十九天:Multitenant :19 Monitoring CDBs and PDBs
全是数据字典
19 Monitoring CDBs and PDBs
You can view information about CDBs and PDBs using SQL*Plus or SQL Developer.
This chapter contains the following topics:
- About CDB and Container Information in Views
In a CDB, the metadata for data dictionary tables and view definitions is stored only in the root. - Determining Whether a Database Is a CDB
You can query theCDB
column in theV$DATABASE
view to determine whether a database is a CDB or a non-CDB. TheCDB
column returnsYES
if the current database is a CDB orNO
if the current database is a non-CDB. - Viewing Information About the Containers in a CDB
TheV$CONTAINERS
view provides information about all containers in a CDB, including the root and all PDBs. - Viewing Information About PDBs
TheCDB_PDBS
view andDBA_PDBS
view provide information about the PDBs associated with a CDB, including the status of each PDB. - Viewing the Open Mode of Each PDB
TheV$PDBS
view provides information about the PDBs associated with the current database instance. - Querying Container Data Objects
In the root, container data objects can show information about database objects (such as tables and users) contained in the root and in PDBs. Access to PDB information is controlled by the common user'sCONTAINER_DATA
attribute. - Querying Across Containers with the CONTAINERS Clause
TheCONTAINERS
clause enables you to query tables and views across all containers in a CDB. It also enables you to query application common objects across all containers in an application container. - Determining the Current Container ID or Name
You can determine your current container ID or container name in a CDB. - Listing the Modifiable Initialization Parameters in PDBs
In a CDB, some initialization parameters apply to the root and to all PDBs. When such an initialization parameter is changed, it affects the entire CDB. You can set other initialization parameters to different values in each container. - Viewing the History of PDBs
TheCDB_PDB_HISTORY
view shows the history of the PDBs in a CDB. It provides information about when and how each PDB was created and other information about each PDB's history. - Viewing Information About Applications in Application Containers
Several views provide information about the applications in application containers in a CDB.
Related Topics
- Tools for a Multitenant Environment
Parent topic: Administering a Multitenant Environment
19.1 About CDB and Container Information in Views
In a CDB, the metadata for data dictionary tables and view definitions is stored only in the root.
This section contains the following topics:
- About Viewing Information When the Current Container Is Not the CDB Root
When the current container is a PDB, an application root, or an application PDB, the data dictionary views show metadata for the current container only. - About Viewing Information When the Current Container Is the CDB Root
When the current container is the CDB root, a common user can view data dictionary information for the CDB root and for PDBs, application roots, and application PDBs by querying container data objects. - Views for a CDB
You can query a set of views for information about a CDB and its PDBs.
Parent topic: Monitoring CDBs and PDBs
19.1.1 About Viewing Information When the Current Container Is Not the CDB Root
Parent topic: About CDB and Container Information in Views
19.1.2 About Viewing Information When the Current Container Is the CDB Root
When the current container is the CDB root, a common user can view data dictionary information for the CDB root and for PDBs, application roots, and application PDBs by querying container data objects.
A container data object is a table or view that can contain data pertaining to the following:
One or more containers
The CDB as a whole
One or more containers and the CDB as a whole
Container data objects include V$
, GV$
, CDB_
, and some Automatic Workload Repository DBA_HIST*
views. A common user's CONTAINER_DATA
attribute determines which containers are visible in container data objects.
In a CDB, for every DBA_
view, there is a corresponding CDB_
view. All CDB_
views are container data objects, but most DBA_
views are not.
Each container data object contains a CON_ID
column that identifies the container for each row returned. Table 19-1 describes the meanings of the values in the CON_ID
column.
Table 19-1 CON_ID Column in Container Data Objects
Value in CON_ID Column | Description |
---|---|
0 |
The data pertains to the entire CDB |
1 |
The data pertains to the CDB root |
2 |
The data pertains to the PDB seed |
3 - 4,098 |
The data pertains to a PDB, an application root, or an application PDB Each container has its own container ID. |
The following views behave differently from other [G]V$
views:
[G]V$SYSSTAT
[G]V$SYS_TIME_MODEL
[G]V$SYSTEM_EVENT
[G]V$SYSTEM_WAIT_CLASS
When queried from the CDB root, these views return instance-wide data, with 0
in the CON_ID
column for each row returned. However, you can query equivalent views that behave the same as other container data objects. The following views can return specific data for each container in a CDB: [G]V$CON_SYSSTAT
, [G]V$CON_SYS_TIME_MODEL
, [G]V$CON_SYSTEM_EVENT
, and [G]V$CON_SYSTEM_WAIT_CLASS
.
Note:
When querying a container data object, the data returned depends on whether containers are open and on the privileges granted to the user running the query.
In an Oracle Real Application Clusters (Oracle RAC) environment, the data returned by container data objects might vary based on the instance to which a session is connected.
In a non-CDB, all
CON_ID
columns in container data objects are 0 (zero).When a container is opened in restricted mode, it is ignored in queries on
CDB_
views.
See Also:
"About the Current Container"
"Container Data Objects in a CDB"
Oracle Database Security Guide for detailed information about container data objects
Parent topic: About CDB and Container Information in Views
19.1.3 Views for a CDB
You can query a set of views for information about a CDB and its PDBs.
Table 19-2 describes data dictionary views that are useful for monitoring a CDB and its PDBs.
Table 19-2 Views for a CDB
View | Description | More Information |
---|---|---|
Container data objects, including:
|
Container data objects can display information about multiple PDBs. Each container data object includes a There is a |
"Querying Container Data Objects" Oracle Database Security Guide |
|
Displays information about the PDBs associated with the CDB, including the status of each PDB. |
"Viewing Information About PDBs" Oracle Database Reference |
|
Displays the permanent properties of each container in a CDB. |
Oracle Database Reference |
|
Displays the history of each PDB. |
Oracle Database Reference |
|
Displays information about the user-level and object-level |
Oracle Database Reference |
|
Displays the PDBs and instances in the Workload Repository. |
Oracle Database Reference |
|
Displays information about the current saved PDB states in the CDB. |
Oracle Database Reference "Preserving or Discarding the Open Mode of PDBs When the CDB Restarts" |
|
Describes all applications in an application container. |
"Viewing Information About Applications" |
|
Describes all statements from application installation, upgrade, and patch operations in an application container. |
"Viewing Information About Application Statements" |
|
Describes all application patches in an application container. |
"Viewing Information About Application Patches" |
|
Describes all application error messages generated in an application container. |
"Viewing Information About Application Errors" |
|
Displays information about all the CDB resource plans. |
Oracle Database Reference "Viewing CDB Resource Plans" |
|
Displays information about all the CDB resource plan directives. |
Oracle Database Reference "Viewing CDB Resource Plan Directives" |
|
Contains descriptions of reasons for PDB alerts. |
Oracle Database Reference |
|
Displays information about incompatibilities between a PDB and the CDB to which it belongs. This view is also used to display information generated by executing |
Oracle Database Reference "Plugging In an Unplugged PDB" |
|
Displays information about database objects, and the |
Oracle Database Reference |
|
Displays information about database services, and the |
Oracle Database Reference |
|
The |
Oracle Database Reference |
|
The |
Oracle Database Reference |
|
The |
Oracle Database Reference |
|
The |
Oracle Database Reference |
|
Displays information about the database from the control file. If the database is a CDB, then CDB-related information is included. |
"Determining Whether a Database Is a CDB" Oracle Database Reference |
|
Displays information about the containers associated with the current CDB, including the root and all PDBs. |
"Viewing Information About the Containers in a CDB" Oracle Database Reference |
|
Displays information about the PDBs associated with the current CDB, including the open mode of each PDB. |
"Viewing the Open Mode of Each PDB" Oracle Database Reference |
|
Displays information about all PDB incarnations. Oracle creates a new PDB incarnation whenever a PDB is opened with the |
Oracle Database Reference |
|
Displays information about initialization parameters, and the |
"Listing the Modifiable Initialization Parameters in PDBs" Oracle Database Reference |
|
Displays trace file and alert file data for the current container in a CDB. |
Oracle Database SQL Tuning Guide |
|
Displays information about problems and incidents for the current container in a CDB. |
Oracle Database Reference |
Parent topic: About CDB and Container Information in Views
19.2 Determining Whether a Database Is a CDB
You can query the CDB
column in the V$DATABASE
view to determine whether a database is a CDB or a non-CDB. The CDB
column returns YES
if the current database is a CDB or NO
if the current database is a non-CDB.
To determine whether a database is a CDB:
In SQL*Plus, connect to the database as an administrative user.
Query the
V$DATABASE
view.
Example 19-1 Determining Whether a Database is a CDB
SELECT CDB FROM V$DATABASE;
Sample output:
CDB --- YES
See Also:
Oracle Database Reference
Parent topic: Monitoring CDBs and PDBs
19.3 Viewing Information About the Containers in a CDB
The V$CONTAINERS
view provides information about all containers in a CDB, including the root and all PDBs.
To view this information, the query must be run by a common user whose current container is the root. When the current container is a PDB, this view only shows information about the current PDB.
To view information about the containers in a CDB:
In SQL*Plus, ensure that the current container is the root.
See "About Container Access in a CDB".
Query the
V$CONTAINERS
view.
Example 19-2 Viewing Identifying Information About Each Container in a CDB
COLUMN NAME FORMAT A8SELECT NAME, CON_ID, DBID, CON_UID, GUID FROM V$CONTAINERS ORDER BY CON_ID;
Sample output:
NAME CON_ID DBID CON_UID GUID
-------- ---------- ---------- ---------- --------------------------------
CDB$ROOT 1 659189539 1 C091A6F89C7572A1E0436797E40AC78D
PDB$SEED 2 4026479912 4026479912 C091AE9C00377591E0436797E40AC138
HRPDB 3 3718888687 3718888687 C091B6B3B53E7834E0436797E40A9040
SALESPDB 4 2228741407 2228741407 C091FA64EF8F0577E0436797E40ABE9F
See Also:
"About Configuring and Managing a Multitenant Environment"
"About the Current Container"
"Determining the Current Container ID or Name"
Oracle Database Reference
Parent topic: Monitoring CDBs and PDBs
19.4 Viewing Information About PDBs
The CDB_PDBS
view and DBA_PDBS
view provide information about the PDBs associated with a CDB, including the status of each PDB.
To view this information, the query must be run by a common user whose current container is the root. When the current container is a PDB, all queries on these views return no results.
To view information about PDBs:
In SQL*Plus, ensure that the current container is the root.
See "Accessing a Container in a CDB with SQL*Plus".
Query the
CDB_PDBS
orDBA_PDBS
view.
Example 19-3 Viewing Container ID, Name, and Status of Each PDB
COLUMN PDB_NAME FORMAT A15SELECT PDB_ID, PDB_NAME, STATUS FROM DBA_PDBS ORDER BY PDB_ID;
Sample output:
PDB_ID PDB_NAME STATUS ---------- --------------- -------------2 PDB$SEED NORMAL3 HRPDB NORMAL4 SALESPDB NORMAL
See Also:
"About the Current Container"
Parent topic: Monitoring CDBs and PDBs
19.5 Viewing the Open Mode of Each PDB
The V$PDBS
view provides information about the PDBs associated with the current database instance.
You can query this view to determine the open mode of each PDB. For each PDB that is open, this view can also show when the PDB was last opened. A common user can query this view when the current container is the root or a PDB. When the current container is a PDB, this view only shows information about the current PDB.
To view the open status of each PDB:
In SQL*Plus, access a container.
See "Accessing a Container in a CDB with SQL*Plus".
Query the
V$PDBS
view.
Example 19-4 Viewing the Name and Open Mode of Each PDB
COLUMN NAME FORMAT A15 COLUMN RESTRICTED FORMAT A10 COLUMN OPEN_TIME FORMAT A30SELECT NAME, OPEN_MODE, RESTRICTED, OPEN_TIME FROM V$PDBS;
Sample output:
NAME OPEN_MODE RESTRICTED OPEN_TIME --------------- ---------- ---------- ------------------------------ PDB$SEED READ ONLY NO 21-MAY-12 12.19.54.465 PM HRPDB READ WRITE NO 21-MAY-12 12.34.05.078 PM SALESPDB MOUNTED NO 22-MAY-12 10.37.20.534 AM
See Also:
"Modifying the Open Mode of PDBs with ALTER PLUGGABLE DATABASE"
"Modifying the Open Mode of PDBs"
"Modifying a PDB with the ALTER PLUGGABLE DATABASE Statement"
"About the Current Container"
Parent topic: Monitoring CDBs and PDBs
19.6 Querying Container Data Objects
In the root, container data objects can show information about database objects (such as tables and users) contained in the root and in PDBs. Access to PDB information is controlled by the common user's CONTAINER_DATA
attribute.
For example, CDB_
views are container data objects. See "About Viewing Information When the Current Container Is the CDB Root" and Oracle Database Security Guide for more information about container data objects.
Each container data object contains a CON_ID
column that shows the container ID of each PDB in the query results. You can view the PDB name for a container ID by querying the DBA_PDBS
view.
To use container data objects to show information about multiple PDBs:
In SQL*Plus, ensure that the current container is the root.
See "About Container Access in a CDB".
Query the container data object to show the desired information.
Note:
When a query contains a join of a container data object and a non-container data object, and the current container is the root, the query returns data for the entire CDB only (CON_ID
= 0
).
Example 19-5 Showing the Tables Owned by Specific Schemas in Multiple PDBs
This example queries the DBA_PDBS
view and the CDB_TABLES
view from the root to show the tables owned by hr
user and oe
user in the PDBs associated with the CDB. This query returns only rows where the PDB has an ID greater than 2 (p.PDB_ID > 2
) to avoid showing the users in the CDB root and PDB seed.
COLUMN PDB_NAME FORMAT A15
COLUMN OWNER FORMAT A15
COLUMN TABLE_NAME FORMAT A30SELECT p.PDB_ID, p.PDB_NAME, t.OWNER, t.TABLE_NAME FROM DBA_PDBS p, CDB_TABLES t WHERE p.PDB_ID > 2 ANDt.OWNER IN('HR','OE') ANDp.PDB_ID = t.CON_IDORDER BY p.PDB_ID;
Sample output:
PDB_ID PDB_NAME OWNER TABLE_NAME
---------- --------------- --------------- ------------------------------3 HRPDB HR COUNTRIES3 HRPDB HR JOB_HISTORY3 HRPDB HR EMPLOYEES3 HRPDB HR JOBS3 HRPDB HR DEPARTMENTS3 HRPDB HR LOCATIONS3 HRPDB HR REGIONS4 SALESPDB OE PRODUCT_INFORMATION4 SALESPDB OE INVENTORIES4 SALESPDB OE ORDERS4 SALESPDB OE ORDER_ITEMS4 SALESPDB OE WAREHOUSES4 SALESPDB OE CUSTOMERS4 SALESPDB OE SUBCATEGORY_REF_LIST_NESTEDTAB4 SALESPDB OE PRODUCT_REF_LIST_NESTEDTAB4 SALESPDB OE PROMOTIONS4 SALESPDB OE PRODUCT_DESCRIPTIONS
This sample output shows the PDB hrpdb
has tables in the hr
schema and the PDB salespdb
has tables in the oe
schema.
Example 19-6 Showing the Users in Multiple PDBs
This example queries the DBA_PDBS
view and the CDB_USERS
view from the root to show the users in each PDB. The query uses p.PDB_ID > 2
to avoid showing the users in the CDB root and the PDB seed.
COLUMN PDB_NAME FORMAT A15
COLUMN USERNAME FORMAT A30SELECT p.PDB_ID, p.PDB_NAME, u.USERNAME FROM DBA_PDBS p, CDB_USERS uWHERE p.PDB_ID > 2 ANDp.PDB_ID = u.CON_IDORDER BY p.PDB_ID;
Sample output:
PDB_ID PDB_NAME USERNAME
---------- --------------- ------------------------------...3 HRPDB HR3 HRPDB OLAPSYS3 HRPDB MDSYS3 HRPDB ORDSYS...4 SALESPDB OE4 SALESPDB CTXSYS4 SALESPDB MDSYS4 SALESPDB EXFSYS4 SALESPDB OLAPSYS...
Example 19-7 Showing the Data Files for Each PDB in a CDB
This example queries the DBA_PDBS
and CDB_DATA_FILES
views to show the name and location of each data file for all of the PDBs in a CDB, including the PDB seed.
COLUMN PDB_ID FORMAT 999
COLUMN PDB_NAME FORMAT A8
COLUMN FILE_ID FORMAT 9999
COLUMN TABLESPACE_NAME FORMAT A10
COLUMN FILE_NAME FORMAT A45SELECT p.PDB_ID, p.PDB_NAME, d.FILE_ID, d.TABLESPACE_NAME, d.FILE_NAMEFROM DBA_PDBS p, CDB_DATA_FILES dWHERE p.PDB_ID = d.CON_IDORDER BY p.PDB_ID;
Sample output:
PDB_ID PDB_NAME FILE_ID TABLESPACE FILE_NAME
------ -------- ------- ---------- ---------------------------------------------2 PDB$SEED 6 SYSAUX /disk1/oracle/dbs/pdbseed/cdb1_ax.f2 PDB$SEED 5 SYSTEM /disk1/oracle/dbs/pdbseed/cdb1_db.f3 HRPDB 9 SYSAUX /disk1/oracle/dbs/hrpdb/hrpdb_ax.f3 HRPDB 8 SYSTEM /disk1/oracle/dbs/hrpdb/hrpdb_db.f3 HRPDB 13 USER /disk1/oracle/dbs/hrpdb/hrpdb_usr.dbf4 SALESPDB 15 SYSTEM /disk1/oracle/dbs/salespdb/salespdb_db.f4 SALESPDB 16 SYSAUX /disk1/oracle/dbs/salespdb/salespdb_ax.f4 SALESPDB 18 USER /disk1/oracle/dbs/salespdb/salespdb_usr.dbf
Example 19-8 Showing the Temp Files in a CDB
This example queries the CDB_TEMP_FILES
view to show the name and location of each temp file in a CDB, as well as the tablespace that uses the temp file.
COLUMN CON_ID FORMAT 999
COLUMN FILE_ID FORMAT 9999
COLUMN TABLESPACE_NAME FORMAT A15
COLUMN FILE_NAME FORMAT A45SELECT CON_ID, FILE_ID, TABLESPACE_NAME, FILE_NAMEFROM CDB_TEMP_FILESORDER BY CON_ID;
Sample output:
CON_ID FILE_ID TABLESPACE_NAME FILE_NAME
------ ------- --------------- ---------------------------------------------1 1 TEMP /disk1/oracle/dbs/t_tmp1.f2 2 TEMP /disk1/oracle/dbs/pdbseed/t_tmp1.f3 3 TEMP /disk1/oracle/dbs/hrpdb/t_hrpdb_tmp1.f4 4 TEMP /disk1/oracle/dbs/salespdb/t_salespdb_tmp1.f
Example 19-9 Showing the Services Associated with PDBs
This example queries the CDB_SERVICES
view to show the PDB name, network name, and container ID of each service associated with a PDB.
COLUMN NETWORK_NAME FORMAT A30
COLUMN PDB FORMAT A15
COLUMN CON_ID FORMAT 999SELECT PDB, NETWORK_NAME, CON_ID FROM CDB_SERVICESWHERE PDB IS NOT NULL ANDCON_ID > 2ORDER BY PDB;
Sample output:
PDB NETWORK_NAME CON_ID
--------------- ------------------------------ ------
HRPDB hrpdb.example.com 3
SALESPDB salespdb.example.com 4
See Also:
"About the Current Container"
"Container Data Objects in a CDB"
Oracle Database Security Guide for detailed information about container data objects
Oracle Database Reference
Parent topic: Monitoring CDBs and PDBs
19.7 Querying Across Containers with the CONTAINERS Clause
The CONTAINERS
clause enables you to query tables and views across all containers in a CDB. It also enables you to query application common objects across all containers in an application container.
This section contains the following topics:
- About Querying Across Containers with the CONTAINERS Clause
TheCONTAINERS
clause enables you to query across containers in a CDB. - Querying User-Created Tables and Views Across All Containers
TheCONTAINERS
clause enables you to query user-created tables and views across all containers. This clause enables queries from the CDB root to display data in tables or views that exist in all open PDBs in a CDB. - Querying Application Common Objects Across Application PDBs
TheCONTAINERS
clause enables you to query application common objects across all PDBs in an application container. Queries from the application root display data in objects that exist in all open PDBs in the container.
Parent topic: Monitoring CDBs and PDBs
19.7.1 About Querying Across Containers with the CONTAINERS Clause
The CONTAINERS
clause enables you to query across containers in a CDB.
The CONTAINERS
clause enables you to query user-created tables and views across all containers in a CDB. This clause enables queries from the CDB root to display data in tables or views that exist in all open containers in a CDB.
The CONTAINERS
clause also enables you to query application common objects, such as tables and views, across all application PDBs in an application container. This clause enables queries from the application root to display data in tables or views that exist in all open application PDBs in the application container.
The CONTAINERS_PARALLEL_DEGREE
initialization parameter can control the degree of parallelism of a query involving the CONTAINERS
clause. If the value of CONTAINERS_PARALLEL_DEGREE
is lower than 65535
(the default), then the specified value is used.
When the CONTAINERS_PARALLEL_DEGREE
initialization parameter is set to the default value (65535
), queries that use the CONTAINERS
clause are parallel by default. The default degree of parallelism is calculated with the following formula:
max(min(cpu_count,number_of_open_containers),#instances)
In addition, you can pass a DEFAULT_PDB_HINT
hint in the CONTAINERS
clause. The hint is passed in the query that is run in each container.
You can force the recursive SQL that results from a query that includes the CONTAINERS
clause to be parallel by using the DEFAULT_PDB_HINT
clause of a CONTAINERS
hint or by using automatic degree of parallelism. However, parallel statement queuing is not possible for recursive SQL that results from a query that includes the CONTAINERS
clause.
Columns of the following types are removed if they exist in a table specified in a CONTAINERS
clause:
The following user-defined types: object types, varrays, REFs, and nested tables
The following Oracle-supplied types:
ANYTYPE
,ANYDATASET
, URI types,SDO_TOPO_GEOMETRY
,SDO_GEORASTER
, andExpression
Note:
When a container is opened in restricted mode, it is ignored by the
CONTAINERS
clause.When the
CONTAINERS
clause is used and an error is returned by a container, the query does not return results from the container that raised the error, and the error is not returned. For example, you cannot select aBFILE
column from a remote table into a local variable. If a query that does this uses theCONTAINERS
clause and includes local and remote containers, then the query returns results for the local containers, but not the remote containers, and no error is returned.
See Also:
"About the Current Container"
Oracle Database SQL Language Reference for more information about the
CONTAINERS
clause and theCONTAINERS
hintOracle Database Security Guide for detailed information about container data objects
Oracle Database Reference for more information about the
CONTAINERS_PARALLEL_DEGREE
initialization parameterOracle Database Data Warehousing Guide for more information about automatic degree of parallelism and parallel statement queuing
Parent topic: Querying Across Containers with the CONTAINERS Clause
19.7.2 Querying User-Created Tables and Views Across All Containers
To use the CONTAINERS
clause to query tables and views across all containers:
In SQL*Plus, access a container.
To view data in multiple containers, ensure that the current container is the CDB root.
See "About Container Access in a CDB".
Run a query that includes the
CONTAINERS
clause.
Example 19-10 Querying a Table Owned by a Common User Across All Containers
This example makes the following assumptions:
An organization has several PDBs, and each PDB is for a different department in the organization.
Each PDB has an
employees
table that tracks the employees in the department, but the table in each PDB contains different employees.The CDB root also has an empty
employees
table.The
employees
table in each container is owned by the same common user.
With the CDB root as the current container and the common user that owns the table as the current user, run the following query with the CONTAINERS
clause to return all employees in the employees
table in all PDBs:
SELECT * FROM CONTAINERS(employees);
Example 19-11 Querying a Table Owned by Local Users Across All Containers
This example makes the following assumptions:
An organization has several PDBs, and each PDB is for a different department in the organization.
Each PDB has an
hr.employees
table that tracks the employees in the department, but the table in each PDB contains different employees.The CDB root also has an empty
employees
table owned by a common user.
To run a query that returns all employees in all PDBs, first connect to each PDB as a common user, and create a view with the following statement:
CREATE OR REPLACE VIEW employees AS SELECT * FROM hr.employees;
The common user that owns the view must be the same common user that owns the employees
table in the CDB root. After you run this statement in each PDB, the common user has a view named employees
in each PDB.
With the CDB root as the current container and the common user as the current user, run the following query with the CONTAINERS
clause to return all employees in the hr.employees
table in all PDBs:
SELECT * FROM CONTAINERS(employees);
You can also query the view in specific containers. For example, the following SQL statement queries the view in the containers with a CON_ID
of 3
and 4
:
SELECT * FROM CONTAINERS(employees) WHERE CON_ID IN(3,4);
Note:
You can also use the CONTAINERS
clause to query Oracle-supplied tables and views. When running the query, ensure that the current user is the owner of the table or view, or create a view using the CONTAINERS
clause and grant SELECT
privilege on the view to the appropriate users.
See Also:
"About the Current Container"
"Container Data Objects in a CDB"
Oracle Database SQL Language Reference for more information about the
CONTAINERS
clauseOracle Database Security Guide for detailed information about container data objects
Parent topic: Querying Across Containers with the CONTAINERS Clause
19.7.3 Querying Application Common Objects Across Application PDBs
The CONTAINERS
clause enables you to query application common objects across all PDBs in an application container. Queries from the application root display data in objects that exist in all open PDBs in the container.
The CONTAINERS
clause is most useful for metadata-linked application common objects. With metadata-linked application common objects, the structure is the same in all containers in an application container, but the data is different. You can use the CONTAINERS
clause to view the data in a metadata-linked application common object in multiple application PDBs. The benefits are similar for extended data-linked objects. The CONTAINERS
clause uses parallel execution to execute the query across the distinct application PDBs hosted in the application root.
To use the CONTAINERS
clause to query tables and views across all application PDBs:
In SQL*Plus, access the application root.
See "About Container Access in a CDB".
Run a query that includes the
CONTAINERS
clause.
Note:
You can enable the CONTAINERS_DEFAULT
attribute for a table or view in an application root. When this attribute is enabled, the CONTAINERS
clause is used for queries and DML statements on the database object by default, and the CONTAINERS
clause is not required in the SQL statements. To enable the CONTAINERS_DEFAULT
attribute for a table or view in an application root, run the ALTER TABLE
or CREATE OR REPLACE VIEW
statement with the ENABLE CONTAINERS_DEFAULT
clause.
Example 19-12 Querying an Application Common Object Across All Application PDBs
This example makes the following assumptions:
An organization has several application PDBs, and each application PDB is for a different department in the organization.
Each application PDB has an
employees
table that tracks the employees in the department, but the table in each application PDB contains different employees.The application root also has an empty
employees
table.The employees table in each container is owned by the same common user.
A company has multiple tenants that use an application in an application container, and each tenant has its own application PDB.
The company uses metadata-linked application common objects to keep the structure of the data the same in all application PDBs, but the data is different in each application PDB.
Each application PDB has a metadata-linked
sales.customers
table that stores information about each tenant’s customers.
With the application root as the current container and the application common user that owns the table as the current user, run the following query with the CONTAINERS
clause to return all customers in the sales.customers
table in all application PDBs:
SELECT * FROM CONTAINERS(sales.customers);
See Also:
"About Application Common Objects"
"About the Current Container"
Oracle Database SQL Language Reference for more information about the
CONTAINERS
clauseOracle Database Security Guide for detailed information about container data objects
Parent topic: Querying Across Containers with the CONTAINERS Clause
19.8 Determining the Current Container ID or Name
You can determine your current container ID or container name in a CDB.
To determine the current container ID:
Run the following SQL*Plus command:
SHOW CON_ID
To determine the current container name:
Run the following SQL*Plus command:
SHOW CON_NAME
In addition, you can use the functions listed in Table 19-3 to determine the container ID of a container.
Table 19-3 Functions That Return the Container ID of a Container
Function | Description |
---|---|
|
Returns the container ID based on the container's name. |
|
Returns the container ID based on the container's DBID. |
|
Returns the container ID based on the container's unique identifier (UID). |
|
Returns the container ID based on the container's globally unique identifier (GUID). |
The V$CONTAINERS
view shows the name, DBID, UID, and GUID for each container in a CDB.
Example 19-13 Returning the Container ID Based on the Container Name
SELECT CON_NAME_TO_ID('HRPDB') FROM DUAL;
Example 19-14 Returning the Container ID Based on the Container DBID
SELECT CON_DBID_TO_ID(2226957846) FROM DUAL;
See Also:
"About a Multitenant Environment"
"About the Current Container"
"Viewing Information About the Containers in a CDB"
Oracle Database Reference for more information about the
V$CONTAINERS
view
Parent topic: Monitoring CDBs and PDBs
19.9 Listing the Modifiable Initialization Parameters in PDBs
To list the initialization parameters that are modifiable in each container:
In SQL*Plus, access a container.
See "About Container Access in a CDB".
Run the following query:
SELECT NAME FROM V$SYSTEM_PARAMETERWHERE ISPDB_MODIFIABLE = 'TRUE'ORDER BY NAME;
If an initialization parameter listed by this query is not set independently for a PDB, then the PDB inherits the parameter value of the root.
See Also:
"Modifying a CDB with ALTER SYSTEM"
"Modifying a PDB at the System Level"
Parent topic: Monitoring CDBs and PDBs
19.10 Viewing the History of PDBs
The CDB_PDB_HISTORY
view shows the history of the PDBs in a CDB. It provides information about when and how each PDB was created and other information about each PDB's history.
To view the history of each PDB:
In SQL*Plus, ensure that the current container is the root.
See "Accessing a Container in a CDB with SQL*Plus".
Query
CDB_PDB_HISTORY
view.
Example 19-15 Viewing the History of PDBs
This example shows the following information about each PDB's history:
The
DB_NAME
field shows the CDB that contained the PDB.The
CON_ID
field shows the container ID of the PDB.The
PDB_NAME
field shows the name of the PDB in one of its incarnations.The
OPERATION
field shows the operation performed in the PDB's history.The
OP_TIMESTAMP
field shows the date on which the operation was performed.If the PDB was cloned in an operation, then the
CLONED_FROM_PDB
field shows the PDB from which the PDB was cloned.
COLUMN DB_NAME FORMAT A10 COLUMN CON_ID FORMAT 999 COLUMN PDB_NAME FORMAT A15 COLUMN OPERATION FORMAT A16 COLUMN OP_TIMESTAMP FORMAT A10 COLUMN CLONED_FROM_PDB_NAME FORMAT A15SELECT DB_NAME, CON_ID, PDB_NAME, OPERATION, OP_TIMESTAMP, CLONED_FROM_PDB_NAMEFROM CDB_PDB_HISTORYWHERE CON_ID > 2ORDER BY CON_ID;
Sample output:
DB_NAME CON_ID PDB_NAME OPERATION OP_TIMESTA CLONED_FROM_PDB ---------- ------ --------------- ---------------- ---------- --------------- NEWCDB 3 HRPDB CREATE 10-APR-12 PDB$SEED NEWCDB 4 SALESPDB CREATE 17-APR-12 PDB$SEED NEWCDB 5 TESTPDB CLONE 30-APR-12 SALESPDB
Note:
When the current container is a PDB, the CDB_PDB_HISTORY
view shows the history of the current PDB only. A local user whose current container is a PDB can query the DBA_PDB_HISTORY
view and exclude the CON_ID
column from the query to view the history of the current PDB.
See Also:
"About the Current Container"
Parent topic: Monitoring CDBs and PDBs
19.11 Viewing Information About Applications in Application Containers
Several views provide information about the applications in application containers in a CDB.
This section contains the following topics:
- Viewing Information About Applications
TheDBA_APPLICATIONS
view provides information about the applications in an application container. - Viewing Information About Application Status
TheDBA_APP_PDB_STATUS
view provides information about the status of the applications in an application container. It can show the status of each application in each application PDB. - Viewing Information About Application Statements
TheDBA_APP_STATEMENTS
view provides information about SQL statements issued during application installation, upgrade, and patch operations - Viewing Information About Application Versions
TheDBA_APP_VERSIONS
view provides information about the versions for applications in an application container. - Viewing Information About Application Patches
TheDBA_APP_PATCHES
view provides information about the patches for applications in an application container. - Viewing Information About Application Errors
TheDBA_APP_ERRORS
view provides information errors raised when an application PDB synchronizes with an application in the application root. - Listing the Shared Database Objects in an Application Container
TheDBA_OBJECTS
view can list the shared database objects in an application container. - Listing the Extended Data-Linked Objects in an Application Container
TheDBA_TABLES
andDBA_VIEWS
views can list the extended data-linked objects in an application container.
Related Topics
- Creating and Removing Application Containers
- Administering Application Containers
Parent topic: Monitoring CDBs and PDBs
19.11.1 Viewing Information About Applications
The DBA_APPLICATIONS
view provides information about the applications in an application container.
Note:
The DBA_APPLICATIONS
view provides information about the application in the current container only. To view information about applications in all of the application PDBs in the current application container, query the DBA_APP_PDB_STATUS
with the application root as the current container.
To view information about the applications in an application container:
In SQL*Plus, access the application root of the application container.
Query the
DBA_APPLICATIONS
view.
Example 19-16 Viewing Details About the Applications in an Application Container
This query shows the name, the latest version, and the status of each user-created application in the application container.
COLUMN APP_NAME FORMAT A15
COLUMN APP_VERSION FORMAT A15
COLUMN APP_STATUS FORMAT A15SELECT APP_NAME, APP_VERSION, APP_STATUS
FROM DBA_APPLICATIONS
WHERE APP_IMPLICIT='N';
The following sample output shows the salesapp
application:
APP_NAME APP_VERSION APP_STATUS
--------------- --------------- ---------------
SALESAPP 1.2 NORMAL
Note:
Oracle Database creates some applications implicitly when an application common user operation is issued with a CONTAINER=ALL
clause outside of ALTER PLUGGABLE DATABASE APPLICATION BEGIN/END
statements. The sample query excludes implicitly-created applications by specifying APP_IMPLICIT='N'
in the WHERE
clause.
Related Topics
- Administering Application Containers
- Synchronizing Applications in an Application PDB
Parent topic: Viewing Information About Applications in Application Containers
19.11.2 Viewing Information About Application Status
The DBA_APP_PDB_STATUS
view provides information about the status of the applications in an application container. It can show the status of each application in each application PDB.
The view can show the status of an application in an application PDB even if the application PDB is closed.
Note:
When queried from the application root, the DBA_APP_PDB_STATUS
view provides information about the applications in all application PDBs in the current application container. To view information about the application in the current container only, query the DBA_APPLICATIONS
view.
To view information about the application status in an application container:
In SQL*Plus, access the application root of the application container.
See "About Container Access in a CDB".
Query the
DBA_APP_PDB_STATUS
view.
Example 19-17 Viewing Information About Application Status
This query shows the name of the application PDB, the name of the application, the version number of the application, and the status of the application.
COLUMN PDB_NAME FORMAT A15
COLUMN APP_NAME FORMAT A15
COLUMN APP_VERSION FORMAT A20
COLUMN APP_STATUS FORMAT A12SELECT p.PDB_NAME, s.APP_NAME, s.APP_VERSION, s.APP_STATUSFROM DBA_PDBS p, DBA_APP_PDB_STATUS sWHERE p.CON_UID = s.CON_UID;
Your output is similar to the following:
PDB_NAME APP_NAME APP_VERSION APP_STATUS
--------------- --------------- -------------------- ------------
SALES1 SALESAPP 4.2 NORMAL
Note:
The status of an application can be NORMAL
in an application PDB even when the application has not been synchronized to the latest version. Other statuses might indicate that an operation is in progress or that an operation encountered a problem. For example, the status UPGRADING
might indicate that an upgrade of the application is in progress in the application PDB, or it might indicate that an error was encountered when the application PDB tried to upgrade an application.
See Also:
"Administering Application Containers"
Parent topic: Viewing Information About Applications in Application Containers
19.11.3 Viewing Information About Application Statements
The DBA_APP_STATEMENTS
view provides information about SQL statements issued during application installation, upgrade, and patch operations
Oracle Database records all of the SQL statements issued during application installation, upgrade, and patch operations, and you can view the history of these statements by querying the DBA_APP_STATEMENTS
view.
To view information about the SQL statements issued during application operations:
In SQL*Plus, access the application root of the application container.
See "About Container Access in a CDB".
Query the
DBA_APP_STATEMENTS
view.
Example 19-18 Viewing Information About Application Statements
This query shows the statement ID, capture time, SQL statement, and application name for the SQL statements for applications in the application container.
SET LONG 8000
SET PAGES 8000
COLUMN STATEMENT_ID FORMAT NNNNN
COLUMN CAPTURE_TIME FORMAT A12
COLUMN APP_STATEMENT FORMAT A36
COLUMN APP_NAME FORMAT A15SELECT STATEMENT_ID, CAPTURE_TIME, APP_STATEMENT, APP_NAMEFROM DBA_APP_STATEMENTSORDER BY STATEMENT_ID;
Your output is similar to the following:
STATEMENT_ID CAPTURE_TIME APP_STATEMENT APP_NAME
------------ ------------ ------------------------------------ ---------------1 30-AUG-15 SYS APP$1E87C0947641142FE0534018F80AA6C52 30-AUG-15 ALTER PLUGGABLE DATABASE APPLICATION APP$1E87C094764APP$CON BEGIN INSTALL '1.0' 1142FE0534018F80AA6C53 30-AUG-15 ALTER PLUGGABLE DATABASE APPLICATION APP$1E87C094764APP$CON END INSTALL '1.0' 1142FE0534018F80AA6C54 30-AUG-15 SYS SALESAPP5 30-AUG-15 ALTER PLUGGABLE DATABASE APPLICATION SALESAPPsalesapp BEGIN INSTALL '1.0'6 30-AUG-15 CREATE TABLE oe.cmtb SHARING=METADAT SALESAPPA (value VARCHAR2(30),country VARCHAR2(30))7 30-AUG-15 CREATE TABLE conmap ( SALESAPPcountry VARCHAR2(30) NOT NULL)PARTITION BY LIST (country) (PARTITION AMER VALUES ('US','MEXICO','CANADA'),PARTITION EURO VALUES ('UK','FRANCE','GERMANY'),PARTITION ASIA VALUES ('INDIA','CHINA','JAPAN'))8 30-AUG-15 ALTER TABLE oe.cmtb ENABLE CONTAINER SALESAPP_MAP9 30-AUG-15 ALTER PLUGGABLE DATABASE APPLICATION SALESAPPsalesapp END INSTALL '1.0'
.
.
.
Note:
Oracle Database creates some applications implicitly when an application common user operation is issued with a CONTAINER=ALL
clause outside of ALTER PLUGGABLE DATABASE APPLICATION BEGIN/END
statements. The names of these applications begin with APP$
, and the sample output shows these applications.
See Also:
"Administering Application Containers"
"Synchronizing Applications in an Application PDB"
Parent topic: Viewing Information About Applications in Application Containers
19.11.4 Viewing Information About Application Versions
The DBA_APP_VERSIONS
view provides information about the versions for applications in an application container.
Oracle Database records the versions for each application in an application container.
To view information about the application versions in an application container:
In SQL*Plus, access the application root of the application container.
See "About Container Access in a CDB".
Query the
DBA_APP_VERSIONS
view.
Example 19-19 Viewing Information About Application Versions
This query shows the name of the application that was versioned, the version number, and the comment for the version.
COLUMN APP_NAME FORMAT A15
COLUMN APP_VERSION FORMAT A20
COLUMN APP_VERSION_COMMENT FORMAT A25SELECT APP_NAME, APP_VERSION, APP_VERSION_COMMENTFROM DBA_APP_VERSIONS;
Your output is similar to the following:
APP_NAME APP_VERSION APP_VERSION_COMMENT
--------------- -------------------- -------------------------
SALESAPP 1.0 Sales Application
See Also:
"Administering Application Containers"
Parent topic: Viewing Information About Applications in Application Containers
19.11.5 Viewing Information About Application Patches
The DBA_APP_PATCHES
view provides information about the patches for applications in an application container.
Oracle Database records the patches for each application in an application container.
To view information about the application patches in an application container:
In SQL*Plus, access the application root of the application container.
See "About Container Access in a CDB".
Query the
DBA_APP_PATCHES
view.
Example 19-20 Viewing Information About Application Patches
This query shows the name of the application that was patched, the patch number, the minimum application version for the patch, and the status of the patch for each patch in the application container.
COLUMN APP_NAME FORMAT A15
COLUMN PATCH_NUMBER FORMAT NNNNNNNN
COLUMN PATCH_MIN_VERSION FORMAT A10
COLUMN PATCH_STATUS FORMAT A15SELECT APP_NAME, PATCH_NUMBER, PATCH_MIN_VERSION, PATCH_STATUSFROM DBA_APP_PATCHES;
Your output is similar to the following:
APP_NAME PATCH_NUMBER PATCH_MIN_ PATCH_STATUS
--------------- ------------ ---------- ---------------
SALESAPP 1 1.2 INSTALLED
See Also:
"Administering Application Containers"
Parent topic: Viewing Information About Applications in Application Containers
19.11.6 Viewing Information About Application Errors
The DBA_APP_ERRORS
view provides information errors raised when an application PDB synchronizes with an application in the application root.
An application PDB issues the ALTER PLUGGABLE DATABASE APPLICATION
statement with the SYNC
clause. You can view the history of application errors during application synchronization by querying the DBA_APP_ERRORS
view.
To view information about errors raised during application synchronization:
In SQL*Plus, access the application root of the application container.
See "About Container Access in a CDB".
Query the
DBA_APP_ERRORS
view.
Example 19-21 Viewing Details About Errors Raised During Application Synchronization
This query shows the application name, the SQL statement that raised the error, the error number, and the error message for errors raised during application synchronization.
SET LONG 8000
SET PAGES 8000
COLUMN APP_NAME FORMAT A15
COLUMN APP_STATEMENT FORMAT A36
COLUMN ERRORNUM FORMAT NNNNNNNN
COLUMN ERRORMSG FORMAT A20SELECT APP_NAME, APP_STATEMENT, ERRORNUM, ERRORMSGFROM DBA_APP_ERRORS;
See Also:
"Administering Application Containers"
Parent topic: Viewing Information About Applications in Application Containers
19.11.7 Listing the Shared Database Objects in an Application Container
The DBA_OBJECTS
view can list the shared database objects in an application container.
Shared database objects are metadata-linked application common objects, data-linked application common objects, and extended data-linked application common objects.
To list the shared database objects in an application container:
In SQL*Plus, access the application root of the application container.
See "About Container Access in a CDB".
Query the
DBA_OBJECTS
view and specify theSHARING
column.
Example 19-22 Listing the User-Created Shared Database Objects in an Application Container
This query shows the owner and name of the user-created shared database objects in the application container. It also shows whether each shared database object is a metadata-linked application common object or a data-linked application common object. The query excludes Oracle-supplied shared database objects.
COLUMN OWNER FORMAT A15
COLUMN OBJECT_NAME FORMAT A25
COLUMN SHARING FORMAT A13 SELECT OWNER, OBJECT_NAME, SHARING FROM DBA_OBJECTS WHERE SHARING != 'NONE' AND ORACLE_MAINTAINED = 'N';
Your output is similar to the following:
OWNER OBJECT_NAME SHARING
--------------- ------------------------- -------------
SALESADM CONMAP METADATA LINK
OE PRODUCT_DESCRIPTIONS_OB DATA LINK
OE CMTB METADATA LINK
See Also:
"Managing Application Common Objects"
Parent topic: Viewing Information About Applications in Application Containers
19.11.8 Listing the Extended Data-Linked Objects in an Application Container
The DBA_TABLES
and DBA_VIEWS
views can list the extended data-linked objects in an application container.
An extended data-linked object is a special type of data-linked object for which each application PDB can create its own specific data while sharing the common data in the application root. Only the data stored in the application root is common for all application PDBs.
To list the extended data-linked objects in an application container:
In SQL*Plus, access the application root of the application container.
See "About Container Access in a CDB".
Query the
DBA_TABLES
orDBA_VIEWS
view and specify theEXTENDED_DATA_LINK='YES'
in theWHERE
clause.
Example 19-23 Listing the Extended Data-Linked Tables in an Application Container
This query shows the owner and name of the extended data-linked tables in the application container.
COLUMN OWNER FORMAT A20
COLUMN TABLE_NAME FORMAT A30SELECT OWNER, TABLE_NAME FROM DBA_TABLES WHERE EXTENDED_DATA_LINK='YES';
Your output is similar to the following:
OWNER TABLE_NAME
-------------------- ------------------------------
SALESADM ZIPCODES
See Also:
"Managing Application Common Objects"
Parent topic: Viewing Information About Applications in Application Containers
【跟我学oracle18c】第二十九天:Multitenant :19 Monitoring CDBs and PDBs相关推荐
- 自学前端第二十九天 CSS高级之细节技巧
第二十九天 css高级细节技巧 一.background-color :属性设置元素的背景颜色. 定义和用法 background-color 属性设置元素的背景颜色. 元素背景的范围 backgro ...
- Python学习笔记第二十九天(N维数组(ndarray))
Python学习笔记第二十九天 N维数组(ndarray) 构建阵列 索引阵列 ndarray的内部内存布局 阵列属性 内存布局 数据类型 其他属性 阵列接口 ctypes外部功能接口 Array方法 ...
- java 根据经纬度计算多边形的面积_强基初中数学amp;学Python——第二十九课 根据海伦秦九韶公式编程计算三角形面积...
问题:如果把边长都是有理数的三角形称作"有理三角形",编程计算"有理三角形"的面积(有理数或带根号的无理数,不是浮点数). 关键点分析:根号中的底化成最简分数, ...
- 第二十九天-ssh服务重要知识深入浅出讲解
目录概述: 1. SSH简介 2. SSH安全验证方式 3. 安装并测试OpenSSH 4. SSH的密匙 4.1 生成你自己的密匙对 4.2分发公用密匙 5. 配置SSH 5.1 ...
- 辉仔日记之学代码第二十一期——单例模式
单例模式的定义 单例(Singleton)模式的定义:指一个类只有一个实例,且该类能自行创建这个实例的一种模式. 单例模式有 3 个特点 单例类只有一个实例对象: 该单例对象必须由单例类自行创建: 单 ...
- 皮皮安学Java第二十六天
写在前面 六月份就要过去了,又要些月总结了,头疼.一个月,我都干了啥啊这是,啥也不是. 今日和上周末所学 二.IO流 1.简介 Input Output 输入和输出流 通过IO流实现文件的输入和输出功 ...
- 皮皮安学Java第二十四天
写在前面 没啥好说的,上总结 今日与昨日所学 2.2使用throws 如果是一个方法可能会产生某种异常,但不知道如何处理这种异常,此时可以声明该方法抛出异常,表明该方法不对这种异常进行处理,而由该方法 ...
- Python学习日记-第二十九天-tcp(客户端)
系列文章目录 tcp介绍 tcp特点 tcp客户端 一.tcp介绍 Tcp协议,传输控制协议是一种面向连接的.可靠的.基于字节流的传输层通信协议,由IETF的RFC 793定义 TCP通信需要经过创建 ...
- 创业失败感悟第二十九天
和朋友聊起来二次创业的话题,关于下一步的行业与模式选择方面,有一个共同的观点,就是不可以再进行重资产运营,倾向于平台类的公司,需要一个概念来主导. 这种出奇一致的观点,其实也代表了现在很多人的想法,特 ...
最新文章
- 【 C 】结构体 与 typedef
- eigen跟踪MILTracker代码分析
- 使用Spring框架开发会遇到的所有异常及解决方案(持续更)
- 【ThinkPHP系列篇】ThinkPHP框架的介绍和搭建(一)
- Flutter中实现整个App变为灰色
- windows 10安装gensim、nltk
- Java的Servlet、Filter、Interceptor、Listener
- REVERSE-PRACTICE-BUUCTF-21
- android listview 移动到顶部,android listview滚动到顶部
- 命令杀mysql进程
- javascript技术教程蔡敏_JavaScript基础与实践教程 (王萍萍,赵俊莉,孙强) pdf扫描版...
- ZUC加密算法实现-软件版本Java
- fgo最新服务器,FGO服务器故障追加说明 凌晨3点已开服
- php获取谷歌邮箱,php 获取gmail 联系人邮箱,应用oauth2.0验证
- 校本课程——宝宝爱上学
- 2020十大黄金配资交易平台排名
- 单位dB(分贝)的含义和好处,dBm(dBmW 分贝毫瓦)的含义 dB的含义
- maven通过mvn命令添加oracle依赖
- (3) openssl genrsa(生成rsa私钥)
- 2022年最新江西机动车签字授权人模拟试题及答案
热门文章
- Linux驱动编程(驱动程序基石)(下)
- Linux驱动模型之注册驱动
- AutoCAD的AccoreConsole - 第二篇(执行脚本)
- 中国电信光纤终端端口映射解决方案
- python识图 web_轻松简单搭建一个python的OCR服务器 识别截图中内容并提取
- 移动光驱接入WIN10电脑提示“无法识别的USB设备-跟这台计算机连接的前一个USB设备工作不正常,Windows无法识别它。”
- C语言 数组查找问题汇总
- Fiori程序员用ADT不正经的ABAP数据库建表操作、数据录入
- Java开发上门洗车系统源码小程序app介绍
- 离散粒子群(DPSO)——任务分类