{"id":5680,"date":"2021-07-06T22:19:58","date_gmt":"2021-07-06T22:19:58","guid":{"rendered":"https:\/\/swiv.com.br\/creating-an-application-root\/"},"modified":"2026-05-27T20:02:30","modified_gmt":"2026-05-27T19:02:30","slug":"creating-an-application-root","status":"publish","type":"post","link":"https:\/\/swiv.com.br\/index.php\/2021\/07\/06\/creating-an-application-root\/","title":{"rendered":"Creating an Application Root"},"content":{"rendered":"\n<p>Um recurso muito interessante da arquitetura Multitenant (a partir da 12.2) \u00e9 o Application Container, que nos permite agrupar de maneira l\u00f3gica um conjunto de containers, de modo a facilitar a sua administra\u00e7\u00e3o e governan\u00e7a. Um exemplo pr\u00e1tico disso: imagine que voc\u00ea prov\u00ea um servi\u00e7o para diversos clientes, e que sua aplica\u00e7\u00e3o seja semelhante entre eles. Em vez de criar um ambiente (servidor, inst\u00e2ncia, banco de dados) para cada cliente, voc\u00ea pode criar um Application Container, com os PDBs para cada cliente. Caso precise fazer algum patch ou upgrade, pode realiz\u00e1-lo nesse conjunto, poupando esfor\u00e7o em atividades repetitivas. Em suma, \u00e9 ideal nos casos que temos m\u00faltiplos PDBS que executam a mesma aplica\u00e7\u00e3o. Nesse artigo, vamos come\u00e7ar a explorar esse item, iniciando pela cria\u00e7\u00e3o de um Application Root.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/swiv.com.br\/wp-content\/uploads\/2022\/07\/image-37.png\" alt=\"\" class=\"wp-image-7544\"\/><figcaption>Fonte:\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/docs.oracle.com\/en\/database\/oracle\/oracle-database\/21\/cncpt\/CDBs-and-PDBs.html#GUID-FC2EB562-ED31-49EF-8707-C766B6FE66B8\" target=\"_blank\">LINK<\/a><\/figcaption><\/figure>\n\n\n\n<p>Vamos logar em nosso CDB$ROOT e executar a cria\u00e7\u00e3o de um PDB, por\u00e9m com a op\u00e7\u00e3o &#8220;AS APPLICATION CONTAINER&#8221;, conforme exemplo abaixo:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@quiasma ~]$ sqlplus \/ as sysdba\n \nSQL*Plus: Release 18.0.0.0.0 - Production on Tue Jul 6 19:07:03 2021\nVersion 18.13.0.0.0\n \nCopyright (c) 1982, 2018, Oracle.  All rights reserved.\n \n \nConnected to:\nOracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production\nVersion 18.13.0.0.0\n \nSQL&gt; SELECT NAME,OPEN_MODE FROM V$DATABASE;\n \nNAME      OPEN_MODE\n--------- --------------------\nASWAN     READ WRITE\n \nSQL&gt; SHOW PDBS;\n \n    CON_ID CON_NAME                       OPEN MODE  RESTRICTED\n---------- ------------------------------ ---------- ----------\n         2 PDB$SEED                       READ ONLY  NO\n         3 HIPOFISE2                      READ WRITE NO\n         4 HIPOFISE1                      READ WRITE NO\nSQL&gt; CREATE PLUGGABLE DATABASE hr_ac AS APPLICATION CONTAINER ADMIN USER hr_acadm IDENTIFIED BY oracle;\n \nPluggable database created.\n \nSQL&gt; ALTER PLUGGABLE DATABASE hr_ac OPEN;\n \nPluggable database altered.\n<\/pre><\/div>\n\n\n<p>Consultando os Containers Root do nosso ambiente (e salvando o seu status):<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSQL&gt; col name format a10\nSQL&gt; SELECT CON_ID, NAME, OPEN_MODE FROM V$PDBS WHERE APPLICATION_ROOT=&#039;YES&#039;;\n \n    CON_ID NAME       OPEN_MODE\n---------- ---------- ----------\n         5 HR_AC      READ WRITE\n \nSQL&gt; ALTER PLUGGABLE DATABASE hr_ac SAVE STATE;\n \nPluggable database altered.\n<\/pre><\/div>\n\n\n<p>Vemos que o Application Root tamb\u00e9m cont\u00e9m tablespaces SYSTEM, SYSAUX e UNDO, como um PDB tradicional:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSQL&gt; SELECT FILE_NAME, TABLESPACE_NAME FROM CDB_DATA_FILES WHERE CON_ID=5;\n \nFILE_NAME\n--------------------------------------------------------------------------------\nTABLESPACE_NAME\n------------------------------\n\/oracle\/dados\/ASWAN\/ASWAN\/C67CA7106BF60C8BE0536A00A8C0CCB0\/datafile\/o1_mf_system\n_jg9o1p5h_.dbf\nSYSTEM\n \n\/oracle\/dados\/ASWAN\/ASWAN\/C67CA7106BF60C8BE0536A00A8C0CCB0\/datafile\/o1_mf_sysaux\n_jg9o1p5o_.dbf\nSYSAUX\n \n\/oracle\/dados\/ASWAN\/ASWAN\/C67CA7106BF60C8BE0536A00A8C0CCB0\/datafile\/o1_mf_undotb\n \nFILE_NAME\n--------------------------------------------------------------------------------\nTABLESPACE_NAME\n------------------------------\ns1_jg9o1p5o_.dbf\nUNDOTBS1\n<\/pre><\/div>\n\n\n<p>Do ponto de vista de privil\u00e9gios, podemos ver que o usu\u00e1rio administrativo (HR_ACADM) possui privil\u00e9gio \u00e0 role PDB_DBA, conforme exposto abaixo:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSQL&gt; ALTER SESSION SET CONTAINER=HR_AC;\n \nSession altered.\n \nSQL&gt; col grantee format a10\nSQL&gt; col granted_role format a15\nSQL&gt; SELECT GRANTEE, GRANTED_ROLE, COMMON FROM DBA_ROLE_PRIVS where GRANTEE =&#039;HR_ACADM&#039;;\n \nGRANTEE    GRANTED_ROLE    COM\n---------- --------------- ---\nHR_ACADM   PDB_DBA         NO\n \nSQL&gt; col role format a10\nSQL&gt; col privilege format a30\nSQL&gt; SELECT ROLE, PRIVILEGE, ADMIN_OPTION, COMMON, INHERITED FROM ROLE_SYS_PRIVS WHERE ROLE=&#039;PDB_DBA&#039;;\n \nROLE       PRIVILEGE                      ADM COM INH\n---------- ------------------------------ --- --- ---\nPDB_DBA    SET CONTAINER                  NO  NO  NO\nPDB_DBA    CREATE PLUGGABLE DATABASE      NO  NO  NO\nPDB_DBA    CREATE SESSION                 NO  NO  NO\n \nSQL&gt;\n<\/pre><\/div>\n\n\n<p>Tamb\u00e9m percebemos que \u00e9 poss\u00edvel a conex\u00e3o direto ao Application Container atrav\u00e9s do Listener. Para isso, vamos inserir em nosso arquivo tnsnames.ora a string de conex\u00e3o e testar:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@quiasma admin]$ tnsping HR_AC\n \nTNS Ping Utility for Linux: Version 18.0.0.0.0 - Production on 06-JUL-2021 19:16:21\n \nCopyright (c) 1997, 2020, Oracle.  All rights reserved.\n \nUsed parameter files:\n\/oracle\/18.0.0\/product\/network\/admin\/sqlnet.ora\n \n \nUsed TNSNAMES adapter to resolve the alias\nAttempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = quiasma.localdomain)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = HR_AC.localdomain)))\nOK (0 msec)\n&#x5B;oracle@quiasma admin]$\n<\/pre><\/div>\n\n\n<p>Conex\u00e3o:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@quiasma admin]$ sqlplus sys\/oracle@HR_AC as sysdba\n \nSQL*Plus: Release 18.0.0.0.0 - Production on Tue Jul 6 19:17:13 2021\nVersion 18.13.0.0.0\n \nCopyright (c) 1982, 2018, Oracle.  All rights reserved.\n \n \nConnected to:\nOracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production\nVersion 18.13.0.0.0\n \nSQL&gt; SHOW CON_ID CON_NAME\n \nCON_ID\n------------------------------\n5\n \nCON_NAME\n------------------------------\nHR_AC\nSQL&gt;\n<\/pre><\/div>\n\n\n<p>Obs: Este procedimento foi criado pelo senhor Ahmed Baraka (www.ahmedbaraka.com) e foi apenas reproduzido por mim em um laborat\u00f3rio pessoal para fins de aprendizado.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Um recurso muito interessante da arquitetura Multitenant (a partir da 12.2) \u00e9 o Application Container, que nos permite agrupar de maneira l\u00f3gica um conjunto de containers, de modo a facilitar a sua administra\u00e7\u00e3o e governan\u00e7a. Um exemplo pr\u00e1tico disso: imagine que voc\u00ea prov\u00ea um servi\u00e7o para diversos clientes, e que sua aplica\u00e7\u00e3o seja semelhante entre [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-5680","post","type-post","status-publish","format-standard","hentry","category-multitenant"],"_links":{"self":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/5680","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/comments?post=5680"}],"version-history":[{"count":1,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/5680\/revisions"}],"predecessor-version":[{"id":9087,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/5680\/revisions\/9087"}],"wp:attachment":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/media?parent=5680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/categories?post=5680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/tags?post=5680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}