Creating Application Containers
You can create application containers in several different ways, including
using the PDB seed, cloning an existing PDB, and plugging in an unplugged PDB by using the
CREATE PLUGGABLE DATABASE
statement.
- About Creating an Application Container
TheCREATE PLUGGABLE DATABASE ... AS APPLICATION CONTAINER
statement creates a new application container. - Preparing for Application Containers
Prerequisites must be met before creating an application container. - Creating an Application Container
You can create an application container using theCREATE PLUGGABLE DATABASE
statement with theAS APPLICATION CONTAINER
clause.
Parent topic: Creating and Removing Application Containers and Seeds
About Creating an Application Container
The CREATE PLUGGABLE DATABASE ... AS APPLICATION CONTAINER
statement creates a new application container.
An application container consists of an application root and a collection of application PDBs that store data for one or more applications. The application PDBs are plugged into the application root, and you can optionally create an application seed for quick and easy creation of new application PDBs. The application PDBs and application root can share application common objects.
There are three types of application common objects:
-
Metadata-linked application common objects store the metadata for specific objects, such as tables, so that the containers that share the application common object have the same structure but different data.
-
Data-linked application common objects are defined once in the application root and shared as read-only objects in the context of hosted application PDBs.
-
Extended data-linked application common objects store shared data in the application root but also allow application PDBs to store data appended to that object. The appended data is local data that is unique to each application PDB.
You create an application container by including the AS APPLICATION CONTAINER
clause in the CREATE PLUGGABLE DATABASE
statement. You can use the following techniques to create an application container:
-
Using the PDB seed
-
Cloning an existing PDB
-
Relocating a PDB
-
Plugging in an unplugged PDB
To create an application container, the current container must be the CDB root and you must specify the AS APPLICATION CONTAINER
clause in the CREATE PLUGGABLE DATABASE
statement. You must create the application container using Oracle Managed Files.
Note:
An application container cannot be unplugged or dropped if any application PDBs belong to it.
Migrating Existing Applications to an Application Container
You can migrate an application to an application root by creating an application root using an existing PDB. You must complete additional tasks when you are migrating an existing application to an application container. The PDBs that you plug in must contain the application objects, including their data, and you must run procedures in the DBMS_PDB
package to specify which objects are shared. Also, when application common users, roles, or profiles exist in the application root, you must run procedures in the DBMS_PDB
package to specify that they are common.
After the application is migrated to the application root, you can create application PDBs in the application root, and create application PDBs using existing PDBs.
Parent topic: Creating Application Containers
Preparing for Application Containers
Prerequisites must be met before creating an application container.
-
The CDB must exist.
-
The CDB must be in read/write mode.
-
The current user must be a common user whose current container is the CDB root.
-
The current user must have the
CREATE PLUGGABLE DATABASE
system privilege. -
You must decide on a unique application container name for every application container. Every application container name must be unique with respect to all containers in a single CDB, and every application container name must be unique within the scope of all the CDBs whose database instances are reached through a specific listener.
The application container name is used to distinguish an application container from other containers in the CDB. Application container names follow the same rules as service names, which includes being case-insensitive.
-
You must create the containing using Oracle Managed Files.
-
If you are creating an application container in an Oracle Data Guard configuration with a physical standby database, then additional tasks must be completed before creating an application container.
-
If you are migrating an existing application to an application container using installation scripts, then the scripts must be available to run.
-
If you are migrating an existing application to an application container using a PDB, then it must be possible to clone the PDB to the application root or plug in the PDB into the application root.
Creating an Application Container
You can create an application container using the CREATE PLUGGABLE DATABASE
statement with the AS APPLICATION CONTAINER
clause.
Example 14-2 Creating an Application Container Using the PDB seed
This example assumes the following factors:
-
Storage limits are not required for the application container. Therefore, the
STORAGE
clause is not required. -
The application container does not require a default tablespace.
-
The
PATH_PREFIX
clause is not required. -
The
FILE_NAME_CONVERT
clause and theCREATE_FILE_DEST
clause are not required.Either Oracle Managed Files is enabled for the CDB, or the
PDB_FILE_NAME_CONVERT
initialization parameter is set. The files associated with the PDB seed will be copied to a new location based on the Oracle Managed Files configuration or the initialization parameter setting. -
There is no file with the same name as the new temp file that will be created in the target location. Therefore, the
TEMPFILE REUSE
clause is not required. -
No predefined Oracle roles need to be granted to the
PDB_DBA
role.
The following statement creates the application container from the PDB seed:
CREATE PLUGGABLE DATABASE salesact AS APPLICATION CONTAINER
ADMIN USER salesadm IDENTIFIED BY password;
Example 14-3 Creating an Application Container by Cloning a Local PDB
This example assumes the following factors:
-
The
PATH_PREFIX
clause is not required. -
The
FILE_NAME_CONVERT
clause is required to specify the target locations of the copied files. In this example, the files are copied from/disk1/oracle/pdb1/ to /disk2/oracle/hract/
.The
CREATE_FILE_DEST
clause is not used, and neither Oracle Managed Files nor thePDB_FILE_NAME_CONVERT
initialization parameter is used to specify the target locations of the copied files.To view the location of the data files for a PDB, run the query in "Example 15-34".
-
Storage limits must be enforced for the application root. Therefore, the
STORAGE
clause is required. Specifically, all tablespaces that belong to the application root must not exceed 2 gigabytes. This storage limit does not apply to the application PDBs that are plugged into the application root. -
There is no file with the same name as the new temp file that will be created in the target location. Therefore, the
TEMPFILE REUSE
clause is not required.
Given the preceding factors, the following statement clones hract
as an application container from pdb1
:
CREATE PLUGGABLE DATABASE hract AS APPLICATION CONTAINER FROM pdb1
FILE_NAME_CONVERT = ('/disk1/oracle/pdb1/', '/disk2/oracle/hract/')
STORAGE (MAXSIZE 2G);
Note:
If you are migrating an existing application to the new application container, then follow the instructions in "Migrating an Existing Application to an Application Container".
Example 14-4 Creating an Application Container by Plugging In an Unplugged PDB
This example assumes the following factors:
-
The new application container is not based on the same unplugged PDB that was used to create an existing PDB or application container in the CDB. Therefore, the
AS
CLONE
clause is not required. -
The
PATH_PREFIX
clause is not required. -
The XML file does not accurately describe the current locations of the files. Therefore, the
SOURCE_FILE_NAME_CONVERT
clause orSOURCE_FILE_DIRECTORY
clause is required. In this example, the XML file indicates that the files are in /disk1/oracle/payroll/, but the files are in /disk2/oracle/payroll/, and theSOURCE_FILE_NAME_CONVERT
clause is used. -
The files are in the correct location. Therefore,
NOCOPY
is included. -
Storage limits must be enforced for the application container. Therefore, the
STORAGE
clause is required. Specifically, all tablespaces that belong to the application container must not exceed 2 gigabytes. -
A file with the same name as the temp file specified in the XML file exists in the target location. Therefore, the
TEMPFILE REUSE
clause is required.
The following statement plugs in the PDB:
CREATE PLUGGABLE DATABASE payrollact AS APPLICATION CONTAINER
USING '/disk1/usr/payrollpdb.xml'
SOURCE_FILE_NAME_CONVERT = ('/disk1/oracle/payroll/',
'/disk2/oracle/payroll/')
NOCOPY
STORAGE (MAXSIZE 2G)
TEMPFILE REUSE;
Note:
If you are migrating an existing application to the new application container, then follow the instructions in "Migrating an Existing Application to an Application Container".