This is an old revision of the document!
Overview
Application containers are new concept from 12.2 and they allow us to group PDB based on their purpose. Furthermore, we can treat these PDB as one whole in the way that we can partition among them, even if they are remote and thus increase the performance:
From 12.2 onward we are allowed to have a Proxy PDB, Application Root Container and a single user-defined PDB (regular or Application PDB) inside a single CDB without having to pay for the Multitenant Option. Notice we are still limited to a single user-defined PDB.
Management
The management of an application root container is very similar to the management of a single PDB.
Operations
The operations of application PDBs and application containers are the same as normal PDBs:
- Creation
- Deletion
- Alteration
Creation
To create application root container, just create a normal PDB, but AS application root
Create application root container
CONN / AS SYSDBA CREATE PLUGGABLE DATABASE appcon1 AS APPLICATION CONTAINER ADMIN USER app_admin IDENTIFIED BY Password1; ALTER PLUGGABLE DATABASE appcon1 OPEN; <
Deletion
To delete a application container, use the following command:
Drop a application container
CONN / AS SYSDBA ALTER PLUGGABLE DATABASE appcon1 CLOSE; DROP PLUGGABLE DATABASE appcon1 INCLUDING DATAFILES;
Create application PDB
To create an application PDB, we can use the same syntax as normal PDB, just we need to change the CDB :)
Create application PDB
CONN / AS SYSDBA ALTER SESSION SET container = appcon1; CREATE PLUGGABLE DATABASE apppdb1 ADMIN USER pdb_admin IDENTIFIED BY Password1; ALTER PLUGGABLE DATABASE apppdb1 OPEN;
Drop application PDB
To drop an application PDB, we can use the same command as a normal PDB
Drop application PDB
CONN / AS SYSDBA ALTER PLUGGABLE DATABASE appcon1 CLOSE; DROP PLUGGABLE DATABASE appcon1 INCLUDING DATAFILES;
Application containers and application roots are mostly useful when we install and deal with applications. But what is application in a DB term.
Applications
Within an application container, an application is the named, versioned set of common data and metadata stored in the application root. In this context of an application container, the term “application” means “master application definition.” For example, the application might include definitions of tables, views, and packages. For example, you might create multiple sales-related PDBs within one application container, with these PDBs sharing an application that consists of a set of common tables and table definitions. You might store multiple HR-related PDBs within a separate application container, with their own common tables and table definitions.
To have an application, firstly we need to install an application.
Installation
Firstly we need to create an application PDB, you know already the steps from above so I will make them shorter :)
Install application container and PDB
Install application PDB
#Create application root CONN / AS SYSDBA CREATE PLUGGABLE DATABASE appcon1 AS APPLICATION CONTAINER ADMIN USER app_admin IDENTIFIED BY Password1; ALTER PLUGGABLE DATABASE appcon1 OPEN; #Change the CDB to the newly created container CONN / AS SYSDBA ALTER SESSION SET container = appcon1; #Create one or more application PDB (repeat if needed) CREATE PLUGGABLE DATABASE apppdb1 ADMIN USER pdb_admin IDENTIFIED BY Password1; ALTER PLUGGABLE DATABASE apppdb1 OPEN; #Sync them all (repeat if needed) ALTER SESSION SET container = apppdb1; ALTER PLUGGABLE DATABASE APPLICATION ALL SYNC;
Install the application
To install an application, we can use the following process:
Install application
#Change to the application root CONN / AS SYSDBA ALTER SESSION SET container = appcon1; #Install the application ALTER PLUGGABLE DATABASE APPLICATION ref_app BEGIN INSTALL '1.0';
Now we can start configuring all that is needed for that application:
Configure the PDB for the application needs
CREATE TABLESPACE ref_app_ts DATAFILE SIZE 1M AUTOEXTEND ON NEXT 1M; CREATE USER ref_app_user IDENTIFIED BY ref_app_user DEFAULT TABLESPACE ref_app_ts QUOTA UNLIMITED ON ref_app_ts CONTAINER=ALL; GRANT CREATE SESSION, CREATE TABLE TO ref_app_user; CREATE TABLE ref_app_user.reference_data SHARING=DATA ( id NUMBER, description VARCHAR2(50), CONSTRAINT t1_pk PRIMARY KEY (id) ); INSERT INTO ref_app_user.reference_data SELECT level, 'Description of ' || level FROM dual CONNECT by level <= 5; COMMIT;
End the installation
To end the installation we simply have to do the following command:
End installation
ALTER PLUGGABLE DATABASE APPLICATION ref_app END INSTALL; COLUMN app_name FORMAT A20 COLUMN app_version FORMAT A10 SELECT app_name, app_version, app_status FROM dba_applications WHERE app_name = 'REF_APP'; APP_NAME APP_VERSIO APP_STATUS -------------------- ---------- ------------ REF_APP 1.0 NORMAL SQL>
Bare in mind, at this point the PDBs, don't know about that installation, so if we try to see it from their point of view, it doesn't exist:
Check
Check on PDB level
-- Connect to application container. CONN / AS SYSDBA ALTER SESSION SET container = apppdb1; SHOW CON_NAME CON_NAME ------------------------------ APPPDB1 SQL> -- Check for presence of application objects. DESC ref_app_user.reference_data; ERROR: ORA-04043: object ref_app_user.reference_data does not exist SQL>