Difference between revisions of "Application Containers"

From Robs_Wiki
Jump to: navigation, search
(Create the Application Root)
(Create an application inside the Application Root)
Line 72: Line 72:
  
 
Pluggable database altered.
 
Pluggable database altered.
 +
</pre>
 +
== Create an application PDB ==
 +
<pre>
 +
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
 
</pre>
 
</pre>

Revision as of 08:50, 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