Difference between revisions of "Application Containers"

From Robs_Wiki
Jump to: navigation, search
(Create an application inside the Application Root)
(Create an application PDB)
Line 108: Line 108:
 
         1 ONE
 
         1 ONE
 
         2 TWO
 
         2 TWO
 +
</pre>
 +
== Create an Application Seed (optional) ==
 +
An application root container can optionally have an application seed database, allowing you to have a preconfigured seed for creation of new application containers. An application seed can be created from the CDB seed, an existing application container or an application root container. In this example we will create a new application seed from the CDB seed.
 +
<br /> <br />
 +
To create an application seed from an existing application pdb (the easiest way):
 +
<pre>
 +
SQL> show con_name
 +
 +
CON_NAME
 +
------------------------------
 +
MYAPP_ROOT
 +
 +
SQL> create pluggable database as seed from myapp_one;
 +
 +
Pluggable database created.
 +
 +
SQL> alter pluggable database myapp_root$SEED open;
 +
 +
Pluggable database altered.
 +
 +
SQL> alter pluggable database myapp_root$SEED open read only;
 +
 +
Pluggable database altered.
 
</pre>
 
</pre>

Revision as of 08:53, 4 October 2020

Introduction

Oracle 12.2 introduces the concept of application containers, which act like a mini-root container. They can be used to centralize shared configuration and applications, which are used by their dependent application PDBs.

Create the Application Root

SQL> create pluggable database myapp_root as application container admin user rob identified by rob roles = (DBA);

Pluggable database created.

SQL> alter pluggable database myapp_root open;

Pluggable database altered.

SQL> alter pluggable database myapp_root save state;

Pluggable database altered.

Create an application inside the Application Root

SQL> alter session set container = myapp_root;

SQL> alter pluggable database application myapp begin install '1.0';

Pluggable database altered.

SQL> create tablespace myapp_data datafile size 10M autoextend on maxsize 500M;

Tablespace created.

SQL> create user myapp_owner identified by myapp_owner default tablespace myapp_data container=all;

User created.

SQL> grant create session, create table to myapp_owner;

Grant succeeded.

SQL> alter user myapp_owner quota unlimited on myapp_data;

User altered.

SQL> alter session set current_schema=myapp_owner;

Session altered.

SQL> create table myapp_table sharing=metadata (n number primary key);

Table created.

SQL> create table myapp_static sharing=data (n number primary key, s varchar2(20));

Table created.

SQL> insert into myapp_static values (1,'ONE');

1 row created.

SQL> insert into myapp_static values (2,'TWO');

1 row created.

SQL> insert into myapp_table values (1);

1 row created.

SQL> commit;

Commit complete.

SQL> alter pluggable database application myapp end install '1.0';

Pluggable database altered.

Create an application PDB

SQL> create pluggable database myapp_one admin user rob identified by rob;      

Pluggable database created.

SQL> alter pluggable database myapp_one open;

Pluggable database altered.

SQL> alter pluggable database myapp_one save state;

SQL> alter session set container=myapp_one;

Session altered.

SQL> alter pluggable database application myapp sync;

Pluggable database altered.

SQL> show user
USER is "SYS"

SQL> show con_name       

CON_NAME
------------------------------
MYAPP_ONE

SQL> select * from myapp_owner.myapp_static; 

         N S
---------- --------------------
         1 ONE
         2 TWO

Create an Application Seed (optional)

An application root container can optionally have an application seed database, allowing you to have a preconfigured seed for creation of new application containers. An application seed can be created from the CDB seed, an existing application container or an application root container. In this example we will create a new application seed from the CDB seed.

To create an application seed from an existing application pdb (the easiest way):

SQL> show con_name

CON_NAME
------------------------------
MYAPP_ROOT

SQL> create pluggable database as seed from myapp_one;

Pluggable database created.

SQL> alter pluggable database myapp_root$SEED open;

Pluggable database altered.

SQL> alter pluggable database myapp_root$SEED open read only;

Pluggable database altered.