You can create application containers in several different ways, including using the PDB seed, cloning an existing PDB or non-CDB, and plugging in an unplugged PDB. You can also remove application containers from a CDB.
Creating Application Containers
You can use the CREATE PLUGGABLE DATABASE
statement to create an application container in a CDB.
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 or non-CDB
- 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.
Creating an Application Container Using the PDB seed
The following statement creates the application container from the PDB seed:
CREATE PLUGGABLE DATABASE salesact AS APPLICATION CONTAINER
ADMIN USER salesadm IDENTIFIED BY
password;
Creating an Application Container by Cloning a Local PDB
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);
Creating an Application Container by Plugging In an Unplugged PDB
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;
Unplugging an Application Container from a CDB
Unplugging an application container disassociates the application container from a CDB.
Typically, you unplug an application container when you want to move the application container to a different CDB. Also, you can unplug the application container when you no longer want it to be available.
Unplugging an application container is similar to unplugging a PDB. To unplug an application container, connect to its CDB root and use the ALTER PLUGGABLE DATABASE
statement to specify an XML file or a .pdb
file. When you specify an XML file (.xml
extension), it will contain metadata about the application container after it is unplugged. The SQL statement creates the XML file, and it contains the required information to enable a CREATE PLUGGABLE DATABASE
statement on a target CDB to plug in the application container. When you specify a .pdb
file, it contains a compressed archive of the XML file that describes the application container and the files used by the application container (such as the data files and wallet file). A .pdb
file enables you to copy a single, compressed file (instead of multiple files) to a new location to plug the application container into a CDB.
Before it can be unplugged, the application container must not have any application PDBs plugged into it, and it must be closed. When you unplug an application container, the unplugged application container is in mounted mode. The unplug operation makes some changes in the application container’s data files to record, for example, that the application container was successfully unplugged. Because it is still part of the CDB, the unplugged application container is included in an RMAN backup of the entire CDB. Such a backup provides a convenient way to archive the unplugged application container in case it is needed in the future.
To completely remove the application container from the CDB, you can drop it. The only operation supported on an unplugged application container is dropping the application container. The application container must be dropped from the CDB before it can be plugged back into the same CDB. An application container is usable only when it is plugged into a CDB.
Unplugging an Application Container
Unplug an application container by using an ALTER PLUGGABLE DATABASE ... UNPLUG INTO
statement.
To unplug an application container:
- In SQL*Plus, ensure that the current container is the root of the CDB.
- Close the application container.
In an Oracle Real Application Clusters (Oracle RAC) environment, the application container must be closed on all instances.
- Run the
ALTER PLUGGABLE DATABASE
statement with theUNPLUG INTO
clause, and specify the application container to unplug and the name and location of the application container’s XML metadata file or .pdb file.
Unplugging Application Container salesact
This ALTER PLUGGABLE DATABASE
statement unplugs the application container salesact
and creates the salesact.xml
metadata file in the /oracle/data/ directory
:
ALTER PLUGGABLE DATABASE salesact UNPLUG INTO '/oracle/data/saleact.xml';
Dropping an Application Container
You can drop an application container when you want to move the application container from one CDB to another or when you no longer need the application container.
Dropping an application container is very similar to dropping a PDB. When you drop an application container, the control file of the CDB is modified to eliminate all references to the dropped application container. Archived redo log files and backups associated with the application container are not removed, but you can use Oracle Recovery Manager (RMAN) to remove them.
When dropping an application container, you can either keep or delete the application container’s data files by using one of the following clauses in the DROP PLUGGABLE DATABASE
statement:
KEEP DATAFILES
, the default, retains the data files.
The application container’s temp file is removed even when KEEP DATAFILES
is specified because the temp file is no longer needed.
INCLUDING DATAFILES
removes the data files from disk.
If an application container was created with the SNAPSHOT COPY
clause, then you must specify INCLUDING DATAFILES
when you drop the application container.
To drop an application container:
- In SQL*Plus, ensure that the current container is the CDB root.
- Run the
DROP
PLUGGABLE
DATABASE
statement and specify the application container to drop.
Dropping Application Container salesact While Keeping Its Data Files
DROP PLUGGABLE DATABASE salesact
KEEP DATAFILES;
Dropping Application Container salesact and Its Data Files
DROP PLUGGABLE DATABASE saleact
INCLUDING DATAFILES;
Creating and Removing Application Seeds
You can create application seeds in several different ways, including using the PDB seed, cloning an existing PDB or non-CDB, and plugging in an unplugged PDB. You can also remove application seeds from application containers.
You can use the CREATE PLUGGABLE DATABASE
statement to create an application seed in an application container.
To create a new application seed in an application container, use the CREATE PLUGGABLE DATABASE
statement with the AS SEED
clause.
You can use an application seed to provision an application container with application PDBs that have the application root’s applications installed. Typically, the application container’s applications are installed in the application root before seed creation. After the application seed is created, it is synchronized with the application root so that the applications are installed in the application seed. When that is complete, any PDBs created using the application seed have the applications installed. When an application in the application root is upgraded or patched, the application seed must be synchronized with the application root to apply these changes.
An application container can have zero or one application seeds. When you create an application seed using the AS SEED
clause of CREATE PLUGGABLE DATABASE
, you do not specify its name. The application seed name is always application_container_name$SEED
, where application_container_name is the name of the application seed’s application container. For example, an application seed in the salesact
application container must be named salesact$SEED
.
When you create a new application seed, you must specify an administrator for the application container in the CREATE PLUGGABLE DATABASE
statement. The statement creates the administrator as a local user in the application container and grants the PDB_DBA
role locally to the administrator.
Creating an Application Seed
You create an application seed by including the AS SEED
clause in the CREATE PLUGGABLE DATABASE
statement.
An application seed in an application container is similar to the seed in a CDB. An application seed enables you to create application PDBs that meet the requirements of an application container quickly and easily.
- In SQL*Plus, ensure that the current container is the application root.
- Run the
CREATE PLUGGABLE DATABASE
statement, and include theAS SEED
clause, to create the application seed. Specify other clauses when they are required.
After you create the application seed, it is in mounted mode, and its status is NEW
. You can view the open mode of an application seed by querying the OPEN_MODE
column in the V$PDBS
view. You can view the status of an application seed by querying the STATUS
column of the CDB_PDBS
or DBA_PDBS
view.
A new default service is created for the application seed. The service has the same name as the application seed and can be used to access the application seed. Oracle Net Services must be configured properly for clients to access this service.
- Open the new application seed in read/write mode.
- You must open the new application seed in read/write mode for Oracle Database to complete the integration of the new application seed into the application container. An error is returned if you attempt to open the application seed in read-only mode. After the application seed is opened in read/write mode, its status is
NORMAL
. - Perform one or more of the following actions:
- If the application seed was created from the PDB seed, then switch container to the application seed, and use an
ALTER PLUGGABLE DATABASE
statement with theSYNC
clause to synchronize the application seed. Synchronizing with the application root instantiates one or more of the application root’s applications in the application seed. - If the application seed was created from an application root, then switch container to the application seed, and run the
pdb_to_apppdb.sql
script to convert the application root to an application PDB.
- If the application seed was created from the PDB seed, then switch container to the application seed, and use an
These actions are not required when the application seed is created by cloning an application PDB.
- Close the application seed, and then open it in open read-only mode.
- Back up the application seed.
An application seed cannot be recovered unless it is backed up.
Creating an Application Seed from the PDB seed
The following statement creates the application seed from the PDB seed, opens the application seed, switches containers to the application seed, synchronizes the application seed with the applications in the application root, closes the application seed, and then opens the application seed in open read-only mode:
CREATE PLUGGABLE DATABASE AS SEED
ADMIN USER actseedadm IDENTIFIED BY
password;
ALTER PLUGGABLE DATABASE salesact$SEED OPEN;
ALTER SESSION SET CONTAINER=salesact$SEED;
ALTER PLUGGABLE DATABASE APPLICATION ALL SYNC;
ALTER PLUGGABLE DATABASE CLOSE IMMEDIATE;
ALTER PLUGGABLE DATABASE OPEN READ ONLY;
Because the application container name is salesact
, the application seed name is salesact$SEED
.
A local user with the name of the specified local administrator is created and granted the PDB_DBA
common role locally in the application seed. If this user was not granted administrator privileges during application seed creation, then use the SYS
and SYSTEM
common users to administer to the application seed.
The application seed was synchronized with the application root when it was created. Therefore, the application seed includes the applications installed in the application root and the application common objects that are part of those applications. When a new application PDB is created using the application seed, the application PDB also includes the installed applications and application common objects.
Creating an Application Seed From an Application PDB
This example assumes the following factors:
- The application seed is being created in an application container named
salesact
. - The application seed is being created in an application PDB in the application container named
salesapppdb
. - Storage limits are not required for the application seed. Therefore, the
STORAGE
clause is not required. - The application seed 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 application root 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.
Given the preceding factors, the following statement creates the application seed from the application root, opens the application seed, closes the application seed, and opens the application seed in open read-only mode:
CREATE PLUGGABLE DATABASE AS SEED FROM salesapppdb;
ALTER PLUGGABLE DATABASE salesact$SEED OPEN;
ALTER PLUGGABLE DATABASE CLOSE IMMEDIATE;
ALTER PLUGGABLE DATABASE OPEN READ ONLY;
Because the application container name is salesact
, the application seed name is salesact$SEED
.
The application seed was created from an application PDB. Therefore, the application seed includes the applications installed in the application root and the application common objects that are part of those applications. When a new application PDB is created using the application seed, the application PDB also includes the installed applications and application common objects.
Creating an Application Seed From an Application Root
Given the preceding factors, the following statement creates the application seed from the application root, opens the application seed, switches containers to the application seed, runs the pdb_to_apppdb.sql
script to convert the application root to an application PDB, closes the application seed, and opens the application seed in open read-only mode:
CREATE PLUGGABLE DATABASE AS SEED FROM salesact;
ALTER PLUGGABLE DATABASE salesact$SEED OPEN;
ALTER SESSION SET CONTAINER=salesact$SEED;
@$ORACLE_HOME/rdbms/admin/pdb_to_apppdb.sql
ALTER PLUGGABLE DATABASE CLOSE IMMEDIATE;
ALTER PLUGGABLE DATABASE OPEN READ ONLY;
Because the application container name is salesact
, the application seed name is salesact$SEED
.
The application seed was created from the application root. Therefore, the application seed includes the applications installed in the application root and the application common objects that are part of those applications. When a new application PDB is created using the application seed, the application PDB also includes the installed applications and application common objects.
Unplugging an Application Seed from an Application Container
You can unplug an application seed from an application container.
Unplugging an application seed disassociates the application seed from an application container. You unplug an application seed when you no longer want the application seed to be available.
Unplugging an application seed is similar to unplugging a PDB. To unplug an application seed, connect to its application root and use the ALTER PLUGGABLE DATABASE
statement to specify an XML file or a .pdb
file. When you specify an XML file (.xml
extension), it will contain metadata about the application seed after it is unplugged. The SQL statement creates the XML file, and it contains the required information to enable a CREATE PLUGGABLE DATABASE
statement on a target CDB to plug it in as a PDB or an application PDB. When you specify a .pdb file, it contains a compressed archive of the XML file that describes the application seed and the files used by the application seed (such as the data files and wallet file). A .pdb
file enables you to copy a single, compressed file (instead of multiple files) to a new location to plug in as a PDB or an application PDB.
Before it can be unplugged, the application seed must be closed. When you unplug an application seed, the unplugged application seed is in mounted mode. The unplug operation makes some changes in the application seed’s data files to record, for example, that the application seed was successfully unplugged. Because it is still part of the application container, the unplugged application seed is included in an RMAN backup of the entire CDB. Such a backup provides a convenient way to archive the unplugged application seed in case it is needed in the future.
To completely remove the application seed from the application container, you can drop it. The only operation supported on an unplugged application seed is dropping the application seed. The application seed must be dropped from the application container before it can be plugged back into the same application container. An application seed is usable only when it is plugged into an application container.
Unplugging an Application Seed
To unplug an application seed, run the ALTER PLUGGABLE DATABASE ... UNPLUG INTO
statement.
To unplug an application seed:
- In SQL*Plus, ensure that the current container is the application root of the application container to which the application seed belongs.
- Close the application seed.
In an Oracle Real Application Clusters (Oracle RAC) environment, the application seed must be closed on all instances.
- Run the
ALTER PLUGGABLE DATABASE
statement with theUNPLUG INTO
clause, and specify the application seed to unplug and the name and location of the application seed’s XML metadata file or .pdb file.
Unplugging Application Seed salesact$SEED
This ALTER PLUGGABLE DATABASE
statement unplugs the application seed salesact$SEED
and creates the salesact$SEED.xml
metadata file in the /oracle/data/
directory:
ALTER PLUGGABLE DATABASE salesact$SEED
UNPLUG INTO '/oracle/data/saleact$SEED.xml';
Dropping an Application Seed
You can use the DROP
PLUGGABLE
DATABASE
statement to drop an application seed. You can drop an application seed when you no longer need it.
When you drop an application seed, the control file of the CDB is modified to eliminate all references to the dropped application seed. Archived redo log files and backups associated with the application seed are not removed, but you can use Oracle Recovery Manager (RMAN) to remove them.
When dropping an application seed, you can either keep or delete the application seed’s data files by using one of the following clauses:
KEEP DATAFILES
, the default, retains the data files.
The application seed’s temp file is removed even when KEEP DATAFILES
is specified because the temp file is no longer needed.
INCLUDING DATAFILES
removes the data files from disk.
If an application seed was created with the SNAPSHOT COPY
clause, then you must specify INCLUDING DATAFILES
when you drop the application seed.
To drop an application seed:
- In SQL*Plus, ensure that the current container is the application root of the application container to which the application seed belongs.
- Run the
DROP PLUGGABLE DATABASE
statement and specify the application seed.
Dropping Application Seed salesact$SEED While Keeping Its Data Files
DROP PLUGGABLE DATABASE salesact$SEED
KEEP DATAFILES;
Dropping Application Seed salesact$SEED and Its Data Files
DROP PLUGGABLE DATABASE saleact$SEED
INCLUDING DATAFILES;