Installing an Application in the Application Root

No artigo anterior, criamos um Application Root, e a partir dele podemos criar um Application PDB. Neste artigo vamos simular este processo.

Conectando no Application Root:

[oracle@quiasma admin]$ sqlplus sys/oracle@HR_AC as sysdba
 
SQL*Plus: Release 18.0.0.0.0 - Production on Tue Jul 6 19:22:36 2021
Version 18.13.0.0.0
 
Copyright (c) 1982, 2018, Oracle.  All rights reserved.
 
 
Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.13.0.0.0
 
SQL> SHOW CON_ID CON_NAME
 
CON_ID
------------------------------
5
 
CON_NAME
------------------------------
HR_AC
SQL>

Vamos criar um Application PDB chamado HR_APP dentro do nosso Application Root (HR_AC), utilizando o parâmetro BEGIN INSTALL com o valor da versão da aplicação:

SQL> ALTER PLUGGABLE DATABASE APPLICATION hr_app BEGIN INSTALL '1.0';
 
Pluggable database altered.

Neste ponto, vamos criar a estrutura mínima nesse novo Application PDB, como tablespace e owner que abrigarão os objetos:

SQL> CREATE TABLESPACE hr_tbs;
 
Tablespace created.
 
SQL> CREATE USER HR IDENTIFIED BY oracle DEFAULT TABLESPACE HR_TBS QUOTA UNLIMITED ON HR_TBS CONTAINER = ALL;
 
User created.
 
SQL> GRANT CREATE SESSION, CREATE TABLE, CREATE SEQUENCE, CREATE VIEW, CREATE PROCEDURE, CREATE TRIGGER TO HR;
 
Grant succeeded.

Agora alteramos o current_schema a nível de sessão e criamos uma série de objetos. Como o script é longo, vou colocar o exemplo de criação de tabela que representará o modo que os objetos estão sendo criados:

CREATE TABLE HR.JOBS SHARING=EXTENDED DATA
(
  JOB_ID      VARCHAR2(10 BYTE),
  JOB_TITLE   VARCHAR2(35 BYTE) ,
  MIN_SALARY  NUMBER(6),
  MAX_SALARY  NUMBER(6)
)
;
SQL> ALTER SESSION SET CURRENT_SCHEMA=hr;
 
Session altered.
 
SQL> host mkdir /home/oracle/scripts
 
SQL> host vi /home/oracle/scripts/hr_app_v1.0.sql
 
SQL> @/home/oracle/scripts/hr_app_v1.0.sql
SQL> @/home/oracle/scripts/hr_app_v1.0.sql
 
Sequence created.
 
 
Sequence created.
 
 
Sequence created.
 
 
Table created.
 
 
Table created.
 
 
Table created.
 
 
Table created.
 
 
Table created.
 
 
Table created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
Commit complete.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
Commit complete.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
Commit complete.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
1 row created.
 
 
Commit complete.

Só então podemos encerrar a instalação de nosso Application PDB:

SQL> ALTER PLUGGABLE DATABASE APPLICATION hr_app END INSTALL '1.0';
 
Pluggable database altered.

Podemos validar a criação do Application PDB com a consulta abaixo:

SQL> ALTER PLUGGABLE DATABASE APPLICATION hr_app END INSTALL '1.0';
 
Pluggable database altered.
 
SQL> column app_name format a15
SQL> column app_version format a10
SQL> column app_status format a15
SQL> SELECT APP_NAME, APP_VERSION, APP_STATUS FROM DBA_APPLICATIONS WHERE APP_IMPLICIT='N';
 
APP_NAME        APP_VERSIO APP_STATUS
--------------- ---------- ---------------
HR_APP          1.0        NORMAL

Obs: Este procedimento foi criado pelo senhor Ahmed Baraka (www.ahmedbaraka.com) e foi apenas reproduzido por mim em um laboratório pessoal para fins de aprendizado.

Leave a Comment

Your email address will not be published.