{
  "date": "2014-12-29T19:28:00",
  "slug": "oracle-multitenant-dictionary-object-links",
  "link": "https://www.dbi-services.com/blog/oracle-multitenant-dictionary-object-links/",
  "title": {
    "rendered": "Oracle multitenant dictionary: object links"
  },
  "content": {
    "rendered": "<h2>By Franck Pachot</h2>\n<p>.<br />\nI&#8217;ve described Oracle 12c metadata and object links internals in a <a href=\"https://www.dbi-services.com/index.php/blog/entry/oracle-12c-cdb-metadata-a-object-links-internals#comment-363\">previous post</a>. But before that, the first time I investigated on it, I made a wrong assumption because I was looking at AUDIT_ACTIONS which is not correctly implemented. That investigation came from a question on <a href=\"http://www.dba-village.com/village/dvp_forum.OpenThread?ThreadIdA=69321#202961\">dba-village</a>. And recently Ivica Arsov (<a href=\"https://twitter.com/IvicaArsov\">@IvicaArsov</a>) has made an interesting <a href=\"https://www.dbi-services.com/index.php/blog/entry/oracle-12c-cdb-metadata-a-object-links-internals#comment-363\">comment</a> about AUDIT_ACTIONS object link table, so I&#8217;ll explain here what is special with it.</p>\n<h3>AUDIT_ACTIONS</h3>\n<p>Here is how is defined AUDIT_ACTIONS:</p>\n<pre><code>SQL&gt; select object_name,object_type,sharing from dba_objects where object_name in ('DBA_AUDIT_TRAIL','AUDIT_ACTIONS') order by object_name,object_type;\n\nOBJECT_NAME          OBJECT_TYPE     SHARING\n-------------------- --------------- -------------\nAUDIT_ACTIONS        SYNONYM         METADATA LINK\nAUDIT_ACTIONS        TABLE           OBJECT LINK\nDBA_AUDIT_TRAIL      SYNONYM         METADATA LINK\nDBA_AUDIT_TRAIL      VIEW            METADATA LINK\n</code></pre>\n<p>It&#8217;s a sharing=object table so you expect that the data is common to all containers. And we will also query a view that reads that table &#8211; DBA_AUDIT_TRAIL.</p>\n<p>Then let&#8217;s query the table from CDB$ROOT and from a PDB and check from ROWID if we read the same rows:</p>\n<pre><code>SQL&gt; alter session set container=CDB$ROOT;\nSession altered.\n\nSQL&gt; select rowid,action,name,dbms_rowid.rowid_to_absolute_fno(rowid,'SYS','AUDIT_ACTIONS') file_id from AUDIT_ACTIONS where action=3;\n\nROWID                  ACTION NAME       FILE_ID\n------------------ ---------- ------- ----------\nAAABG7AABAAACo5AAD          3 SELECT           1\n\nSQL&gt; alter session set container=PDB1;\nSession altered.\n\nSQL&gt; select rowid,action,name,dbms_rowid.rowid_to_absolute_fno(rowid,'SYS','AUDIT_ACTIONS') file_id from AUDIT_ACTIONS where action=3;\n\nROWID                  ACTION NAME       FILE_ID\n------------------ ---------- ------- ----------\nAAABG5AABAAAA3pAAD          3 SELECT           8\n\n</code></pre>\n<p>The rows are not coming from the same file, but from the local SYSTEM tablespace of each container. This is a proof that this OBJECT LINK table is not common at all.</p>\n<h3>DBA_AUDIT_TRAIL</h3>\n<p>Now I want to check what happens when we query through the view. I don&#8217;t have the ROWID so let&#8217;s update the table in the PDB so that we can distinguish rows coming from CDB$ROOT and from PDB1:</p>\n<pre><code>SQL&gt; update AUDIT_ACTIONS set name='select' where action=3;\n\n1 row updated.\n\nSQL&gt; select rowid,action,name from AUDIT_ACTIONS where action=3;\n\nROWID                  ACTION NAME\n------------------ ---------- -------\nAAABG5AABAAAA3pAAD          3 select\n\nSQL&gt; select distinct dbid,action,action_name from DBA_AUDIT_TRAIL;\n\n      DBID     ACTION ACTION_NAME\n---------- ---------- ----------------------------\n 314687597          3 select\n\n</code></pre>\n<p>Ok. I&#8217;ve changed one &#8216;ACTION_NAME&#8217; to lowercase &#8211; only in the PDB1. And when I query through the view I see the local row. This definitly prooves that the implementation of AUDIT_ACTIONS is not achieving the goal of multinenant dictionary: store common oracle objects only in CDB$ROOT to avoid duplication and faciliate upgrade. Note that it is not a big problem anyway as it is just a 200 rows table.</p>\n<h3>DBA_CPOOL_INFO</h3>\n<p>In order to show the normal behaviour of object links I&#8217;ll do the same with DBA_CPOOL_INFO which is a view over SYS.CPOOL$. I&#8217;ve described this behaviour <a href=\"https://www.dbi-services.com/index.php/blog/entry/oracle-12c-cdb-metadata-a-object-links-internals\">previously</a> by creating my own objects but here I&#8217;ll show how it is used to store the DRCP information which is at CDB level. Here are the involved table and views:</p>\n<pre><code>SQL&gt; select object_name,object_type,sharing from dba_objects where object_name in ('CPOOL$','INT$DBA_CPOOL_INFO','DBA_CPOOL_INFO') order by object_name,object_type;\n\nOBJECT_NAME          OBJECT_TYPE     SHARING\n-------------------- --------------- -------------\nCPOOL$               TABLE           OBJECT LINK\nDBA_CPOOL_INFO       SYNONYM         METADATA LINK\nDBA_CPOOL_INFO       VIEW            METADATA LINK\nINT$DBA_CPOOL_INFO   VIEW            OBJECT LINK\n</code></pre>\n<p>CPOOL$ is defined with sharing=object. An internal view INT$DBA_CPOOL_INFO is defined on it with sharing=object as well. And finally that view is exposed through DBA_CPOOL_INFO.</p>\n<p>As before, I check the ROWID of CPOOL$ row from CDB$ROOT and PDB1:</p>\n<pre><code>SQL&gt; alter session set container=CDB$ROOT;\nSession altered.\n\nSQL&gt; select rowid,minsize,dbms_rowid.rowid_to_absolute_fno(rowid,'SYS','CPOOL$') file_id from SYS.CPOOL$;\n\nROWID                 MINSIZE    FILE_ID\n------------------ ---------- ----------\nAAABz5AABAAADb5AAA          4          1\n\nSQL&gt; alter session set container=PDB1;\nSession altered.\n\nSQL&gt; select rowid,minsize,dbms_rowid.rowid_to_absolute_fno(rowid,'SYS','CPOOL$') file_id from SYS.CPOOL$;\n\nROWID                 MINSIZE    FILE_ID\n------------------ ---------- ----------\nAAABz3AABAAABQJAAA          4          8\n\n</code></pre>\n<p>So this is the same as we have seen before: an OBJECT LINK has its data in each PDB.</p>\n<p>But what is different here is the view charing which is sharing=object. Let&#8217;s query that view after changing the value in PDB1:</p>\n<pre><code>SQL&gt; update SYS.CPOOL$ set minsize=0;\n1 row updated.\n\nSQL&gt; select rowid,minsize,dbms_rowid.rowid_to_absolute_fno(rowid,'SYS','CPOOL$') file_id from SYS.CPOOL$;\n\nROWID                 MINSIZE    FILE_ID\n------------------ ---------- ----------\nAAABz3AABAAABQJAAA          0          8\n\nSQL&gt; select minsize from INT$DBA_CPOOL_INFO;\n\n   MINSIZE\n----------\n         4\n\nSQL&gt; select minsize from DBA_CPOOL_INFO;\n\n   MINSIZE\n----------\n         4\n\n</code></pre>\n<p>Now we have a view which will always show the CDB$ROOT rows, even when we are in a PDB container. We still have rows in the PDB containers, but they will not be used. Once again, this defeats the goal of deduplication, but this is a very small table.</p>\n<h3>AWR tables</h3>\n<p>The main advantage of multitenant dictionary architecture is with the big tables storing data which is common in the whole CDB, such as the AWR data:</p>\n<pre><code>SQL&gt; alter session set container=CDB$ROOT;\nSession altered.\n\nSQL&gt; select con_id,count(*) from containers(WRH$_SQLTEXT) group by con_id;\n\n    CON_ID   COUNT(*)\n---------- ----------\n         1       5549\n\nSQL&gt; alter session set container=PDB1;\n\nSession altered.\n\nSQL&gt; select count(*) from WRH$_SQLTEXT;\n\n  COUNT(*)\n----------\n         0\n\n</code></pre>\n<p>This information &#8211; stored only from CDB$ROOT &#8211; is shared in all PDB through the OBJECT LINK view.</p>\n",
    "protected": false
  }
}
