<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Oracle Team, auteur/autrice sur dbi Blog</title>
	<atom:link href="https://www.dbi-services.com/blog/author/oracle-team/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbi-services.com/blog/author/oracle-team/</link>
	<description></description>
	<lastBuildDate>Tue, 11 Mar 2025 09:24:56 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2025/05/cropped-favicon_512x512px-min-32x32.png</url>
	<title>Oracle Team, auteur/autrice sur dbi Blog</title>
	<link>https://www.dbi-services.com/blog/author/oracle-team/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Why Data Pump Fails to Import Scheduler-Programs</title>
		<link>https://www.dbi-services.com/blog/why-data-pump-fails-to-import-scheduler-programs/</link>
					<comments>https://www.dbi-services.com/blog/why-data-pump-fails-to-import-scheduler-programs/#comments</comments>
		
		<dc:creator><![CDATA[Oracle Team]]></dc:creator>
		<pubDate>Fri, 21 Feb 2025 05:50:00 +0000</pubDate>
				<category><![CDATA[Database management]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Data pump]]></category>
		<category><![CDATA[dbms_metadata]]></category>
		<category><![CDATA[dbms_scheduler]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[program argument]]></category>
		<category><![CDATA[scheduler]]></category>
		<category><![CDATA[scheduler job]]></category>
		<category><![CDATA[scheduler program]]></category>
		<guid isPermaLink="false">https://www.dbi-services.com/blog/?p=37197</guid>

					<description><![CDATA[<p>Here is the How To of scripting them instead Oracle Data Pump can import simple programs without arguments, but it fails when handling Scheduler-Programs that contain arguments. This has been a persistent issue with no official resolution. Since this was a critical challenge in a recent project of mine, I’d like to share my solution. [&#8230;]</p>
<p>L’article <a href="https://www.dbi-services.com/blog/why-data-pump-fails-to-import-scheduler-programs/">Why Data Pump Fails to Import Scheduler-Programs</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading" id="h-here-is-the-how-to-of-scripting-them-instead">Here is the How To of scripting them instead</h2>



<p class="wp-block-paragraph">Oracle Data Pump can import simple programs without arguments, but it fails when handling Scheduler-Programs that contain arguments. This has been a persistent issue with no official resolution. <br>Since this was a critical challenge in a recent project of mine, I’d like to share my solution.</p>



<p class="wp-block-paragraph">In rare cases, the scripts are available and can be reused, but when you need to dig through Change Requests, JIRA tickets or the Document Management System (DMS) because the developer has already retired, you’re often left with no choice but to reengineer the solution.</p>



<p class="wp-block-paragraph">At first, I started with a schema-export and import which generated a log file with 15,000 lines and hundreds of error messages. I was puzzled by this message:<br>There were more of them, however I would like to use this single Scheduler-Program as example.</p>



<h6 class="wp-block-heading" id="h-here-s-an-example-of-an-error-message-i-encountered">Here’s an example of an error message I encountered:</h6>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
19-OCT-24 10:55:09.222: ORA-39083: Object type PROCOBJ:&quot;MMTK&quot;.&quot;MAIL_MMTK_PRG&quot; failed to create with error:
ORA-06550: line 8, column 265:
PL/SQL: ORA-00942: table or view does not exist
ORA-06550: line 8, column 21:
PL/SQL: SQL Statement ignored
ORA-06550: line 11, column 5:
PLS-00364: loop index variable &#039;ARG&#039; use is invalid
ORA-06550: line 11, column 2:
PL/SQL: Statement ignored

Failing sql is:
BEGIN 
dbms_scheduler.create_program(&#039;&quot;MAIL_MMTK_PRG&quot;&#039;,&#039;STORED_PROCEDURE&#039;,
&#039;PKG_JOBMMTK.prc_wmail&#039;
,18, FALSE,
&#039;Send Mail&#039;
);
DECLARE 
CURSOR prog_args IS SELECT replace(a.argument_name, &#039;&#039;&#039;&#039;, &#039;&#039;&#039;&#039;&#039;&#039;) arg_name,  a.argument_position position, a.argument_type type_name, a.metadata_attribute int_arg_type, a.default_anydata_value value, decode(a.out_argument,&#039;FALSE&#039;,0,&#039;TRUE&#039;,1) out_flag  FROM SYSTEM.SCHEDULER_PROGRAM_ARGS_TMP a  where a.owner=&#039;MMTK&#039; and  a.program_name=&#039;MAIL_MMTK_PRG&#039;;
 BEGIN
FOR arg in prog_args LOOP
 IF arg.int_arg_type IS NULL THEN
 dbms_scheduler.define_anydata_argument(&#039;&quot;MAIL_MMTK_PRG&quot;&#039; , arg.position,  CASE WHEN arg.arg_name IS NULL THEN NULL ELSE 
     &#039;&quot;&#039;||arg.arg_name||&#039;&quot;&#039; END, arg.type_name, arg.value, arg.out_flag=1 );
 ELSE
 dbms_scheduler.define_metadata_argument(&#039;&quot;MAIL_MMTK_PRG&quot;&#039; ,arg.int_arg_type, arg.position, CASE WHEN arg.arg_name IS NULL THEN NULL ELSE 
     &#039;&quot;&#039;||arg.arg_name||&#039;&quot;&#039; END );
 END IF;
 END LOOP;
 END;
dbms_scheduler.enable(&#039;&quot;MAIL_MMTK_PRG&quot;&#039;);COMMIT; END;

</pre></div>


<p class="wp-block-paragraph">The first hint (ORA-00942) suggests a missing table or privilege, but which one?<br>Maybe the SYSTEM.SCHEDULER_PROGRAM_ARGS_TMP in the DECLARE-block? It does not exist. Sounds like a temporary view during import.<br>The second hint about variable ‘ARG’ is mysterious – though the loop variable appears syntactically correct, it still triggers an error. <br>Furthermore, in another Scheduler-Program, I found the same error.<br>Although the Scheduler-Programs worked fine in the existing environment, I could not import them. Missing tables or permissions as the reason for the errors could be excluded after some work.<br>Somewhere on the internet, I found the information, that this is an unsolved problem. A request for enhancement is pending …</p>



<p class="wp-block-paragraph">Now, how can we script these Scheduler-Programs?<br>dbms-metadata? Good idea! Let’s see what it delivers:</p>



<h6 class="wp-block-heading" id="h-to-extract-the-definition-of-the-scheduler-program-i-used-the-following-command">To extract the definition of the Scheduler-Program, I used the following command:</h6>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
select dbms_metadata.get_ddl(&#039;PROCOBJ&#039;,&#039;MAIL_MMTK_PRG&#039;,&#039;MMTK&#039;) from dual;

BEGIN
  dbms_scheduler.create_program(&#039;MAIL_MMTK_PRG&#039;,&#039;STORED_PROCEDURE&#039;,
  &#039;PKG_JOBMMTK.prc_wmail&#039;, 18, FALSE, &#039;Send Mail&#039;
);
COMMIT;
END;
/
</pre></div>


<p class="wp-block-paragraph">Nice <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f610.png" alt="😐" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br>It retrieves the Scheduler-Program itself, but not its arguments <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2639.png" alt="☹" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br>This is just the “failing sql” we have seen in the error message above.</p>



<h6 class="wp-block-heading" id="h-using-user-scheduler-program-args-allows-us-to-reconstruct-missing-arguments">Using USER_SCHEDULER_PROGRAM_ARGS allows us to reconstruct missing arguments</h6>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
select argument_position, argument_name, argument_type, default_value 
 from USER_SCHEDULER_PROGRAM_ARGS 
 where  program_name = &#039;MAIL_MMTK_PRG&#039; order by   argument_position;

ARGUMENT_POSITION ARGUMENT_NAME      ARGUMENT_TYPE  DEFAULT_VALUE
----------------- ------------------ -------------- --------------------
                1 P_HOST             VARCHAR2       mailhost
                2 P_DOMAIN           VARCHAR2       mycompany.com
                3 P_PORTNUM          NUMBER         25
                4 P_FROM             VARCHAR2
                5 P_TO               VARCHAR2
                6 P_CC               VARCHAR2
                7 P_BCC              VARCHAR2
                8 P_REPLYTO          VARCHAR2
                9 P_SUBJECT          VARCHAR2
               10 P_MSGTXT           VARCHAR2
               11 P_CONTENTS         VARCHAR2
               12 P_ATTACH           VARCHAR2
               13 P_URL              VARCHAR2
               14 P_TRACEMODE        VARCHAR2       N
               15 P_MIMETYPE         VARCHAR2       text/plain
               16 P_DISPOSITION      VARCHAR2       attachment
               17 P_CHARSET          VARCHAR2       iso-8859-1
               18 P_TRANSFERTENCODE  VARCHAR2

</pre></div>


<p class="wp-block-paragraph">I was not aware that Emails need to have 18 arguments, but ok<br>Now I started puzzling pieces. The syntax for an argument is:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
dbms_scheduler.define_program_argument(
 program_name      =&gt; &#039;MAIL_MMTK_PRG&#039;,
 argument_position =&gt; 1,
 argument_name     =&gt; &#039;P_HOST&#039;,
 argument_type     =&gt; &#039;VARCHAR2&#039;,
 default_value     =&gt; &#039;mailhost&#039;  );

</pre></div>


<p class="wp-block-paragraph">copy this block 18 times and insert the values from listing above.<br>Yes, I could have done some clever dynamic-SQL …</p>



<p class="wp-block-paragraph">At the end, the entire code block looks like that:<br>Before, you need to create the scheduler-program as seen above &#8211; of course &#8230;</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
begin
  dbms_scheduler.define_program_argument(
    program_name      =&gt; &#039;MAIL_MMTK_PRG&#039;,
    argument_position =&gt; 1,
    argument_name     =&gt; &#039;P_HOST&#039;,
    argument_type     =&gt; &#039;VARCHAR2&#039;,
    default_value     =&gt; &#039;mailhost&#039;  );
  dbms_scheduler.define_program_argument(
    program_name      =&gt; &#039;MAIL_MMTK_PRG&#039;,
    argument_position =&gt; 2,
    argument_name     =&gt; &#039;P_DOMAIN&#039;,
    argument_type     =&gt; &#039;VARCHAR2&#039;,
    default_value     =&gt; &#039;mycompany.com&#039;  );
  dbms_scheduler.define_program_argument(
    program_name      =&gt; &#039;MAIL_MMTK_PRG&#039;,
    argument_position =&gt; 3,
    argument_name     =&gt; &#039;P_PORTNUM&#039;,
    argument_type     =&gt; &#039;NUMBER&#039;,
    default_value     =&gt; 25  );
  dbms_scheduler.define_program_argument(
    program_name      =&gt; &#039;MAIL_MMTK_PRG&#039;,
    argument_position =&gt; 4,
    argument_name     =&gt; &#039;P_FROM&#039;,
    argument_type     =&gt; &#039;VARCHAR2&#039;,
    default_value     =&gt; NULL  );
  dbms_scheduler.define_program_argument(
    program_name      =&gt; &#039;MAIL_MMTK_PRG&#039;,
    argument_position =&gt; 5,
    argument_name     =&gt; &#039;P_TO&#039;,
    argument_type     =&gt; &#039;VARCHAR2&#039;,
    default_value     =&gt; NULL  );
  dbms_scheduler.define_program_argument(
    program_name      =&gt; &#039;MAIL_MMTK_PRG&#039;,
    argument_position =&gt; 6,
    argument_name     =&gt; &#039;P_CC&#039;,
    argument_type     =&gt; &#039;VARCHAR2&#039;,
    default_value     =&gt; NULL  );
  dbms_scheduler.define_program_argument(
    program_name      =&gt; &#039;MAIL_MMTK_PRG&#039;,
    argument_position =&gt; 7,
    argument_name     =&gt; &#039;P_BCC&#039;,
    argument_type     =&gt; &#039;VARCHAR2&#039;,
    default_value     =&gt; NULL  );
  dbms_scheduler.define_program_argument(
    program_name      =&gt; &#039;MAIL_MMTK_PRG&#039;,
    argument_position =&gt; 8,
    argument_name     =&gt; &#039;P_REPLYTO&#039;,
    argument_type     =&gt; &#039;VARCHAR2&#039;,
    default_value     =&gt; NULL  );
  dbms_scheduler.define_program_argument(
    program_name      =&gt; &#039;MAIL_MMTK_PRG&#039;,
    argument_position =&gt; 9,
    argument_name     =&gt; &#039;P_SUBJECT&#039;,
    argument_type     =&gt; &#039;VARCHAR2&#039;,
    default_value     =&gt; NULL  );
  dbms_scheduler.define_program_argument(
    program_name      =&gt; &#039;MAIL_MMTK_PRG&#039;,
    argument_position =&gt; 10,
    argument_name     =&gt; &#039;P_MSGTXT&#039;,
    argument_type     =&gt; &#039;VARCHAR2&#039;,
    default_value     =&gt; NULL  );
  dbms_scheduler.define_program_argument(
    program_name      =&gt; &#039;MAIL_MMTK_PRG&#039;,
    argument_position =&gt; 11,
    argument_name     =&gt; &#039;P_CONTENTS&#039;,
    argument_type     =&gt; &#039;VARCHAR2&#039;,
    default_value     =&gt; NULL  );
  dbms_scheduler.define_program_argument(
    program_name      =&gt; &#039;MAIL_MMTK_PRG&#039;,
    argument_position =&gt; 12,
    argument_name     =&gt; &#039;P_ATTACH&#039;,
    argument_type     =&gt; &#039;VARCHAR2&#039;,
    default_value     =&gt; NULL  );
  dbms_scheduler.define_program_argument(
    program_name      =&gt; &#039;MAIL_MMTK_PRG&#039;,
    argument_position =&gt; 13,
    argument_name     =&gt; &#039;P_URL&#039;,
    argument_type     =&gt; &#039;VARCHAR2&#039;,
    default_value     =&gt; NULL  );
  dbms_scheduler.define_program_argument(
    program_name      =&gt; &#039;MAIL_MMTK_PRG&#039;,
    argument_position =&gt; 14,
    argument_name     =&gt; &#039;P_TRACEMODE&#039;,
    argument_type     =&gt; &#039;VARCHAR2&#039;,
    default_value     =&gt; &#039;N&#039;  );
  dbms_scheduler.define_program_argument(
    program_name      =&gt; &#039;MAIL_MMTK_PRG&#039;,
    argument_position =&gt; 15,
    argument_name     =&gt; &#039;P_MIMETYPE&#039;,
    argument_type     =&gt; &#039;VARCHAR2&#039;,
    default_value     =&gt; &#039;text/plain&#039;  );
  dbms_scheduler.define_program_argument(
    program_name      =&gt; &#039;MAIL_MMTK_PRG&#039;,
    argument_position =&gt; 16,
    argument_name     =&gt; &#039;P_DISPOSITION&#039;,
    argument_type     =&gt; &#039;VARCHAR2&#039;,
    default_value     =&gt; &#039;attachment&#039;  );
  dbms_scheduler.define_program_argument(
    program_name      =&gt; &#039;MAIL_MMTK_PRG&#039;,
    argument_position =&gt; 17,
    argument_name     =&gt; &#039;P_CHARSET&#039;,
    argument_type     =&gt; &#039;VARCHAR2&#039;,
    default_value     =&gt; &#039;iso-8859-1&#039;  );
  dbms_scheduler.define_program_argument(
    program_name      =&gt; &#039;MAIL_MMTK_PRG&#039;,
    argument_position =&gt; 18,
    argument_name     =&gt; &#039;P_TRANSFERTENCODE&#039;,
    argument_type     =&gt; &#039;VARCHAR2&#039;,
    default_value     =&gt; NULL  );
commit;
end;
/

exec DBMS_SCHEDULER.ENABLE(name=&gt;&#039;MAIL_MMTK_PRG&#039;);

</pre></div>


<p class="wp-block-paragraph">I hope this guide helps others facing the same issue. If you’ve encountered this problem before or have alternative solutions, share your thoughts in the comments!</p>
<p>L’article <a href="https://www.dbi-services.com/blog/why-data-pump-fails-to-import-scheduler-programs/">Why Data Pump Fails to Import Scheduler-Programs</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbi-services.com/blog/why-data-pump-fails-to-import-scheduler-programs/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Cleanup Oracle After Patching</title>
		<link>https://www.dbi-services.com/blog/cleanup-after-patching/</link>
					<comments>https://www.dbi-services.com/blog/cleanup-after-patching/#comments</comments>
		
		<dc:creator><![CDATA[Oracle Team]]></dc:creator>
		<pubDate>Tue, 11 Feb 2025 16:55:59 +0000</pubDate>
				<category><![CDATA[Database Administration & Monitoring]]></category>
		<category><![CDATA[Database management]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[cleanup]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[guideline]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[inactive]]></category>
		<category><![CDATA[know how]]></category>
		<category><![CDATA[obsolete]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[patches]]></category>
		<category><![CDATA[release update]]></category>
		<category><![CDATA[remove]]></category>
		<category><![CDATA[update]]></category>
		<guid isPermaLink="false">https://www.dbi-services.com/blog/?p=37011</guid>

					<description><![CDATA[<p>cleanup Oracle-Home(s) after applying the quarterly Release Updates Do you suffer from the fact that release updates take longer each time?Are you afraid that your hard disk will fill up because the Oracle-Home is getting bigger and bigger?Here is the how-to for cleaning up your environment. A) cleanup &#8211; option 1 for Out-Of-Place patching According [&#8230;]</p>
<p>L’article <a href="https://www.dbi-services.com/blog/cleanup-after-patching/">Cleanup Oracle After Patching</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading" id="h-cleanup-oracle-home-s-after-applying-the-quarterly-release-updates">cleanup Oracle-Home(s) <br>after applying the quarterly Release Updates</h2>



<p class="wp-block-paragraph">Do you suffer from the fact that release updates take longer each time?<br>Are you afraid that your hard disk will fill up because the Oracle-Home is getting bigger and bigger?<br>Here is the how-to for cleaning up your environment.  </p>



<h3 class="wp-block-heading" id="h-a-cleanup-option-1-for-out-of-place-patching"><strong>A) cleanup &#8211; option 1 for Out-Of-Place patching</strong></h3>



<p class="has-medium-font-size wp-block-paragraph">According to Oracle&#8217;s recommendations, you did &#8220;out of place patching&#8221; and have now several Oracle-Home directories.<br>All your databases are using the new ORACLE_HOME (OH) and the old OHs are now obsolete.<br>Cleaning up is not only a matter of disk space. The old Software releases contain security issues &#8211; of course. This is the very reason for patching.</p>



<h6 class="wp-block-heading" id="h-set-the-environment-for-the-oh-you-want-to-delete">Set the environment for the OH you want to delete</h6>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
export ORACLE_HOME=/u01/app/oracle/product/19.25.0/dbhome_1
PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/perl/bin:$ORACLE_HOME/ctx/bin
PATH=$PATH:/home/oracle/.local/bin:/home/oracle/bin:/usr/local/bin:/usr/bin:/usr/ccs/bin:/usr/local/sbin:/usr/sbin:/sbin
export PATH
export CV_ASSUME_DISTID=OEL8.1

cd $ORACLE_HOME/deinstall
./deinstall
   -&gt; enter required answers …
       Enter     (confirm &#x5B;LISTENER] )
       Enter     (confirm databases &#x5B;] )
        Y        (to confirm to delete the listed OH)
</pre></div>


<h6 class="wp-block-heading" id="h-you-can-delete-the-empty-directory-now">you can delete the empty directory, now</h6>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
cd /u01/app/oracle/product/
du -sh *
rmdir 19.25.0
</pre></div>


<h3 class="wp-block-heading" id="h-b-cleanup-option-2-for-out-of-place-patching"><strong>B) cleanup &#8211; option 2 for Out-Of-Place patching</strong></h3>



<p class="wp-block-paragraph">In some cases, the deinstall does not work and gives you some error messages.<br>Now we have the option to detach AND remove the old ORACLE_HOME.<br>In this example our OH-path is:   /u01/app/oracle/product/19.15.0.0.220419.EE</p>



<h6 class="wp-block-heading" id="h-first-you-need-to-find-the-home-name-for-the-oh-to-deinstall-you-might-have-to-look-into-several-subfolders-for-it">first you need to find the &#8220;Home-Name&#8221; for the OH to deinstall &#8211; you might have to look into several subfolders for it</h6>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
cd /u01/app/oraInventory/logs
ls -l
cd InstallActions&lt;timestamp&gt;
grep -i ORACLE_HOME_NAME *.log
--&gt;&gt; responds for example with:   OraDB19Home1
</pre></div>


<h6 class="wp-block-heading" id="h-set-the-environment-for-the-oracle-home-to-remove-and-detach-it">set the environment for the ORACLE_HOME to remove and DETACH it</h6>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
export ORACLE_HOME=/u01/app/oracle/product/19.15.0.0.220419.EE
PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/perl/bin:$ORACLE_HOME/ctx/bin
PATH=$PATH:/home/oracle/.local/bin:/home/oracle/bin:/usr/local/bin:/usr/bin:/usr/ccs/bin:/usr/local/sbin:/usr/sbin:/sbin
export PATH
export CV_ASSUME_DISTID=OEL8.1

cd $ORACLE_HOME/oui/bin
./runInstaller -silent -detachHome ORACLE_HOME=&quot;/u01/app/oracle/product/19.15.0.0.220419.EE&quot; ORACLE_HOME_NAME=&quot;OraDB19Home1&quot;

cd /u01/app/oracle/product
rm -rf 19.15.0.0.220419.EE

</pre></div>


<h6 class="wp-block-heading" id="h-and-don-t-forget-to-remove-the-obsolete-oh-from-the-oratab-file">and don&#8217;t forget to remove the obsolete OH from the oratab file</h6>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
vi /etc/oratab
</pre></div>


<h3 class="wp-block-heading" id="h-c-cleanup-option-for-in-place-patching"><br><strong>C) cleanup &#8211; option for IN-Place patching</strong></h3>



<p class="wp-block-paragraph">For reasons, you could not do &#8220;out of place&#8221; patching. When you have an OH which was already patched several times, the OH increased in size over time. The old patches got stored in a subdirectory for rollback reasons.</p>



<h6 class="wp-block-heading" id="h-simply-check-the-size-of-the-subdirectory">Simply check the size of the subdirectory</h6>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
du -sh $ORACLE_HOME/.patch_storage/
--&gt;&gt; 6.6G  .patch_storage/
</pre></div>


<h5 class="wp-block-heading" id="h-i-checked-this-for-an-oracle-home-with-up-to-7-rus-installed"><strong>I checked this for an ORACLE_HOME with up to 7 RUs installed:</strong></h5>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
.patch_storage with   2 RUs     3 RUs     4 RUs     5 RUs     6 RUs     7 RUs
          Size GB      5.6       6.6        9.1       12        14        18
</pre></div>


<p class="wp-block-paragraph">you can imagine that each run of opatch needs more and more time for a larger repository in directory &#8216;.patch_storage&#8217;.<br>For the first patch it goes &#8216;on the fly&#8217;. The second needs a coffee break, the third needs a lunch break …</p>



<h6 class="wp-block-heading" id="h-with-this-command-you-can-list-your-obsolete-patches">with this command you can list your obsolete patches</h6>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
opatch util listorderedinactivepatches
</pre></div>


<h6 class="wp-block-heading" id="h-now-delete-them-this-will-take-a-while-and-it-leaves-intentionally-the-last-ru-in-the-repository">now  delete them (this will take a while) and it leaves intentionally the last RU in the repository</h6>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
opatch util deleteinactivepatches
</pre></div>


<h6 class="wp-block-heading" id="h-the-disk-usage-is-now-reduced-and-the-next-patch-will-run-definitively-faster">the disk usage is now reduced, and the next patch will run definitively faster</h6>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
du -sh $ORACLE_HOME/.patch_storage/
--&gt;&gt; 6.0G .patch_storage/
</pre></div>


<p class="wp-block-paragraph">I am an impatient DBA and I don&#8217;t like drinking lots of coffee while waiting for opatch to finish. This is why I love to keep my Oracle-Home directories small and smart.<br></p>



<h3 class="wp-block-heading" id="h-d-add-on-patch-the-opatch">D) add on &#8211; patch the OPatch</h3>



<p class="wp-block-paragraph">regardless of you do in-place or out-of-place patching, you need to update your opatch with the most recent release. The very most DBAs follow the advice in p6880880_opatch_README_12.2.0.1.xy.txt<br>&#8220;Please take a backup of ORACLE_HOME/OPatch into a dedicated backup location&#8221; and rename the folder OPatch to OPatch_<strong>old</strong>.<br>With the next RU, they move the current to OPatch_<strong>even_older</strong> or some other funny name.<br>Just to remember: the purpose of patching is to REPLACE older Software, which contains security issues, by newer releases, containing fixes.<br>Did you know that opatch contains its own <strong>Java</strong>? So why should we leave an outaged Java on the system as a gate for hackers?</p>



<p class="wp-block-paragraph">Remove it immediately after you have verified, the new release is working.</p>



<pre class="wp-block-preformatted"><strong>---&gt;&gt;&gt; rm -rf ORACLE_HOME/OPatch_old</strong></pre>



<p class="wp-block-paragraph">I hope, this helps you to keep your environment clean and tidy.</p>
<p>L’article <a href="https://www.dbi-services.com/blog/cleanup-after-patching/">Cleanup Oracle After Patching</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbi-services.com/blog/cleanup-after-patching/feed/</wfw:commentRss>
			<slash:comments>9</slash:comments>
		
		
			</item>
		<item>
		<title>Integrating MongoDB Documents in Oracle Database: A Modern Approach to Hybrid Data Management</title>
		<link>https://www.dbi-services.com/blog/integrating-mongodb-documents-in-oracle-database-a-modern-approach-to-hybrid-data-management/</link>
					<comments>https://www.dbi-services.com/blog/integrating-mongodb-documents-in-oracle-database-a-modern-approach-to-hybrid-data-management/#respond</comments>
		
		<dc:creator><![CDATA[Oracle Team]]></dc:creator>
		<pubDate>Tue, 16 Jul 2024 14:38:53 +0000</pubDate>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[oracle 23ai]]></category>
		<category><![CDATA[Oralce]]></category>
		<guid isPermaLink="false">https://www.dbi-services.com/blog/?p=33995</guid>

					<description><![CDATA[<p>In today’s data-driven world, organizations often leverage a variety of databases to meet their diverse data storage and processing needs. MongoDB and Oracle Database are two prominent names in the database landscape, each excelling in different areas. MongoDB is renowned for its flexibility and scalability in handling unstructured data, while Oracle Database is a powerhouse for structured data with robust transactional capabilities.</p>
<p>L’article <a href="https://www.dbi-services.com/blog/integrating-mongodb-documents-in-oracle-database-a-modern-approach-to-hybrid-data-management/">Integrating MongoDB Documents in Oracle Database: A Modern Approach to Hybrid Data Management</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">by Alexandre Nestor</p>



<p class="wp-block-paragraph">In today’s data-driven world, organizations often leverage a variety of databases to meet their diverse data storage and processing needs. MongoDB and Oracle Database are two prominent names in the database landscape, each excelling in different areas. MongoDB is renowned for its flexibility and scalability in handling unstructured data, while Oracle Database is a powerhouse for structured data with robust transactional capabilities.</p>



<p class="wp-block-paragraph">Integrating MongoDB documents within an Oracle database allows organizations to harness the strengths of both systems. This hybrid approach enables seamless data management, providing the flexibility of NoSQL with the reliability and performance of a traditional RDBMS. In this blog, we will explore eth technical steps involved in integrating MongoDB documents into an Oracle database.</p>



<h2 class="wp-block-heading" id="h-why-integrate-mongodb-documents-in-oracle-database"><strong>Why Integrate MongoDB Documents in Oracle Database</strong> ?</h2>



<p class="wp-block-paragraph">In short, is for getting the best of two worlds.  </p>



<p class="wp-block-paragraph">1. <strong>Unified Data View</strong>: Combining MongoDB’s unstructured data with Oracle’s structured data creates a unified view, making it easier to perform comprehensive data analysis and reporting.</p>



<p class="wp-block-paragraph">2. <strong>Enhanced Flexibility</strong>: MongoDB’s schema-less architecture allows for rapid development and iteration, while Oracle’s structured schema ensures data integrity and consistency.</p>



<p class="wp-block-paragraph">3. <strong>Scalability and Performance</strong>: MongoDB’s horizontal scalability complements Oracle’s vertical scaling capabilities, providing a balanced approach to handling large volumes of data.</p>



<p class="wp-block-paragraph">4. <strong>Cost Efficiency</strong>: By leveraging both databases, organizations can optimize costs by storing data where it is most efficient based on its nature and usage patterns.</p>



<h2 class="wp-block-heading" id="h-technical-steps-to-connect-the-two-worlds">Technical steps to connect the two worlds. </h2>



<h3 class="wp-block-heading" id="h-the-vm-preparation">The VM preparation </h3>



<p class="wp-block-paragraph">I made some changes to the configuration to make the database changes persistent. </p>



<p class="wp-block-paragraph">For this example I use an Oracle 23 AI docker container.  How to use it is explained here: <a href="https://www.oracle.com/my/database/free/get-started/">https://www.oracle.com/my/database/free/get-started/</a></p>



<p class="wp-block-paragraph">The VM used is an Oracle Linux Server VM deployed on OCI:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
&#x5B;opc@db23ai ~]$ cat /etc/os-release
NAME=&quot;Oracle Linux Server&quot;
VERSION=&quot;9.4&quot;
</pre></div>


<p class="wp-block-paragraph">The docker part installation is described here: <a href="https://docs.docker.com/engine/install/rhel/">https://docs.docker.com/engine/install/rhel/</a></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
&#x5B;root@db23ai ~]# yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

</pre></div>


<p class="wp-block-paragraph">Next,I create the oracle user and groups with the same ID&#8217;s as used in the container: </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
&#x5B;root@db23ai ~]# groupadd -g 54321 oinstall
&#x5B;root@db23ai ~]# groupadd -g 54322 dba
&#x5B;root@db23ai ~]# groupadd -g 54323 oper
&#x5B;root@db23ai ~]# useradd -g oinstall -G dba,oper,docker --uid 54321 -m oracle
</pre></div>


<p class="wp-block-paragraph">Finally I install the sqlplus client and mongo shell:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
&#x5B;root@db23ai u02]# dnf install oracle-instantclient-sqlplus.x86_64
&#x5B;root@db23ai u02]# wget https://downloads.mongodb.com/compass/mongodb-mongosh-2.2.12.x86_64.rpm
&#x5B;root@db23ai u02]# rpm -ivh mongodb-mongosh-2.2.12.x86_64.rpm
warning: mongodb-mongosh-2.2.12.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID d361cb16: NOKEY
Verifying...                          ################################# &#x5B;100%]
Preparing...                          ################################# &#x5B;100%]
Updating / installing...
   1:mongodb-mongosh-2.2.12-1.el8     ################################# &#x5B;100%]
...
</pre></div>


<h3 class="wp-block-heading" id="h-the-oracle-23-ai-container">The Oracle 23 AI container </h3>



<p class="wp-block-paragraph">The <code>port 1700 </code>is for database <code>sqlplus</code> connections and the <code>port 27017</code> is for <code>mongosh</code> connections. I exported some volumes first to make the Oracle database persistent, and to have a place to install ORDS (<a href="https://www.oracle.com/ch-de/database/technologies/appdev/rest.html">https://www.oracle.com/ch-de/database/technologies/appdev/rest.html</a>)</p>



<p class="wp-block-paragraph">Get the container: </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
&#x5B;root@db23ai ~]# sudo su - oracle
&#x5B;oracle@db23ai ~]$ docker pull container-registry.oracle.com/database/free:latest
</pre></div>


<p class="wp-block-paragraph">Run the container:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
&#x5B;oracle@db23ai ~]$ mkdir /u02/data/DB
&#x5B;oracle@db23ai ~]$ mkdir /u02/reco/DB
&#x5B;oracle@db23ai ~]$ mkdir /u02/ords

&#x5B;oracle@db23ai ~]$ docker run  -it --name 23ai -p 1700:1521 -p 27017:27017 \
-v /u02/data/DB:/opt/oracle/oradata \
-v /u02/reco/DB:/opt/oracle/reco \
-v /u02/oracle/ords:/opt/oracle/ords \
-e ENABLE_ARCHIVELOG=true  \
-e ORACLE_PWD=&quot;Hello-World-123&quot; \
container-registry.oracle.com/database/free
...

# Once the traces shows that database is running we can start it as daemon (-d option)

# Test the connection to the PDB 
&#x5B;oracle@db23ai ~]$ sqlplus system/&quot;Hello-World-123&quot;@localhost:1700/freepdb1

SQL*Plus: Release 23.0.0.0.0 - Production on Thu Jul 11 12:09:40 2024
Version 23.4.0.24.05

Copyright (c) 1982, 2024, Oracle.  All rights reserved.

Last Successful login time: Thu Jul 11 2024 11:59:21 +00:00

Connected to:
Oracle Database 23ai Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.4.0.24.05
SQL&gt; show con_id

CON_ID
------------------------------
3

</pre></div>


<p class="wp-block-paragraph">Create the <code>scott</code> schema: </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
SQL&gt; drop user scott cascade;

SQL&gt; create user SCOTT identified by tiger default tablespace users;

SQL&gt; grant connect, create session, create table, create view, create sequence, create procedure, create job, to scott; 

SQL&gt; alter user scott quota unlimited on users;
</pre></div>


<h3 class="wp-block-heading" id="h-install-ords-to-give-access-to-mongo-shell-to-the-database">Install ORDS to give access to mongo shell to the database</h3>



<h3 class="wp-block-heading" id="h-"></h3>



<p class="wp-block-paragraph">Download ORDS from <a href="https://www.oracle.com/database/sqldeveloper/technologies/db-actions/download/">https://www.oracle.com/database/sqldeveloper/technologies/db-actions/download/</a></p>



<p class="wp-block-paragraph">Download it to <code>/u02/oracle/ords/ords_pkg</code> wich is the <code>/u02/oracle/ords</code> directory in the docker container.</p>



<p class="wp-block-paragraph">Connect as <code>oracle</code> user to the container and install ORDS:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
# connect to the container
&#x5B;oracle@db23ai ~]$ docker exec -u 54321 -it 23ai /bin/bash

bash-4.4$ id
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54330(racdba)

bash-4.4$ cd /opt/oracle/ords/ords_pkg
bash-4.4$ ls
ords-24.2.2.187.1943.zip

bash-4.4$ unzip ords-24.2.2.187.1943.zip
...

bash-4.4$ export JAVA_HOME=/opt/oracle/product/23ai/dbhomeFree/jdk
bash-4.4$ export PATH=$PATH:/opt/oracle/product/23ai/dbhomeFree/jdk/bin

bash-4.4$ /opt/oracle/ords/ords_pkg/bin/ords --config /opt/oracle/ords install

ORDS: Release 24.2 Production on Thu Jul 11 12:20:40 2024

Copyright (c) 2010, 2024, Oracle.

Configuration:
  /opt/oracle/ords

The configuration folder /opt/oracle/ords does not contain any configuration files.

Oracle REST Data Services - Interactive Install

  Enter a number to select the TNS net service name to use from /opt/oracle/product/23ai/dbhomeFree/network/admin/tnsnames.ora or specify the database connection
    &#x5B;1] EXTPROC_CONNECTION_DATA SID=PLSExtProc
    &#x5B;2] FREE         SERVICE_NAME=FREE
    &#x5B;3] FREEPDB1     SERVICE_NAME=FREEPDB1
    &#x5B;S] Specify the database connection
  Choose &#x5B;1]: 3 &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; MY ENTRY &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;
  Provide database user name with administrator privileges.
    Enter the administrator username: sys. &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; MY ENTRY &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;
  Enter the database password for SYS AS SYSDBA:  Hello-World-123 &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; MY ENTRY &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;

Retrieving information.
ORDS is not installed in the database. ORDS installation is required.

  Enter a number to update the value or select option A to Accept and Continue
    &#x5B;1] Connection Type: TNS
    &#x5B;2] TNS Connection: TNS_NAME=FREEPDB1 TNS_FOLDER=/opt/oracle/product/23ai/dbhomeFree/network/admin
           Administrator User: SYS AS SYSDBA
    &#x5B;3] Database password for ORDS runtime user (ORDS_PUBLIC_USER): &amp;lt;generate&amp;gt;
    &#x5B;4] ORDS runtime user and schema tablespaces:  Default: SYSAUX Temporary TEMP
    &#x5B;5] Additional Feature: Database Actions
    &#x5B;6] Configure and start ORDS in Standalone Mode: Yes
    &#x5B;7]    Protocol: HTTP
    &#x5B;8]       HTTP Port: 8080
    &#x5B;A] Accept and Continue - Create configuration and Install ORDS in the database
    &#x5B;Q] Quit - Do not proceed. No changes
  Choose &#x5B;A]:   &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; MY ENTRY &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;
  .....
2024-07-11T12:23:05.339Z INFO        Oracle REST Data Services initialized
Oracle REST Data Services version : 24.2.2.r1871943
Oracle REST Data Services server info: jetty/10.0.21
Oracle REST Data Services java info: Java HotSpot(TM) 64-Bit Server VM 11.0.23+7-LTS-222

&amp;lt;&amp;lt;&amp;lt;&amp;lt; ORDS is running in foreground. Press ^C to stop it once installed 
^C


bash-4.4$
</pre></div>


<p class="wp-block-paragraph">Once installed stop the <code>ords</code> server to configure it for <code>mongodb</code>:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
# in the container as oracl user
bash-4.4$ /opt/oracle/ords/ords_pkg/bin/ords --config /opt/oracle/ords config set mongo.enabled true

ORDS: Release 24.2 Production on Thu Jul 11 12:25:09 2024

Copyright (c) 2010, 2024, Oracle.

Configuration:
  /opt/oracle/ords

The global setting named: mongo.enabled was set to: true

# start the ords server 
bash-4.4$ /opt/oracle/ords/ords_pkg/bin/ords --config /opt/oracle/ords serve

ORDS: Release 24.2 Production on Thu Jul 11 12:25:51 2024

Copyright (c) 2010, 2024, Oracle.

Configuration:
  /opt/oracle/ords

2024-07-11T12:25:53.083Z INFO        HTTP and HTTP/2 cleartext listening on host: 0.0.0.0 port: 8080
....
2024-07-11T12:25:53.170Z INFO        The Oracle API for MongoDB connection string is:
         mongodb://&#x5B;{user}:{password}@]localhost:27017/{user}?authMechanism=PLAIN&amp;authSource=$external&amp;ssl=true&amp;retryWrites=false&amp;loadBalanced=true
2024-07-11T12:25:58.362Z INFO        Configuration properties for: |default|lo|
awt.toolkit=sun.awt.X11.XToolkit
db.tnsAliasName=FREEPDB1
...
</pre></div>


<p class="wp-block-paragraph">If the configuration is correct the mongo shell URI is printed: <code>2024-07-11T12:25:53.170Z INFO The Oracle API for MongoDB connection string is:<br>mongodb://[{user}:{password}@]localhost:27017/{user}?</code></p>



<p class="wp-block-paragraph">Connect as <code>scott</code> to the PDB and enable the schema for ORDS usage: </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
oracle@db23ai ~]$ sqlplus scott/tiger@localhost:1700/freepdb1

-- Enable SODA_APP role to work with JSON collections.
SQL&gt; grant soda_app to scott;

SQL&gt; exec ORDS.ENABLE_SCHEMA;

PL/SQL procedure successfully completed.
</pre></div>


<p class="wp-block-paragraph">Now connect to Oracle database using  <code>mongosh</code>:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
&#x5B;oracle@db23ai ~]$ export URI=&#039;mongodb://scott:tiger@localhost:27017/freepdb1?authMechanism=PLAIN&amp;authSource=$external&amp;tls=true&amp;retryWrites=false&amp;loadBalanced=true&#039;

&#x5B;oracle@db23ai ~]$ mongosh  --tlsAllowInvalidCertificates $URI
Current Mongosh Log ID:	668fd0b81156f2c04b482f8a
Connecting to:		mongodb://&lt;credentials&gt;@localhost:27017/freepdb1?authMechanism=PLAIN&amp;authSource=%24external&amp;tls=true&amp;retryWrites=false&amp;loadBalanced=true&amp;serverSelectionTimeoutMS=2000&amp;tlsAllowInvalidCertificates=true&amp;appName=mongosh+2.2.12
Using MongoDB:		4.2.14
Using Mongosh:		2.2.12

For mongosh info see: https://docs.mongodb.com/mongodb-shell/


To help improve our products, anonymous usage data is collected and sent to MongoDB periodically (https://www.mongodb.com/legal/privacy-policy).
You can opt-out by running the disableTelemetry() command.

freepdb1&gt; 
</pre></div>


<p class="wp-block-paragraph">Let&#8217;s create a collection:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
freepdb1&gt; use scott

scott&gt; db.createCollection(&#039;emp_mdb&#039;);

scott&gt; db.emp_mdb.insertOne({&quot;name&quot;:&quot;Miller&quot;,&quot;job&quot;: &quot;Programmer&quot;,&quot;salary&quot;: 70000});
{
  acknowledged: true,
  insertedId: ObjectId(&#039;668fd349ec28de3a61482f8d&#039;)
}

scott&gt; db.emp_mdb.find({&quot;name&quot;:&quot;Miller&quot;});
&#x5B;
  {
    _id: ObjectId(&#039;668fd349ec28de3a61482f8d&#039;),
    name: &#039;Miller&#039;,
    job: &#039;Programmer&#039;,
    salary: 70000
  }
]

# remark the table name in lowercase 
scott&gt; show collections
emp_mdb
</pre></div>


<p class="wp-block-paragraph">Let&#8217;s check the collection table from Oracle <code>sqlplus</code> point of view: </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
# connect to the PDB 
&#x5B;oracle@db23ai ~]$ sqlplus scott/tiger@localhost:1700/freepdb1

SQL&gt; 
-- describe the MongoDB collection stored as a table 
SQL&gt; desc emp_mdb;
 Name					   Null?    Type
 ----------------------------------------- -------- ----------------------------
 DATA						    JSON

-- select the collection 
SQL&gt; select * from emp_mdb;

DATA
--------------------------------------------------------------------------------
{&quot;_id&quot;:&quot;668fd349ec28de3a61482f8d&quot;,&quot;name&quot;:&quot;Miller&quot;,&quot;job&quot;:&quot;Programmer&quot;,&quot;salary&quot;:70


-- check the tables from scott schema (the collection is in lowercase ;) ) 
SQL&gt; select table_name from user_tables;

TABLE_NAME
--------------------------------------------------------------------------------
DEPT
EMP
BONUS
SALGRADE
emp_mdb


-- print JSON fields a human readable 
SQL&gt; select json_serialize(dbms_json_schema.describe(object_name=&gt;&#039;emp_mdb&#039;, owner_name  =&gt; &#039;SCOTT&#039;) pretty) as json_schema;

JSON_SCHEMA
--------------------------------------------------------------------------------
{
  &quot;title&quot; : &quot;emp_mdb&quot;,
  &quot;dbObject&quot; : &quot;SCOTT.emp_mdb&quot;,
  &quot;type&quot; : &quot;object&quot;,
  &quot;dbObjectType&quot; : &quot;table&quot;,
  &quot;properties&quot; :
  {
    &quot;DATA&quot; :
    {
    }
  },
  &quot;dbPrimaryKey&quot; :
  &#x5B;
    &quot;RESID&quot;
  ]
}

--  print them more pretty 
SQL&gt; select json_serialize((e.data) pretty) from emp_mdb e;

JSON_SERIALIZE((E.DATA)PRETTY)
--------------------------------------------------------------------------------
{
  &quot;_id&quot; : &quot;668fd349ec28de3a61482f8d&quot;,
  &quot;name&quot; : &quot;Miller&quot;,
  &quot;job&quot; : &quot;Programmer&quot;,
  &quot;salary&quot; : 70000
}

</pre></div>


<h2 class="wp-block-heading" id="h-conclusion">Conclusion </h2>



<p class="wp-block-paragraph">Integrating MongoDB documents into an Oracle database enables organizations to take advantage of the unique strengths of both databases. This hybrid approach supports flexible, scalable, and robust data management, catering to a wide range of business needs. By following the steps outlined in this blog, you can create a seamless integration that leverages the best of both worlds.</p>



<p class="wp-block-paragraph">Embrace the hybrid model and unlock new potentials in your data architecture.</p>
<p>L’article <a href="https://www.dbi-services.com/blog/integrating-mongodb-documents-in-oracle-database-a-modern-approach-to-hybrid-data-management/">Integrating MongoDB Documents in Oracle Database: A Modern Approach to Hybrid Data Management</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbi-services.com/blog/integrating-mongodb-documents-in-oracle-database-a-modern-approach-to-hybrid-data-management/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Oracle 21c: Attention Log &#8211; Useful or Superflous?</title>
		<link>https://www.dbi-services.com/blog/oracle-21c-attention-log-useful-or-superflous/</link>
					<comments>https://www.dbi-services.com/blog/oracle-21c-attention-log-useful-or-superflous/#respond</comments>
		
		<dc:creator><![CDATA[Oracle Team]]></dc:creator>
		<pubDate>Thu, 11 Jul 2024 16:00:00 +0000</pubDate>
				<category><![CDATA[Database Administration & Monitoring]]></category>
		<category><![CDATA[Database management]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[alert.log]]></category>
		<category><![CDATA[New Features]]></category>
		<category><![CDATA[Oracle 21c]]></category>
		<category><![CDATA[Oracle 21c New features]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<guid isPermaLink="false">https://www.dbi-services.com/blog/?p=33951</guid>

					<description><![CDATA[<p>Attention.log is a feature, which was introduced in Oracle Database 21c, designed to capture high-level summaries of significant database events and activities. It differs from the alert.log in following points: High-Level Summaries: The attention.log focuses on summarizing critical and significant events rather than logging every minor detail, including database startups and shutdowns, major configuration changes, [&#8230;]</p>
<p>L’article <a href="https://www.dbi-services.com/blog/oracle-21c-attention-log-useful-or-superflous/">Oracle 21c: Attention Log &#8211; Useful or Superflous?</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Attention.log is a feature, which was introduced in Oracle Database 21c, designed to capture high-level summaries of significant database events and activities. It differs from the alert.log in following points:</p>



<p class="wp-block-paragraph"><strong>High-Level Summaries</strong>: The attention.log focuses on summarizing critical and significant events rather than logging every minor detail, including database startups and shutdowns, major configuration changes, errors or warnings that need immediate attention.</p>



<p class="wp-block-paragraph"><strong>Consolidation of Critical Events</strong>: It provides a consolidated view of the most important events, making it easier for database administrators to quickly review and identify critical issues without rummaging through through detailed logs.</p>



<p class="wp-block-paragraph"><strong>Accessibility</strong>: Designed to be easily readable and quickly accessible for a high-level overview of the database’s health and significant activities.</p>



<p class="wp-block-paragraph"><strong>Complementary to Alert Log</strong>: While the attention.log highlights major events, it complements the alert.log rather than replacing it. Database administrators can use the attention.log for a quick overview and the alert.log for detailed diagnostics.</p>



<p class="wp-block-paragraph"><strong>Location</strong>: Like the alert.log, the attention.log is also found in the DIAGNOSTIC_DEST directory, usually under $ORACLE_BASE/diag/rdbms/&lt;db_name&gt;/&lt;instance_name&gt;/log.</p>



<p class="wp-block-paragraph">It can be very helpful for not so experienced database administrators or to get a quick overview in difficult or unexpected cases, as I had on a productive environment some time ago: an internal error had occurred, the database crashed and the alert.log was far too large to read without splitting it up which of course makes troubleshooting unnecessarily difficult (under time pressure).</p>



<h2 class="wp-block-heading" id="h-how-to-get-information-about-the-attention-log"><strong>How to get information about the attention.log:</strong></h2>



<p class="wp-block-paragraph">The location of the attention log can be found by querying the&nbsp;<code>V$DIAG_INFO</code>&nbsp;view, it is in the same directory as the alert. log, (since Oracle 11g: $OH/diag/rdbms&#8230; )</p>



<pre class="wp-block-code"><code>select name, value
from   v$diag_info
where  name = 'Attention Log';

NAME                      VALUE
--------------------- -------------------------------------------------------------
Attention Log         /u01/app/oracle/diag/rdbms/cdb1/cdb1/trace/attention_cdb1.log</code></pre>



<p class="wp-block-paragraph">The oracle documentation proposes to query the V$DIAG_ALERT_EXT view to get relevant attention.log information, but it is a view over the XML-based alert.log (in the Automatic Diagnostic Repository for the current container), not the attention log! But nevertheless we can get very useful information out of it, divided into the same categories as in the attention.log:</p>



<pre class="wp-block-code"><code>--message_type 2=INCIDENT_ERROR, message_type 3=ERROR
SELECT message_type, message_level, message_text
FROM V$DIAG_ALERT_EXT 
WHERE message_type in (2, 3);

MESSAGE_TYPE MESSAGE_LEVEL MESSAGE_TEXT
------------ ------------- ---------------------------------------------------------
           3    4294967295 PMON (ospid: 3565): terminating the instance due to ORA error 471 </code></pre>



<p class="wp-block-paragraph">Querying <code>V$DIAG_ALERT_EXT</code> the most important labels are: </p>



<p class="wp-block-paragraph">MESSAGE_LEVEL:</p>



<p class="wp-block-paragraph"><code>1</code>:&nbsp;<code>CRITICAL</code>: critical errors</p>



<p class="wp-block-paragraph"><code>2</code>:&nbsp;<code>SEVERE</code>: severe errors</p>



<p class="wp-block-paragraph"><code>8</code>:&nbsp;<code>IMPORTANT</code>: important message</p>



<p class="wp-block-paragraph"><code>16</code>:&nbsp;<code>NORMAL</code>: normal message</p>



<p class="wp-block-paragraph">MESSAGE_TYPE:</p>



<p class="wp-block-paragraph"><code>1</code>:&nbsp;<code>UNKNOWN</code>: essentially the NULL type</p>



<p class="wp-block-paragraph"><code>2</code>:&nbsp;<code>INCIDENT_ERROR</code>: the program has encountered an error for some internal or unexpected reason, and it must be reported to Oracle Support</p>



<p class="wp-block-paragraph"><code>3</code>: <code>ERROR</code>: an error of some kind has occurred</p>



<p class="wp-block-paragraph"><code>4</code>: <code>WARNING</code>: an action occurred or a condition was discovered that should be reviewed and may require action</p>



<p class="wp-block-paragraph"><code>5</code>: <code>NOTIFICATION</code>: reports a normal action or event, this could be a user action such as &#8220;logon completed&#8221;</p>



<p class="wp-block-paragraph"><code>6</code>: <code>TRACE</code>: output of a diagnostic trace</p>



<p class="wp-block-paragraph">Opening the attention.log with vi</p>



<pre class="wp-block-code"><code>vi /u01/app/oracle/diag/rdbms/cdb1/cdb1/trace/attention_cdb1.log</code></pre>



<p class="wp-block-paragraph">will give you an output like this (JSON formatted), which is obviously pretty comfortable to read:</p>



<pre class="wp-block-code"><code>{
IMMEDIATE : "PMON (ospid: 3565): terminating the instance due to ORA error 471" 
CAUSE: "PMON detected fatal background process death"
ACTION: "Termination of fatal background is not recommended, Investigate cause of process termination"
CLASS : CDB-INSTANCE / CDB_ADMIN / ERROR / DBAL-35782660
TIME : 2024-07-10T14:15:16.159-07:00
INFO : "Some additional data on error PMON error"
}
</code></pre>



<p class="wp-block-paragraph">It is possible to convert the output into plain text format:</p>



<pre class="wp-block-code"><code>jq -r '.tags&#091;].name' input.json &gt; output.txt</code></pre>



<p class="wp-block-paragraph">which gives us a formatted expression that might look like this:</p>



<pre class="wp-block-code"><code>2024-07-01T10:15:32.123456+00:00
&#091;SEVERE] ORA-00600: internal error code, arguments: &#091;1234], &#091;], &#091;], &#091;], &#091;], &#091;], &#091;], &#091;], &#091;], &#091;], &#091;]
Action: Please contact Oracle Support Services.

2024-07-01T11:20:45.789012+00:00
&#091;CRITICAL] ORA-01578: ORACLE data block corrupted (file # 23, block # 220734)
Action: This error signifies a corrupted data block. The data block has been marked as corrupt. Consider restoring from backup.

2024-07-02T08:42:27.654321+00:00
&#091;ALERT] Database instance crashed due to unexpected termination.
Action: Investigate the cause of the instance termination. Review related logs and diagnostic information.

2024-07-03T12:34:56.987654+00:00
&#091;INFO] System global area (SGA) resized. New size: 68GB.
Action: No immediate action required. Monitor performance and stability.</code></pre>



<h2 class="wp-block-heading" id="h-key-points"><strong>Key Points</strong></h2>



<p class="wp-block-paragraph"><strong>Severity Levels</strong>: Entries are tagged with severity levels such as [SEVERE], [CRITICAL], [IMPORTANT] or [NORMAL] to highlight their importance.</p>



<p class="wp-block-paragraph"><strong>Timestamp</strong>: Each entry begins with a timestamp in ISO 8601 format.</p>



<p class="wp-block-paragraph"><strong>Messages and Actions</strong>: Each entry provides a brief description of the event and recommended actions.</p>



<h2 class="wp-block-heading" id="h-benefits-for-dbas"><strong>Benefits for DBAs</strong></h2>



<p class="wp-block-paragraph"><strong>Quick Identification</strong>: The attention.log helps DBAs quickly identify and respond to critical issues without sifting through the more detailed alert.log.</p>



<p class="wp-block-paragraph"><strong>Conciseness</strong>: It captures only the most significant events, reducing noise and making it easier to focus on urgent matters.</p>



<p class="wp-block-paragraph"><strong>Complementary to </strong><strong>alert.log</strong>: It complements the alert.log by summarizing critical events, while the alert.log continues to provide detailed information for troubleshooting.</p>



<p class="wp-block-paragraph">Overall, the attention.log is a useful addition for DBAs, enabling more efficient monitoring and quicker responses to significant database events.</p>



<h2 class="wp-block-heading" id="h-sources-links-amp-blogs"><strong>Sources, Links &amp; Blogs:</strong></h2>



<p class="wp-block-paragraph"><a href="https://oracle-base.com/articles/21c/attention-log-oracle-database-21c">https://oracle-base.com/articles/21c/attention-log-oracle-database-21c</a></p>



<p class="wp-block-paragraph"><a href="https://blogs.oracle.com/cloud-infrastructure/post/alert-log-support-for-oci-database-management">https://blogs.oracle.com/cloud-infrastructure/post/alert-log-support-for-oci-database-management</a></p>



<p class="wp-block-paragraph"><a href="https://docs.oracle.com/en/database/oracle/oracle-database/21/nfcon/management-solutions.html#GUID-F2EB58EC-4B22-473F-A2D3-40161372610E">https://docs.oracle.com/en/database/oracle/oracle-database/21/nfcon/management-solutions.html#GUID-F2EB58EC-4B22-473F-A2D3-40161372610E</a></p>
<p>L’article <a href="https://www.dbi-services.com/blog/oracle-21c-attention-log-useful-or-superflous/">Oracle 21c: Attention Log &#8211; Useful or Superflous?</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbi-services.com/blog/oracle-21c-attention-log-useful-or-superflous/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Exploring Vector Search in Oracle 23c AI</title>
		<link>https://www.dbi-services.com/blog/exploring-vector-search-in-oracle-23c-ai/</link>
					<comments>https://www.dbi-services.com/blog/exploring-vector-search-in-oracle-23c-ai/#respond</comments>
		
		<dc:creator><![CDATA[Oracle Team]]></dc:creator>
		<pubDate>Tue, 09 Jul 2024 14:39:36 +0000</pubDate>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[ai]]></category>
		<category><![CDATA[Artificial inteligence]]></category>
		<category><![CDATA[Cloud]]></category>
		<guid isPermaLink="false">https://www.dbi-services.com/blog/?p=33843</guid>

					<description><![CDATA[<p>Exploring Vector Search in Oracle 23c AI</p>
<p>L’article <a href="https://www.dbi-services.com/blog/exploring-vector-search-in-oracle-23c-ai/">Exploring Vector Search in Oracle 23c AI</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">by Alexandre Nestor</p>



<p class="wp-block-paragraph">In our data-centric world, efficiently searching and retrieving information is crucial. Traditional search methods frequently fail with the surge of unstructured data. Oracle 23c AI addresses this challenge with a groundbreaking feature: vector search. This innovative tool transforms data handling and retrieval, particularly with complex, high-dimensional datasets. In this blog post, we&#8217;ll explore the concept of vector search, its implementation in Oracle 23c AI, and its transformative impact across various industries.</p>



<h2 class="wp-block-heading" id="h-understanding-vector-search-short">Understanding Vector Search (short)</h2>



<p class="wp-block-paragraph">Vector search, also known as similarity search or nearest neighbor search, involves searching for data points in a vector space. Unlike traditional search methods that rely on exact keyword matches, vector search leverages mathematical representations of data (vectors) to find similarities. Each data point is encoded into a vector, capturing its essential features. The search process then identifies vectors that are closest to the query vector based on a chosen distance metric, such as Euclidean distance or cosine similarity.</p>



<p class="wp-block-paragraph">Oracle 23c AI integrates vector search capabilities, providing users with an advanced tool for data retrieval. Here’s a closer look at how it works and its features:</p>



<p class="wp-block-paragraph"><strong style="font-size: revert;color: initial;, sans-serif">Seamless Integration:</strong><span style="font-size: revert;color: initial;, sans-serif"> Oracle 23c AI&#8217;s vector search is integrated into the database, allowing users to perform vector searches without the need for external tools or complex workflows.</span></p>



<p class="wp-block-paragraph"><strong style="font-size: revert;color: initial;, sans-serif">High Performance:</strong><span style="font-size: revert;color: initial;, sans-serif"> Leveraging Oracle&#8217;s robust infrastructure, vector search in 23c AI offers high-speed search capabilities even with large datasets. Advanced indexing and optimized algorithms ensure quick and accurate retrieval.</span></p>



<p class="wp-block-paragraph"><strong style="font-size: revert;color: initial;, sans-serif">Multi-Modal Data Support:</strong><span style="font-size: revert;color: initial;, sans-serif"> Oracle 23c AI supports various data types, including text, images, audio, and more. This versatility makes it a powerful tool for applications across different domains.</span></p>



<p class="wp-block-paragraph"><strong style="font-size: revert;color: initial;, sans-serif">Customizable Distance Metrics:</strong><span style="font-size: revert;color: initial;, sans-serif"> Users can choose from a variety of distance metrics based on their specific needs, enhancing the flexibility and accuracy of the search results.</span></p>



<h2 class="wp-block-heading" id="h-what-is-the-flow">What is the flow</h2>



<p class="wp-block-paragraph"><strong>Data Ingestion:</strong> Data is ingested into the Oracle 23c AI database, where it is preprocessed and converted into vectors. This step involves using machine learning models to encode the data&#8217;s features into numerical vectors.</p>



<p class="wp-block-paragraph"><strong>Indexing:</strong> The vectors are indexed to facilitate efficient searching. Oracle 23c AI uses advanced indexing techniques, such as hierarchical navigable small world (HNSW) graphs, to enable fast and scalable searches.</p>



<p class="wp-block-paragraph"><strong>Querying:</strong> When a query is made, it is also converted into a vector. The vector search algorithm then identifies the closest vectors in the database using the chosen distance metric.</p>



<p class="wp-block-paragraph"><strong>Results:</strong> The search results are returned, showcasing the most similar data points to the query. These results can be further refined or analyzed based on the application’s requirements.</p>



<p class="wp-block-paragraph">The classical example is the image search, and classification following some criteria. </p>



<p class="wp-block-paragraph">To achieve this goal Oracle can make benefit of ONNX (Open Neural Network Exchange) existent models. ONNX models offer a standardised format for representing deep learning models.</p>



<p class="wp-block-paragraph">Predefined ONNX models exist for free: <a href="https://github.com/onnx/models">https://github.com/onnx/models</a></p>



<h2 class="wp-block-heading" id="h-building-the-test-environment">Building the test environment </h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">I use an OCI VM Oracle Linux Server 9.4</p>



<p class="wp-block-paragraph">I will use Python function to generate the ONNX model. </p>



<p class="wp-block-paragraph">First step is to create a virtual environnement using python:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
(venv) &#x5B;oracle@db23-134956 ~]$ pip freeze
certifi==2024.6.2
cffi==1.16.0
charset-normalizer==3.3.2
coloredlogs==15.0.1
contourpy==1.2.1
cryptography==42.0.8
cycler==0.12.1
filelock==3.15.4
flatbuffers==24.3.25
fonttools==4.53.0
fsspec==2024.6.1
huggingface-hub==0.23.4
humanfriendly==10.0
idna==3.7
importlib_resources==6.4.0
Jinja2==3.1.4
joblib==1.4.2
kiwisolver==1.4.5
MarkupSafe==2.1.5
matplotlib==3.9.0
mpmath==1.3.0
networkx==3.3
numpy==1.26.4
nvidia-cublas-cu12==12.1.3.1
nvidia-cuda-cupti-cu12==12.1.105
nvidia-cuda-nvrtc-cu12==12.1.105
nvidia-cuda-runtime-cu12==12.1.105
nvidia-cudnn-cu12==8.9.2.26
nvidia-cufft-cu12==11.0.2.54
nvidia-curand-cu12==10.3.2.106
nvidia-cusolver-cu12==11.4.5.107
nvidia-cusparse-cu12==12.1.0.106
nvidia-nccl-cu12==2.20.5
nvidia-nvjitlink-cu12==12.5.82
nvidia-nvtx-cu12==12.1.105
oml @ file:///home/oracle/installer/client/oml-2.0-cp312-cp312-linux_x86_64.whl#sha256=0c1f7c83256f60c87f1f66b2894098bc8fefd8a60a03e67ba873661dd178b3c2
onnx==1.16.1
onnxruntime==1.18.1
onnxruntime_extensions==0.11.0
oracledb==2.2.1
packaging==24.1
pandas==2.2.2
pillow==10.4.0
protobuf==5.27.2
pycparser==2.22
pyparsing==3.1.2
python-dateutil==2.9.0.post0
pytz==2024.1
PyYAML==6.0.1
regex==2024.5.15
requests==2.32.3
safetensors==0.4.3
scikit-learn==1.5.0
scipy==1.13.1
sentencepiece==0.2.0
setuptools==70.2.0
six==1.16.0
sympy==1.12.1
threadpoolctl==3.5.0
tokenizers==0.19.1
torch==2.3.1
tqdm==4.66.4
transformers==4.42.3
typing_extensions==4.12.2
tzdata==2024.1
urllib3==2.2.2
zipp==3.19.2
</pre></div>


<p class="wp-block-paragraph">I also use Oracle Database 23ai Free as docker image. </p>



<p class="wp-block-paragraph">To start the docker image I use this command, and I put datafiles and archivelogs on external mount point: </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
(venv) &#x5B;oracle@db23-134956 ~]$ docker run  -it --name 23ai -p 1700:1521 \
-v /u02/data/DB:/opt/oracle/oradata \
-v /u02/reco/DB:/opt/oracle/reco \
-e ENABLE_ARCHIVELOG=true  \
container-registry.oracle.com/database/free
</pre></div>


<p class="wp-block-paragraph">Let&#8217;s get the ONX image  and built it for our usage: </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
(venv) &#x5B;oracle@db23-134956 ~]$ python
Python 3.12.1 (main, Feb 19 2024, 00:00:00) &#x5B;GCC 11.4.1 20231218 (Red Hat 11.4.1-3.0.1)] on linux
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; from oml.utils import EmbeddingModel, EmbeddingModelConfig
&gt;&gt;&gt; em = EmbeddingModel(model_name=&quot;sentence-transformers/all-MiniLM-L6-v2&quot;)
&gt;&gt;&gt; em.export2file(&quot;all-MiniLM-L6-v2&quot;, output_dir=&quot;.&quot;)
tokenizer_config.json: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 350/350 &#x5B;00:00&lt;00:00, 4.01MB/s]
vocab.txt: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 232k/232k &#x5B;00:00&lt;00:00, 1.15MB/s]
special_tokens_map.json: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 112/112 &#x5B;00:00&lt;00:00, 1.52MB/s]
tokenizer.json: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 466k/466k &#x5B;00:00&lt;00:00, 1.55MB/s]
config.json: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 612/612 &#x5B;00:00&lt;00:00, 8.23MB/s]
model.safetensors: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 90.9M/90.9M &#x5B;00:00&lt;00:00, 304MB/s]
&gt;&gt;&gt; exit()
l(venv) &#x5B;oracle@db23-134956 ~]$ ls
all-MiniLM-L6-v2.onnx  venv
</pre></div>


<p class="wp-block-paragraph">The ONNX generated file is <code>all-MiniLM-L6-v2.onnx</code></p>



<p class="wp-block-paragraph">Finally I copy the ONNX generated file to a shared directory to be able to import it to the database: </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
(venv) &#x5B;oracle@db23-134956 ~]$ cp all-MiniLM-L6-v2.onnx /u02/data/DB/FREE/FREEPDB1/dump/1AC27018093909F8E063020011AC7FF6/
</pre></div>


<p class="wp-block-paragraph">Let&#8217;s connect to the database and load the ONNX model into database:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
(venv) &#x5B;oracle@db23-134956 ~]$ sqlplus system/oracle@localhost:1700/freepdb1

SQL*Plus: Release 23.0.0.0.0 - Production on Wed Jul 3 09:12:02 2024
Version 23.4.0.24.05

SQL&gt; create or replace directory DATA_PUMP_DIR as &#039;/opt/oracle/oradata/FREE/FREEPDB1/dump&#039;;

Directory created.

SQL&gt; begin
  2  dbms_vector.load_onnx_model(
  3  directory =&gt; &#039;DATA_PUMP_DIR&#039;
  4  , file_name =&gt; &#039;all-MiniLM-L6-v2.onnx&#039;
  5  , model_name =&gt; &#039;all_minilm_l6_v2&#039;
  6  , metadata =&gt; json(&#039;{&quot;function&quot; : &quot;embedding&quot;, &quot;embeddingOutput&quot; : &quot;embedding&quot; , &quot;input&quot;: {&quot;input&quot;: &#x5B;&quot;DATA&quot;]}}&#039;)
  7  );
  8  end;
  9  /

PL/SQL procedure successfully completed.

-- test the loaded model 
SQL&gt; select
  model_name
  , mining_function
  , algorithm
  , (model_size/1024/1024) as model_size_mb
from user_mining_models
order by model_name;  2    3    4    5    6    7

MODEL_NAME
--------------------------------------------------------------------------------
MINING_FUNCTION 	       ALGORITHM		      MODEL_SIZE_MB
------------------------------ ------------------------------ -------------
ALL_MINILM_L6_V2
EMBEDDING		       ONNX				 86.4376068

</pre></div>


<p class="wp-block-paragraph">The test table contains a word, the description end the generated vector:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
-- create the table  
SQL&gt; create table my_dictionary(
 id number generated always as identity
  , word varchar2(100) not null
  , description varchar2(500) not null
  , word_vector vector not null
   );

Table created.

-- create the trigger to generate the vector 
SQL&gt; create or replace trigger my_dict_vect_build
before insert or update on my_dictionary
for each row
declare
begin
  :new.word_vector := dbms_vector_chain.utl_to_embedding(
    data =&gt; :new.word
    , params =&gt; json(q&#039;&#x5B;{&quot;provider&quot;: &quot;database&quot;,  2   &quot;model&quot;: &quot;&amp;model_name.&quot;}]&#039;)
  );
end;
/  3    4    5    6    7    8    9   10   11
Enter value for model_name: all_minilm_l6_v2
old   8:     , params =&gt; json(q&#039;&#x5B;{&quot;provider&quot;: &quot;database&quot;,  2   &quot;model&quot;: &quot;&amp;model_name.&quot;}]&#039;)
new   8:     , params =&gt; json(q&#039;&#x5B;{&quot;provider&quot;: &quot;database&quot;,  2   &quot;model&quot;: &quot;all_minilm_l6_v2&quot;}]&#039;)

Trigger created.

-- create and index on the table
SQL&gt; create vector index my_dict_ivf_idx
  on my_dictionary(word_vector)
  organization neighbor partitions
  distance cosine
  with target accuracy 95;

Index created.
</pre></div>


<p class="wp-block-paragraph">I download a dictionary from  the web in CSV mode as word | description from <a href="https://www.bragitoff.com/2016/03/english-dictionary-in-csv-format">https://www.bragitoff.com/2016/03/english-dictionary-in-csv-format</a> and I formatted it to be somehow like this : </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
Score;q&#039;&#x5B;To engrave, as upon a shield.]&#039;
Score;q&#039;&#x5B;To make a score of, as points, runs, etc., in a game.]&#039;
Score;q&#039;&#x5B;To write down in proper order and arrangement  as, to score an overture for an orchestra. See Score, n., 9.]&#039;
Score;q&#039;&#x5B;To mark with parallel lines or scratches  as, the rocks of New England and the Western States were scored in the drift epoch.]&#039;
Scorer;q&#039;&#x5B;One who, or that which, scores.]&#039;
</pre></div>


<p class="wp-block-paragraph">The I loaded the dictionary into a table <code>dict</code> using <code>sqlldr</code>:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
SQL&gt; 

SQL&gt; desc dict;
Name Null? Type

WORD VARCHAR2(100)
DESCRIPTION NOT NULL VARCHAR2(500)

Using these parameters files: 

&#x5B;oracle@0c97e3a7be16 ]$ cat ld.par
control=ld.ctl
log=ld.log
bad=ld.bad
data=ld.csv
direct=true
errors=1000000

&#x5B;oracle@0c97e3a7be16 ]$ cat ld.ctl 
load data into table dict
insert
fields terminated by &quot;;&quot;
(word,description
)
</pre></div>

<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
&#x5B;oracle@0c97e3a7be16 1AC27018093909F8E063020011AC7FF6]$  sqlldr &#039;system/&quot;Hello-World-123&quot;@freepdb1&#039; parfile=ld.par

SQL*Loader: Release 23.0.0.0.0 - Production on Tue Jul 9 09:47:59 2024
Version 23.4.0.24.05

Copyright (c) 1982, 2024, Oracle and/or its affiliates.  All rights reserved.

Path used:      Direct

Load completed - logical record count 54555.

Table DICT:
  19080 Rows successfully loaded.

Check the log file:
  ld.log
for more information about the load.

SQL&gt; select count(*) from dict;

  COUNT(*)
----------
     19080

</pre></div>


<p class="wp-block-paragraph">Finally insert into the final table my_dictionars. The trigger will build the vector information </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
SQL&gt; insert into my_dictionary(word,DESCRIPTION)  select WORD,DESCRIPTION from dict;

19080 rows created.

SQL&gt; commit;

Commit complete.

</pre></div>


<h2 class="wp-block-heading" id="h-let-s-test-the-miraculous-ai">Let&#8217;s test the miraculous AI.</h2>



<p class="wp-block-paragraph">The ONNX model used was designed to search words. Obviously more the model is complicates mode the research is precise, and more is expensive. </p>



<p class="wp-block-paragraph">The question is <em>what are the first x words from my build dictionary which are most closely to a given word</em>. As My dictionary contains words similar I used distinct to filter the final result. </p>



<p class="wp-block-paragraph">Let&#8217;s search the result for the word &#8220;Sun&#8221;: </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
SQL&gt; define search_term=&quot;Sun&quot;;

select distinct word from (
with subject as (
  select to_vector(
  vector_embedding(&amp;model_name. using &#039;&amp;search_term.&#039; as data)
  ) as search_vector
  )
  select o.word from my_dictionary o, subject s order by cosine_distance(
    o.word_vector, s.search_vector)
  fetch approx first 50 rows only with target accuracy 80);  2    3    4    5    6    7    8    9
old   4:   vector_embedding(&amp;model_name. using &#039;&amp;search_term.&#039; as data)
new   4:   vector_embedding(all_minilm_l6_v2 using &#039;Sun&#039; as data)

WORD
--------------------------------------------------------------------------------
Radiant
Radiate
Light
Radiancy
Earth shine
Heat

6 rows selected.

</pre></div>


<p class="wp-block-paragraph">Test for the word &#8220;Seed&#8221;: </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
SQL&gt; define search_term=&quot;Seed&quot;;
SQL&gt; /
old   4:   vector_embedding(&amp;model_name. using &#039;&amp;search_term.&#039; as data)
new   4:   vector_embedding(all_minilm_l6_v2 using &#039;Seed&#039; as data)

WORD
--------------------------------------------------------------------------------
Germinate
Germination
Feeder
Grow
Germinal
Heartseed
Grass
Fertile
Fertilization
Grass-grown
Harvest
Fruit
Grower
Packfong
Pack
Agnation
Gusset

17 rows selected.
</pre></div>


<p class="wp-block-paragraph">The result&#8217;s is pretty cool </p>



<h2 class="wp-block-heading" id="h-conclusion">Conclusion </h2>



<p class="wp-block-paragraph">The AI is here, everyone is using it. We are going to use it more and more. Artificial Intelligence (AI) has rapidly evolved from a theoretical concept into a transformative force across numerous industries, redefining how we interact with technology and fundamentally altering societal structures.</p>



<p class="wp-block-paragraph">This example is limited, the ONNX model is simple, but shows how easy we can implemented a solution which can project into the AI world. </p>
<p>L’article <a href="https://www.dbi-services.com/blog/exploring-vector-search-in-oracle-23c-ai/">Exploring Vector Search in Oracle 23c AI</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbi-services.com/blog/exploring-vector-search-in-oracle-23c-ai/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Cleanup Audit Trail &#8211; the Full Picture</title>
		<link>https://www.dbi-services.com/blog/cleanup-audit-trail-the-full-picture/</link>
					<comments>https://www.dbi-services.com/blog/cleanup-audit-trail-the-full-picture/#respond</comments>
		
		<dc:creator><![CDATA[Oracle Team]]></dc:creator>
		<pubDate>Tue, 02 Jul 2024 17:30:00 +0000</pubDate>
				<category><![CDATA[Database Administration & Monitoring]]></category>
		<category><![CDATA[Database management]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[AUD$]]></category>
		<category><![CDATA[audit]]></category>
		<category><![CDATA[Unified Auditing]]></category>
		<guid isPermaLink="false">https://www.dbi-services.com/blog/?p=33833</guid>

					<description><![CDATA[<p>Oracle Database 23ai introduces several enhancements to unified auditing, focused on flexibility, and effectiveness. Some of the new key features are: Desupport of Traditional Auditing: Traditional auditing is desupported in Oracle 23ai, which means all auditing must now be done using unified auditing. Unified auditing consolidates audit records into a single, secure trail and supports [&#8230;]</p>
<p>L’article <a href="https://www.dbi-services.com/blog/cleanup-audit-trail-the-full-picture/">Cleanup Audit Trail &#8211; the Full Picture</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Oracle Database 23ai introduces several enhancements to unified auditing, focused on flexibility, and effectiveness. Some of the new key features are:</p>



<p class="wp-block-paragraph"><strong>Desupport of Traditional Auditing</strong>: Traditional auditing is desupported in Oracle 23ai, which means all auditing must now be done using unified auditing. Unified auditing consolidates audit records into a single, secure trail and supports conditional policies for selective auditing.</p>



<p class="wp-block-paragraph"><strong>Column-Level Audit Policies</strong>: One of the most notable features is the ability to create audit policies on individual columns of tables and views. This granularity control allows organizations to focus their audit efforts on the most sensitive data elements, reducing the volume of audit data and enhancing security by targeting specific actions like SELECT, INSERT, UPDATE, or DELETE on specified columns​. It can be implemented like:</p>



<pre class="wp-block-code"><code>conn / as sysdba
noaudit policy test_audit_policy;
drop audit policy test_audit_policy;
create audit policy test_audit_policy
	actions update(col1, col2) on userx.audit_test_tab,
	select(col2) on userx.audit_test_tab
	container = current;
audit policy test_audit_policy;
</code></pre>



<p class="wp-block-paragraph"><strong>Enhanced Integration with IAM and Cloud Services</strong>: Oracle 23ai includes improved authentication and authorization capabilities for IAM users, supporting Azure AD OAuth2 tokens and allowing seamless integration with Oracle Autonomous Database on Dedicated Exadata Infrastructure.</p>



<p class="wp-block-paragraph"><strong>New Cryptographic Algorithms and Security Enhancements</strong>: The release includes support for new cryptographic algorithms such as SM2, SM3, SM4, and SHA-3, along with enhancements to the <code>DBMS_CRYPTO</code> package and <code>orapki</code> utility.</p>



<p class="wp-block-paragraph"><strong>Consolidation of FIPS 140 Parameter</strong>: Oracle 23c introduces a unified <code>FIPS_140</code> parameter for configuring FIPS across various database environments, including Transparent Data Encryption (TDE) and network encryption, streamlining the compliance process and improving security management​.</p>



<h2 class="wp-block-heading" id="h-cleanup-of-audit-trail"><strong>Cleanup of audit trail</strong></h2>



<p class="wp-block-paragraph">Also for the reason that unified audit is now standard, I would like to summarize the management and cleanup of the audit trail in detail here:</p>



<p class="wp-block-paragraph">First of all you should check the size of the existing audit tables (AUD$ and FGA_LOG$), create a new audit-tablespace for the audit tables:</p>



<pre class="wp-block-code"><code>set lin 999
set pages 999
col tablespace_name for a30
col segment_name for a30
col owner for a20
select owner, segment_name, tablespace_name, bytes/1024/1024 MB 
from dba_segments 
where segment_name in ('AUD$', 'FGA_LOG$');
-- create audit tablespace
create tablespace audit_ts;
select file_name, file_id, tablespace_name, autoextensible, maxbytes/1024/1024/1024 GB 
from dba_data_files 
where tablespace_name like 'AUD$';
-- alter database datafile … autoextend on next 100M maxsize 1G;
-- eventually create an audit history table for further use
create table AUD_HIST tablespace audit_ts as select * from AUD$;
-- truncate table sys.aud$;
</code></pre>



<p class="wp-block-paragraph">Now you can move the audit tables from sysaux to the audit-tablespace:</p>



<pre class="wp-block-code"><code>--move AUD$
BEGIN
DBMS_AUDIT_MGMT.SET_AUDIT_TRAIL_LOCATION(
audit_trail_type =&gt; DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,
audit_trail_location_value =&gt; 'AUDIT_TS');
END;
/
--move FGA_LOG$
BEGIN
DBMS_AUDIT_MGMT.SET_AUDIT_TRAIL_LOCATION(
audit_trail_type =&gt; DBMS_AUDIT_MGMT.AUDIT_TRAIL_FGA_STD,
audit_trail_location_value =&gt; 'AUDIT_TS');
END;
/
--moving additional audit tables
alter table FGACOL$ move tablespace AUDIT_TS;
</code></pre>



<p class="wp-block-paragraph">Short check of audit-parameters:</p>



<pre class="wp-block-code"><code>-- check audit parameters
col parameter_name for a30
col parameter_value for a20
col audit_trail for a20
show parameter audit
SELECT * FROM dba_audit_mgmt_config_params;
</code></pre>



<p class="wp-block-paragraph">Before starting any cleanup you should be sure that no old jobs exist:</p>



<pre class="wp-block-code"><code>-- deinit all purge jobs
exec dbms_audit_mgmt.deinit_cleanup( dbms_audit_mgmt.audit_trail_all );
exec dbms_audit_mgmt.deinit_cleanup( dbms_audit_mgmt.audit_trail_os );
exec dbms_audit_mgmt.deinit_cleanup( dbms_audit_mgmt.audit_trail_xml );
exec dbms_audit_mgmt.deinit_cleanup( dbms_audit_mgmt.audit_trail_aud_std );
exec dbms_audit_mgmt.deinit_cleanup( dbms_audit_mgmt.audit_trail_fga_std )
</code></pre>



<p class="wp-block-paragraph">Now you can set up an audit-management, e.g. every 24 hours, which purges audit-entries older than 7 months:</p>



<pre class="wp-block-code"><code>-- init cleanup for 24 hours
exec DBMS_AUDIT_MGMT.INIT_CLEANUP( DBMS_AUDIT_MGMT.AUDIT_TRAIL_all, 24 );
-- set retention (last_archive_timestamp, sysdate -210 days) =7 months
exec dbms_audit_mgmt.set_last_archive_timestamp( dbms_audit_mgmt.AUDIT_TRAIL_AUD_STD, to_timestamp(sysdate-210));
exec dbms_audit_mgmt.set_last_archive_timestamp( dbms_audit_mgmt.AUDIT_TRAIL_FGA_STD, to_timestamp(sysdate-210));
exec DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP( dbms_audit_mgmt.audit_trail_unified, sysdate-210);
-- 1 means RAC-node 1
exec dbms_audit_mgmt.set_last_archive_timestamp( dbms_audit_mgmt.AUDIT_TRAIL_OS, to_timestamp(sysdate-210), 1);
exec dbms_audit_mgmt.set_last_archive_timestamp( dbms_audit_mgmt.AUDIT_TRAIL_XML, to_timestamp(sysdate-210), 1);
</code></pre>



<p class="wp-block-paragraph">Short check of parameter settings:</p>



<pre class="wp-block-code"><code>-- getting parameters
COLUMN parameter_name FORMAT A30
COLUMN parameter_value FORMAT A20
COLUMN audit_trail FORMAT A20
col days_back  for 9999  head "days|back"
select audit_trail, rac_instance, last_archive_ts, extract(day from(systimestamp-last_archive_ts))days_back from DBA_AUDIT_MGMT_LAST_ARCH_TS;
</code></pre>



<p class="wp-block-paragraph">Now you can set up and initiate the purge-jobs:</p>



<pre class="wp-block-code"><code>-- creating purge job for all audit trails
BEGIN 
dbms_audit_mgmt.create_purge_job(
audit_trail_type =&gt; dbms_audit_mgmt.audit_trail_all,
audit_trail_purge_interval =&gt; 24  /* hours */,
audit_trail_purge_name =&gt; 'DAILY_AUDIT_PURGE',
use_last_arch_timestamp =&gt; TRUE);
END;
/
-- create job for automatic updating last_archive_timestamp
create or replace procedure AUDIT_UPDATE_RETENTION( m_purge_retention  IN  number  DEFAULT 210
) AS
BEGIN
DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP( DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD, TO_TIMESTAMP(SYSDATE-m_purge_retention));
DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP( DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD, TO_TIMESTAMP(SYSDATE-m_purge_retention));
DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP( DBMS_AUDIT_MGMT.AUDIT_TRAIL_FGA_STD, TO_TIMESTAMP(SYSDATE-m_purge_retention));
DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP( DBMS_AUDIT_MGMT.AUDIT_TRAIL_UNIFIED, TO_TIMESTAMP(SYSDATE-m_purge_retention));
DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP( DBMS_AUDIT_MGMT.AUDIT_TRAIL_OS, TO_TIMESTAMP(SYSDATE-m_purge_retention), 1);
DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP( DBMS_AUDIT_MGMT.AUDIT_TRAIL_XML, TO_TIMESTAMP(SYSDATE-m_purge_retention), 1);
END;
/
</code></pre>



<p class="wp-block-paragraph">You can test it now:</p>



<pre class="wp-block-code"><code>-- test run
exec audit_update_retention(210);
</code></pre>



<p class="wp-block-paragraph">Before we invoke the new job, we get sure that no old bodies are left:</p>



<pre class="wp-block-code"><code>-- drop job if exists
set serveroutput on
begin
dbms_scheduler.drop_job(job_name =&gt; 'DAILY_AUDIT_UPDATE_RETENTION');
end;
/
-- create job for last_archive_timestamp
set serveroutput on
declare
m_purge_retention number DEFAULT 210;
ex_job_doesnt_exist EXCEPTION;
PRAGMA EXCEPTION_INIT(ex_job_doesnt_exist, -27475);
begin
--dbms_scheduler.drop_job(job_name =&gt; 'DAILY_AUDIT_UPDATE_RETENTION');
--dbms_output.put_line(chr(13)||'= 60;
DBMS_SCHEDULER.create_job (
job_name =&gt; 'DAILY_AUDIT_UPDATE_RETENTION',
job_type =&gt; 'PLSQL_BLOCK',
job_action =&gt; 'BEGIN
DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP( DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD, TO_TIMESTAMP(SYSDATE-m_purge_retention));
DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP( DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD, TO_TIMESTAMP(SYSDATE-m_purge_retention));
DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP( DBMS_AUDIT_MGMT.AUDIT_TRAIL_FGA_STD, TO_TIMESTAMP(SYSDATE-m_purge_retention));
DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP( DBMS_AUDIT_MGMT.AUDIT_TRAIL_UNIFIED, TO_TIMESTAMP(SYSDATE-m_purge_retention));
DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP( DBMS_AUDIT_MGMT.AUDIT_TRAIL_OS, TO_TIMESTAMP(SYSDATE-m_purge_retention), 1);
DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP( DBMS_AUDIT_MGMT.AUDIT_TRAIL_XML, TO_TIMESTAMP(SYSDATE-m_purge_retention), 1);
END;', 
start_date =&gt; SYSTIMESTAMP, 
repeat_interval =&gt; 'freq=daily; byhour=0; byminute=0; bysecond=0;', 
end_date =&gt; NULL, 
enabled =&gt; TRUE, 
auto_drop =&gt; FALSE, 
comments =&gt; 'every day, update last_archive_timestamp (which DAILY_AUDIT_PURGE uses) to '||m_purge_retention||' days back.'
);
--Exception
--when ex_must_be_declared then
--dbms_output.put_line('DAILY_AUDIT_UPDATE_RETENTION: component missing?'||chr(13));
END;
/
</code></pre>



<p class="wp-block-paragraph">An other option would be to start the jon manually or to purge the audit-trail on demand:</p>



<pre class="wp-block-code"><code>-- manual start of purge jobs
select distinct job_name, owner from dba_scheduler_jobs;
exec dbms_scheduler.run_job('DAILY_AUDIT_UPDATE_RETENTION',use_current_session=&gt;false);
exec dbms_scheduler.run_job('audsys.DAILY_AUDIT_PURGE',use_current_session=&gt;false);
-- other options
exec DBMS_AUDIT_MGMT.FLUSH_UNIFIED_AUDIT_TRAIL;
-- or
begin
DBMS_AUDIT_MGMT.FLUSH_UNIFIED_AUDIT_TRAIL;
for i in 1..10 loop
DBMS_AUDIT_MGMT.TRANSFER_UNIFIED_AUDIT_RECORDS;
end loop;
end;
/
begin
DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL(
audit_trail_type =&gt; DBMS_AUDIT_MGMT.AUDIT_TRAIL_UNIFIED,
use_last_arch_timestamp =&gt; FALSE);
end;
/
</code></pre>



<h2 class="wp-block-heading" id="h-sources-links-and-related-blogs">Sources, links and related blogs:</h2>



<p class="wp-block-paragraph"><a href="https://support.oracle.com/knowledge/Oracle%20Database%20Products/2904294_1.html">https://support.oracle.com/knowledge/Oracle%20Database%20Products/2904294_1.html</a></p>



<p class="wp-block-paragraph"><a href="https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/AUDIT-Unified-Auditing.html">https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/AUDIT-Unified-Auditing.html</a></p>



<p class="wp-block-paragraph"><a href="https://oracle-base.com/articles/23/auditing-enhancements-23">https://oracle-base.com/articles/23/auditing-enhancements-23</a></p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-embed is-type-wp-embed is-provider-dbi-blog wp-block-embed-dbi-blog"><div class="wp-block-embed__wrapper">
<blockquote class="wp-embedded-content" data-secret="X5dWIytpr2"><a href="https://www.dbi-services.com/blog/purging-unified-audit-trail-in-12cr2/">Purging Unified Audit Trail in 12cR2</a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="&#8220;Purging Unified Audit Trail in 12cR2&#8221; &#8212; dbi Blog" src="https://www.dbi-services.com/blog/purging-unified-audit-trail-in-12cr2/embed/#?secret=sKzMAbliRo#?secret=X5dWIytpr2" data-secret="X5dWIytpr2" width="500" height="282" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
</div></figure>



<figure class="wp-block-embed is-type-wp-embed is-provider-dbi-blog wp-block-embed-dbi-blog"><div class="wp-block-embed__wrapper">
<blockquote class="wp-embedded-content" data-secret="3NmvxFyHE0"><a href="https://www.dbi-services.com/blog/from-oracle-standard-auditing-to-oracle-unified-auditing/">From Oracle Standard Auditing to Oracle Unified Auditing</a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="&#8220;From Oracle Standard Auditing to Oracle Unified Auditing&#8221; &#8212; dbi Blog" src="https://www.dbi-services.com/blog/from-oracle-standard-auditing-to-oracle-unified-auditing/embed/#?secret=AQSsnN5rAM#?secret=3NmvxFyHE0" data-secret="3NmvxFyHE0" width="500" height="282" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
</div></figure>



<figure class="wp-block-embed is-type-wp-embed is-provider-dbi-blog wp-block-embed-dbi-blog"><div class="wp-block-embed__wrapper">
<blockquote class="wp-embedded-content" data-secret="DfYuHM0vIv"><a href="https://www.dbi-services.com/blog/upgrade-to-oracle-19c-performance-issue/">Upgrade to Oracle 19c &#8211; performance issue</a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="&#8220;Upgrade to Oracle 19c &#8211; performance issue&#8221; &#8212; dbi Blog" src="https://www.dbi-services.com/blog/upgrade-to-oracle-19c-performance-issue/embed/#?secret=18qEZivpot#?secret=DfYuHM0vIv" data-secret="DfYuHM0vIv" width="500" height="282" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
</div></figure>
<p>L’article <a href="https://www.dbi-services.com/blog/cleanup-audit-trail-the-full-picture/">Cleanup Audit Trail &#8211; the Full Picture</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbi-services.com/blog/cleanup-audit-trail-the-full-picture/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Oracle 23ai New Backup &#038; Recovery Features</title>
		<link>https://www.dbi-services.com/blog/oracle-23ai-new-backup-recovery-features/</link>
					<comments>https://www.dbi-services.com/blog/oracle-23ai-new-backup-recovery-features/#respond</comments>
		
		<dc:creator><![CDATA[Oracle Team]]></dc:creator>
		<pubDate>Mon, 01 Jul 2024 11:25:58 +0000</pubDate>
				<category><![CDATA[Database Administration & Monitoring]]></category>
		<category><![CDATA[Database management]]></category>
		<category><![CDATA[OCI]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[enhancements]]></category>
		<category><![CDATA[New Features]]></category>
		<category><![CDATA[oracle 23ai]]></category>
		<category><![CDATA[RMAN]]></category>
		<guid isPermaLink="false">https://www.dbi-services.com/blog/?p=33407</guid>

					<description><![CDATA[<p>In this article I will give a short overview of some Backup &#38; Recovery features in the new Oracle 23ai database. Meanwhile there are more than 300 new features in Oracle 23ai most of them reflecting artificial intelligence. I will focus here on pure Backup &#38; Recovery enhancements. Creating Immutable Backups Using RMAN It is [&#8230;]</p>
<p>L’article <a href="https://www.dbi-services.com/blog/oracle-23ai-new-backup-recovery-features/">Oracle 23ai New Backup &amp; Recovery Features</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">In this article I will give a short overview of some Backup &amp; Recovery features in the new Oracle 23ai database. Meanwhile there are more than 300 new features in Oracle 23ai most of them reflecting artificial intelligence. I will focus here on pure Backup &amp; Recovery enhancements.</p>



<h2 class="wp-block-heading" id="h-creating-immutable-backups-using-rman"><strong>Creating Immutable Backups Using RMAN</strong></h2>



<p class="wp-block-paragraph">It is now possible to store immutable backups with the Oracle Database Cloud Backup Module for Oracle Cloud Infrastructure (OCI) which enables to configure backups suchlike, that they cannot be altered or deleted for a specific period, which helps to follow any compliance and data protection rules. Immutable backups will prevent anyone, even administrators to delete or modify backups in OCI Object Storage.</p>



<p class="wp-block-paragraph">Here&#8217;s a step-by-step example to set up immutable backups using RMAN and the Oracle Database Cloud Backup Module for OCI:</p>



<p class="wp-block-paragraph">You have to download and install the Oracle Database Cloud Backup Module on your database server whith following options: You can specify the -bucket parameter (and the name of an existing bucket or a new immutable bucket that you have created in OCI) otherwise the default bucket created by the installer will be used.</p>



<pre class="wp-block-code"><code>java -jar oci_install.jar -host https://objectstorage.&lt;region&gt;.oraclecloud.com -pdb1 &lt;password&gt; -opcId "&lt;tenancy-namespace&gt;/&lt;bucket-name&gt;" -opcPassFile &lt;path-to-opc-pass-file&gt; -libDir &lt;path-to-lib-dir&gt;</code></pre>



<p class="wp-block-paragraph">In RMAN you have to configure your SBT channel that way, that it will use the Oracle Database Cloud Backup Module. Now you can create a backup, e.g immutable for 30 days:</p>



<ul class="wp-block-list">

<li>KEEP UNTIL TIME &#8216;SYSDATE+30&#8217;: specifies that the backup is retained and immutable for 30 days.</li>


<li>IMMUTABLE: marks the backup as immutable.</li>

</ul>



<p class="wp-block-paragraph">A backup-script (like following example) can be used:</p>



<pre class="wp-block-code"><code>RMAN&gt; connect target /
RMAN&gt; CONFIGURE CHANNEL DEVICE TYPE sbt PARMS 'SBT_LIBRARY=/opt/oracle/lib/libopc.so, SBT_PARMS=(OPC_PFILE=/opt/oracle/opc/ocipassfile)';
BACKUP AS BACKUPSET DATABASE KEEP UNTIL TIME 'SYSDATE+30' IMMUTABLE;
RMAN&gt; LIST BACKUP OF DATABASE SUMMARY;</code></pre>



<p class="wp-block-paragraph">You should ensure,that the backup status is AVAILABLE und and the backupset includes the KEEP UNTIL date.</p>



<p class="wp-block-paragraph">That OCI backups work appropiatley you have to take into consideration, that</p>



<ul class="wp-block-list">
<li>OCI Object Storage bucket has Object Lock enabled to support immutability.</li>



<li>The IMMUTABLE keyword is used for specifying that the backup should not be altered or deleted within the specified retention.</li>



<li>OCI Object Storage policy and IAM settings must allow creating immutable objects.</li>
</ul>



<h2 class="wp-block-heading" id="h-rman-backup-encryption-algorithm-now-defaults-to-aes256"><strong>RMAN Backup Encryption Algorithm Now Defaults to AES256</strong></h2>



<p class="wp-block-paragraph">From Oracle 23ai on RMAN encrypted backups default to AES256 encryption algorithm.</p>



<p class="wp-block-paragraph">For backward compatibility<strong> e</strong>xisting backups created with previous encryption settings remain accessible. However, new backups will use AES256 unless explicitly configured otherwise. In other words, restore is supported by using existing backupsets AES128 or AES192 encryption algorithms and by changing your default settings you can still create backups with AES128 encryption.</p>



<p class="wp-block-paragraph">With AES256 encryption you will get enhanced security using a stronger encryption standard and achieving industry standards and compliance regulations for sensitive data.</p>



<p class="wp-block-paragraph">The default encryption using AES256 can be easily invoked out-of-the-box:</p>



<pre class="wp-block-code"><code>RMAN&gt; SET ENCRYPTION ON IDENTIFIED BY 'your_password';
RMAN&gt; BACKUP DATABASE;</code></pre>



<h2 class="wp-block-heading" id="h-oracle-globally-distributed-database-coordinated-backup-and-restore-enhancements"><strong>Oracle Globally Distributed Database Coordinated Backup and Restore Enhancements</strong></h2>



<p class="wp-block-paragraph">Additionally Oracle 23c AI Database includes several enhancements to globally distributed database coordinated backup and restore operations, aiming to improve efficiency, consistency, and reliability in multi-datacenter environments. Here are some key enhancements:</p>



<p class="wp-block-paragraph"><strong>Unified Backup Management</strong> can simplify the management of backups across globally distributed databases by providing a centralized framework to coordinate backup operations. This ensures that backups are synchronized and consistent across all sites. It can be programmed via DBMS_BACKUP_RESTORE:</p>



<pre class="wp-block-code"><code>-- Example SQL script to configure unified backup policy
-- Define global backup policy 
BEGIN 
DBMS_BACKUP_RESTORE.SET_GLOBAL_POLICY( 
policy_name =&gt; 'GlobalBackupPolicy', 
backup_schedule =&gt; 'FULL EVERY SUNDAY 2:00 AM UTC, INCREMENTAL DAILY 2:00 AM UTC', 
retention_period =&gt; 30, 
encryption_algorithm =&gt; 'AES256' 
); 
END; 
/ 
-- Apply global backup policy to all distributed databases 
BEGIN 
DBMS_BACKUP_RESTORE.APPLY_GLOBAL_POLICY( 
policy_name =&gt; 'GlobalBackupPolicy', 
target_databases =&gt; 'NYC_DB, LDN_DB, TOKYO_DB' 
); 
END; 
/</code></pre>



<p class="wp-block-paragraph"><strong>Global Backup Policies</strong>: You can now define global backup policies that apply uniformly across all distributed databases. This standardization helps in maintaining consistency and compliance with organizational policies. It can be set up like:</p>



<pre class="wp-block-code"><code>BEGIN 
DBMS_BACKUP_RESTORE.CONFIGURE_GLOBAL_SETTING(
setting_name =&gt; 'RETENTION_POLICY', 
setting_value =&gt; 'RECOVERY WINDOW OF 30 DAYS'
 ); 
DBMS_BACKUP_RESTORE.CONFIGURE_GLOBAL_SETTING( 
setting_name =&gt; 'BACKUP_OPTIMIZATION', 
setting_value =&gt; 'ON' 
); 
DBMS_BACKUP_RESTORE.CONFIGURE_GLOBAL_SETTING( 
setting_name =&gt; 'ENCRYPTION_ALGORITHM', 
setting_value =&gt; 'AES256' 
); 
DBMS_BACKUP_RESTORE.CONFIGURE_GLOBAL_SETTING( 
setting_name =&gt; 'ENCRYPTION_PASSWORD', 
setting_value =&gt; 'your_encryption_password'
 ); 
END; 
/</code></pre>



<p class="wp-block-paragraph"><strong>Consistent Point-in-Time Recovery</strong> ensures that all databases in a distributed environment can be restored to the same point in time, maintaining data consistency across different geographic locations (in my opinion not really new, it is managed via known RMAN-scripts for restore &amp; recover).</p>



<p class="wp-block-paragraph"><strong>Cross-Site Transaction Coordination</strong> enhances the coordination of transactions across distributed databases to ensure that backup and restore operations capture a consistent state of the entire database system, it can be done via Oracle Global Data Services (GDS):</p>



<pre class="wp-block-code"><code>-- Connect to the GDS catalog database
sqlplus / as sysdba

-- Create the GDS catalog
BEGIN
  DBMS_GDS.CREATE_GDS_CATALOG();
END;
/

-- Add databases to the GDS pool
BEGIN
  DBMS_GDS.ADD_GDS_DATABASE(
    db_unique_name =&gt; 'NYC_DB',
    connect_string =&gt; 'NYC_DB_CONN_STRING',
    region         =&gt; 'AMERICAS'
  );

  DBMS_GDS.ADD_GDS_DATABASE(
    db_unique_name =&gt; 'LDN_DB',
    connect_string =&gt; 'LDN_DB_CONN_STRING',
    region         =&gt; 'EMEA'
  );

  DBMS_GDS.ADD_GDS_DATABASE(
    db_unique_name =&gt; 'TOKYO_DB',
    connect_string =&gt; 'TOKYO_DB_CONN_STRING',
    region         =&gt; 'APAC'
  );
END;
/
-- On each database (NYC_DB, LDN_DB, TOKYO_DB)
sqlplus / as sysdba

-- Enable distributed transactions
ALTER SYSTEM SET distributed_transactions = 10 SCOPE = BOTH;

-- Configure the global_names parameter
ALTER SYSTEM SET global_names = TRUE SCOPE = BOTH;

-- Set the commit point strength
ALTER SYSTEM SET commit_point_strength = &lt;value&gt; SCOPE = BOTH;

-- Configure Oracle Net for distributed transactions (update tnsnames.ora and listener.ora as necessary)
-- Create database links to enable cross-site communication
-- Begin the distributed transaction
SET TRANSACTION READ WRITE;

...

-- Commit the transaction
COMMIT;</code></pre>



<p class="wp-block-paragraph"><strong>Parallel Backup Streams</strong> support parallel backup streams to expedite the backup process, making it faster and more efficient, especially for large databases spread across multiple sites. You just have to configure RMAn-channels like in previous releases but in Oracle 23ai <strong>Adaptive Parallelism</strong> is used. By setting a higher level of parallelism (e.g., 8), Oracle 23ai can dynamically adjust the number of active channels based on real-time system performance and workload, rather than strictly adhering to the configured number.</p>



<p class="wp-block-paragraph"><strong>Automated Restore Coordination</strong> automates the coordination of restore operations across multiple databases, ensuring that all parts of the distributed database are restored in a synchronized manner, it will be invoked with:</p>



<pre class="wp-block-code"><code>-- Enable automated restore coordination
CONFIGURE RESTORE COORDINATION ON;
-- Automated restore coordination across distributed databases
RESTORE DATABASE FROM SERVICE 'NYC_DB' USING CHANNEL c1;
RESTORE DATABASE FROM SERVICE 'LDN_DB' USING CHANNEL c2;
RESTORE DATABASE FROM SERVICE 'TOKYO_DB' USING CHANNEL c3;
-- Recover database
RECOVER DATABASE;</code></pre>



<p class="wp-block-paragraph"><strong>Resilient Backup Infrastructure</strong> enhancements to the backup infrastructure to handle network disruptions and other issues that may arise in a globally distributed environment, ensuring that backups are resilient and reliable. Oracle Database 23ai enhances the resilience of backup infrastructure by integrating features like Data Guard for high availability, Fast Recovery Area for automated backup management, and RMAN duplication for redundant data copies. </p>



<h2 class="wp-block-heading" id="h-rman-operational-enhancements"><strong>RMAN Operational Enhancements</strong></h2>



<p class="wp-block-paragraph"><strong>Automatic Block Repair During Backup</strong>: Oracle 23ai enhances RMAN&#8217;s capability to automatically detect and repair corrupt blocks during backup operations.</p>



<pre class="wp-block-code"><code>RMAN&gt; BACKUP DATABASE PLUS ARCHIVELOG CHECK READONLY;</code></pre>



<p class="wp-block-paragraph"><strong>Improved Block Corruption Detection</strong>: Oracle 23ai has enhanced algorithms for faster and more accurate detection of block corruption during backup and restore operations and the some structures are used for <strong>Enhanced Backup Validation</strong>: RMAN has now faster and more efficient methods to validate backups and ensure data integrity.</p>



<h2 class="wp-block-heading" id="h-simplified-database-migration-across-platforms-using-rman"><strong>Simplified Database Migration Across Platforms Using RMAN</strong></h2>



<p class="wp-block-paragraph">Oracle Database 23ai includes RMAN-enhancements which simplify the process of migrating databases across different platforms. This feature is particularly useful when transitioning databases between heterogeneous environments, ensuring minimal downtime and efficient migration. New command options allow existing RMAN backups to be used to transport tablespaces or pluggable databases to a new destination database with minimal downtime. With the example below you can easily migrate from e.g. Linux to Windows or vice versa:</p>



<pre class="wp-block-code"><code>-- Connect RMAN to both source and target databases
CONNECT TARGET sys@PROD_DB
CONNECT AUXILIARY sys@TARGET_DB

-- Configure cross-platform migration settings
SET NEWNAME FOR DATABASE TO '/path/to/new/PROD_DB';

-- Start migration process
DUPLICATE TARGET DATABASE TO TARGET_DB
  FROM ACTIVE DATABASE
  SPFILE
  PARAMETER_VALUE_CONVERT 'db_unique_name=PROD_DB','db_unique_name=TARGET_DB'
  SET db_file_name_convert='/prod_data/','/target_data/'
  SET log_file_name_convert='/prod_redo/','/target_redo/';
-- Check the migration progress
SHOW DUPLICATE SUMMARY;
-- Validate the migrated database
VALIDATE DATABASE;</code></pre>



<h2 class="wp-block-heading" id="h-related-sources-links-and-blogs"><strong>Related Sources, Links and Blogs:</strong></h2>



<p class="wp-block-paragraph"><a href="https://docs.oracle.com/en/database/oracle/oracle-database/23/nfcoa/oracle-database-23c-new-features-guide.pdf">https://docs.oracle.com/en/database/oracle/oracle-database/23/nfcoa/oracle-database-23c-new-features-guide.pdf</a></p>



<p class="wp-block-paragraph"><a href="https://docs.oracle.com/en/cloud/paas/db-backup-cloud/csdbb/storing-backups-oci-immutable-buckets.html#GUID-DECFAAF9-861F-46D9-A1FC-B848476772C5">https://docs.oracle.com/en/cloud/paas/db-backup-cloud/csdbb/storing-backups-oci-immutable-buckets.html#GUID-DECFAAF9-861F-46D9-A1FC-B848476772C5</a></p>



<p class="wp-block-paragraph"><a href="https://www.oracle.com/pls/topic/lookup?ctx=en/database/oracle/oracle-database/23&amp;id=SHARD-GUID-99A32370-00BD-4C30-A2DB-19F4EA168064">https://www.oracle.com/pls/topic/lookup?ctx=en/database/oracle/oracle-database/23&amp;id=SHARD-GUID-99A32370-00BD-4C30-A2DB-19F4EA168064</a></p>



<p class="wp-block-paragraph"><a href="https://www.oracle.com/pls/topic/lookup?ctx=en/database/oracle/oracle-database/23&amp;id=BRADV-GUID-6ED708C7-1092-45FC-80C6-236F062D0DAC">https://www.oracle.com/pls/topic/lookup?ctx=en/database/oracle/oracle-database/23&amp;id=BRADV-GUID-6ED708C7-1092-45FC-80C6-236F062D0DAC</a></p>



<p class="wp-block-paragraph"><a href="https://www.oracle.com/pls/topic/lookup?ctx=en/database/oracle/oracle-database/23&amp;id=BRADV-GUID-E836E243-6620-495B-ACFB-AC0001EF4E89">https://www.oracle.com/pls/topic/lookup?ctx=en/database/oracle/oracle-database/23&amp;id=BRADV-GUID-E836E243-6620-495B-ACFB-AC0001EF4E89</a></p>



<p class="wp-block-paragraph"><a href="https://www.oracle.com/pls/topic/lookup?ctx=en/database/oracle/oracle-database/23&amp;id=BRADV-GUID-BB0E3EBC-6720-4E33-9219-95F4CEA6FA65">https://www.oracle.com/pls/topic/lookup?ctx=en/database/oracle/oracle-database/23&amp;id=BRADV-GUID-BB0E3EBC-6720-4E33-9219-95F4CEA6FA65</a></p>



<p class="wp-block-paragraph"><a href="https://www.oracle.com/pls/topic/lookup?ctx=en/database/oracle/oracle-database/23&amp;id=BRADV-GUID-54099115-7158-4ED4-A537-59451B3E14DC">https://www.oracle.com/pls/topic/lookup?ctx=en/database/oracle/oracle-database/23&amp;id=BRADV-GUID-54099115-7158-4ED4-A537-59451B3E14DC</a></p>
<p>L’article <a href="https://www.dbi-services.com/blog/oracle-23ai-new-backup-recovery-features/">Oracle 23ai New Backup &amp; Recovery Features</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbi-services.com/blog/oracle-23ai-new-backup-recovery-features/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Simulate (Transparent Tablespace Encryption) TDE on Oracle Standard Edition</title>
		<link>https://www.dbi-services.com/blog/simulate-transparent-tablespace-encryption-tde-on-oracle-standard-edition/</link>
					<comments>https://www.dbi-services.com/blog/simulate-transparent-tablespace-encryption-tde-on-oracle-standard-edition/#respond</comments>
		
		<dc:creator><![CDATA[Oracle Team]]></dc:creator>
		<pubDate>Wed, 29 May 2024 14:54:08 +0000</pubDate>
				<category><![CDATA[Database Administration & Monitoring]]></category>
		<category><![CDATA[Database management]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Oracle SE2]]></category>
		<category><![CDATA[Oracle TDE]]></category>
		<guid isPermaLink="false">https://www.dbi-services.com/blog/?p=33334</guid>

					<description><![CDATA[<p>by Alexandre Nestor Introduction The Oracle database Standard Edition do not have the Transparent Tablespace Encryption (TDE) feature which is a part of ASO (Advanced Security), and ASO is availabale only on Entreprise Edition version. But encryption can still be used, with a little developpement effort.$ The test platform I have an Oracle 19c SE2 [&#8230;]</p>
<p>L’article <a href="https://www.dbi-services.com/blog/simulate-transparent-tablespace-encryption-tde-on-oracle-standard-edition/">Simulate (Transparent Tablespace Encryption) TDE on Oracle Standard Edition</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">by Alexandre Nestor</p>



<h2 class="wp-block-heading" id="h-introduction">Introduction</h2>



<p class="wp-block-paragraph">The Oracle database Standard Edition do not have the Transparent Tablespace Encryption (TDE) feature which is a part of ASO (Advanced Security), and ASO is availabale only on Entreprise Edition version.</p>



<p class="wp-block-paragraph">But encryption can still be used, with a little developpement effort.$</p>



<h2 class="wp-block-heading" id="h-the-test-platform">The test platform</h2>



<p class="wp-block-paragraph">I have an Oracle 19c SE2 version with one pdb (PDB11).</p>



<p class="wp-block-paragraph">I will create a schema named <code>safe</code>, which will contains the encript/decrypt function and th key to be used to encrypt and decrypt.</p>



<p class="wp-block-paragraph">Also the safe schema will contain a secret table with encrypted data.</p>



<p class="wp-block-paragraph">On the database I will create an user <code>scott</code>, with minimal rights (only create session) which can read encrypted data.</p>



<p class="wp-block-paragraph">Let&#8217;s build the environnement: </p>



<p class="wp-block-paragraph">Connect on the <code>pdb11</code> as <code>sysdba</code> and create the <code>safe</code> tablespace, and user <code>safe</code>.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
SQL&gt; alter session set container=pdb11;

Session altered.

SQL&gt; create tablespace safe;

Tablespace created.

SQL&gt; create user safe identified by tiger default tablespace safe;

User created.

SQL&gt;  grant create session to safe;

Grant succeeded.

SQL&gt; alter user safe quota unlimited on safe;

User altered.

SQL&gt;  grant resource to safe;

Grant succeeded.

SQL&gt; grant create view to safe;

Grant succeeded.
</pre></div>


<p class="wp-block-paragraph">User safe need to have execution rights on <code>dbms_crypto</code> package</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
SQL&gt;  grant execute on dbms_crypto to safe;

Grant succeeded.

</pre></div>


<p class="wp-block-paragraph">From now on we are going to do all commands as <code>safe</code> user. Connect as user <code>safe</code> to the <code>PDB11</code>. and create the <code>secret_keys</code> table to hold all needed keys for decrypt.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
&#x5B;CDB01]&#x5B;oracle@db ~]$ sqlplus safe/tiger@db.sub05191447261.vcn01.oraclevcn.com:1521/pdb11

SQL&gt; create table secret_keys(key_bytes_raw RAW (32), iv_raw RAW (16));

Table created.
</pre></div>


<p class="wp-block-paragraph">Insert random keys in the secret_keys table.</p>



<p class="wp-block-paragraph"><strong>Do not loose, or change these key. Your data will be lost.</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
SQL&gt; insert into secret_keys(key_bytes_raw,iv_raw) values(DBMS_CRYPTO.RANDOMBYTES(256/8),DBMS_CRYPTO.RANDOMBYTES(16));

1 row created.

SQL&gt; commit;

Commit complete.

SQL&gt; select * from secret_keys;

KEY_BYTES_RAW
----------------------------------------------------------------
IV_RAW
--------------------------------
CCF9303B9AE706AC6212F9672FF8720113EC75D7C5FFAC267E42128AC40A33FA
A39F34AB9705CE91A6E6B4E592B32E28

</pre></div>


<p class="wp-block-paragraph">Create the <code>encrypt</code> and <code>decrypt</code> functions.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
SQL&gt; CREATE OR REPLACE FUNCTION encr(input_string in VARCHAR2)
RETURN RAW
  IS 
    encryption_type    PLS_INTEGER := DBMS_CRYPTO.ENCRYPT_AES256
                       + DBMS_CRYPTO.CHAIN_CBC
                       + DBMS_CRYPTO.PAD_PKCS5;
    iv_raw             RAW (16);
    encrypted_raw      RAW (2000);
    key_bytes_raw      RAW (32);
    BEGIN
    --DBMS_OUTPUT.PUT_LINE ( &#039;Original string: &#039; || input_string);
    select key_bytes_raw,iv_raw into key_bytes_raw,iv_raw FROM secret_keys;
    encrypted_raw := DBMS_CRYPTO.ENCRYPT(
       src =&gt; UTL_I18N.STRING_TO_RAW (input_string,  &#039;AL32UTF8&#039;),
       typ =&gt; encryption_type,
       key =&gt; key_bytes_raw,
       iv  =&gt; iv_raw
    );
    --DBMS_OUTPUT.PUT_LINE ( &#039;Encrypted raw: &#039; || encrypted_raw);
    return encrypted_raw;
  END encr;
/

Function created.


SQL&gt; CREATE OR REPLACE FUNCTION decr(encrypted_raw in RAW) 
return varchar2
IS 
  encryption_type    PLS_INTEGER := DBMS_CRYPTO.ENCRYPT_AES256
                 + DBMS_CRYPTO.CHAIN_CBC
                 + DBMS_CRYPTO.PAD_PKCS5;
  iv_raw             RAW (16);
  key_bytes_raw      RAW (32);
  decrypted_raw      RAW (2000);
BEGIN
  select key_bytes_raw,iv_raw into key_bytes_raw,iv_raw FROM secret_keys;
  decrypted_raw := DBMS_CRYPTO.DECRYPT(
    src =&gt; encrypted_raw,
    typ =&gt; encryption_type,
    key =&gt; key_bytes_raw,
    iv  =&gt; iv_raw
  );
  return UTL_I18N.RAW_TO_CHAR (decrypted_raw, &#039;AL32UTF8&#039;);
END decr;
/

Function created.
</pre></div>


<p class="wp-block-paragraph">Test how these fonctions work:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
-- encypt
SQL&gt; select encr(&#039;Hello&#039;) from dual;

ENCR(&#039;HELLO&#039;)
--------------------------------------------------------------------------------
75388B4D940B559DD1A5D5BCA753101B

--decrypt
SQL&gt; select decr(&#039;75388B4D940B559DD1A5D5BCA753101B&#039;) from dual;

DECR(&#039;75388B4D940B559DD1A5D5BCA753101B&#039;)
--------------------------------------------------------------------------------
Hello

--encrypt/decrypt
SQL&gt; select decr(encr(&#039;Hello&#039;)) from dual;

DECR(ENCR(&#039;HELLO&#039;))
--------------------------------------------------------------------------------
Hello

</pre></div>


<p class="wp-block-paragraph">On the schema <code>safe</code> create the table that need to be protected, let&#8217;s call it, <code>secret_emp</code>, and insert an encrypted string.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
SQL&gt; create table secret_emp(name_encrypted RAW(2000));

Table created.

SQL&gt; insert into secret_emp(name_encrypted) values(encr(&#039;Obama&#039;));

1 row created.

SQL&gt; commit;

Commit complete.

SQL&gt; select * from secret_emp;

NAME_ENCRYPTED
--------------------------------------------------------------------------------
9115E6FD54D676DB043CD0D1BF982027

</pre></div>


<p class="wp-block-paragraph">Finally we create a view on this table named <code>authorized_read_emp</code>. On this view authorised users will select to get the decrypted data.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
SQL&gt; create view authorized_read_emp as select decr(name_encrypted) name_decrypted from secret_emp;

View created.

SQL&gt; select * from authorized_read_emp;

NAME_DECRYPTED
--------------------------------------------------------------------------------
Obama
</pre></div>


<p class="wp-block-paragraph">Now we are going to create an user which has the rights to read the plan text data. For this user the encryption is transparent.</p>



<p class="wp-block-paragraph">Connect as <code>sysdba</code> to the <code>pdb11</code> and create an user <code>scott</code>. This user is allowed to read the data from <code>authorized_read_emp </code>view.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
SQL&gt; create user scott identified by tiger;

User created.

SQL&gt; grant create session to scott;

Grant succeeded.

</pre></div>


<p class="wp-block-paragraph">And finally as safe user, give the rights to user <code>scott</code> to read the view:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
&#x5B;CDB01]&#x5B;oracle@db ~]$  sqlplus safe/tiger@db.sub05191447261.vcn01.oraclevcn.com:1521/pdb11

SQL&gt; grant select on authorized_read_emp to scott;

Grant succeeded.

SQL&gt; exit; 

</pre></div>


<p class="wp-block-paragraph">Back to user scott, let&#8217;s try to read the plan text data: </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
&#x5B;CDB01]&#x5B;oracle@db ~]$  sqlplus scott/tigger@db.sub05191447261.vcn01.oraclevcn.com:1521/pdb11

SQL&gt; select * from safe.authorized_read_emp;

NAME_DECRYPTED
--------------------------------------------------------------------------------
Obama
</pre></div>


<h2 class="wp-block-heading" id="h-conclusion">Conclusion </h2>



<p class="wp-block-paragraph">Ok is not really like the TDE implementation, and maybe a better implementation could be done. But the main points are:</p>



<ul class="wp-block-list">
<li>Schema &#8216;<code>safe</code>&#8216; contains only encrypted data. If someone stole the storage disks from the datacenter it cannot have access to tha data as it is stored encrypted. This is one of the main goal of TDE.</li>
</ul>



<ul class="wp-block-list">
<li>Schema &#8216;<code>safe</code>&#8216; contains also the keys needed to decrypt the data. This is a limitation. The keys to decrypt data can be stored outside the database to increase the security.</li>
</ul>



<ul class="wp-block-list">
<li>The user &#8216;<code>scott</code>&#8216; can access the data in a transparent mode as the data is decrypted on the fly. No data in plain is stored in the database.</li>
</ul>



<ul class="wp-block-list">
<li>The user &#8216;<code>scott</code>&#8216; has only the rights to connect and to read the data which is decrypted on the fly.</li>
</ul>
<p>L’article <a href="https://www.dbi-services.com/blog/simulate-transparent-tablespace-encryption-tde-on-oracle-standard-edition/">Simulate (Transparent Tablespace Encryption) TDE on Oracle Standard Edition</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbi-services.com/blog/simulate-transparent-tablespace-encryption-tde-on-oracle-standard-edition/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Using WebHooks with GitLab to launch external tools</title>
		<link>https://www.dbi-services.com/blog/using-webhooks-with-gitlab-to-launch-external-tools/</link>
					<comments>https://www.dbi-services.com/blog/using-webhooks-with-gitlab-to-launch-external-tools/#respond</comments>
		
		<dc:creator><![CDATA[Oracle Team]]></dc:creator>
		<pubDate>Mon, 27 May 2024 15:02:10 +0000</pubDate>
				<category><![CDATA[Ansible]]></category>
		<category><![CDATA[DevOps]]></category>
		<guid isPermaLink="false">https://www.dbi-services.com/blog/?p=33303</guid>

					<description><![CDATA[<p>by Alexandre Nestor Introduction WebHooks are HTTP callbacks that are triggered by events. In case of GitlLab these can be events like pushing some code, or creating an issue, or pushing some comments, create a merge request and so on. Somehow, is a way for an application to send data, trigger events, in real time [&#8230;]</p>
<p>L’article <a href="https://www.dbi-services.com/blog/using-webhooks-with-gitlab-to-launch-external-tools/">Using WebHooks with GitLab to launch external tools</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">by Alexandre Nestor</p>



<h2 class="wp-block-heading" id="h-introduction">Introduction</h2>



<p class="wp-block-paragraph">WebHooks are HTTP callbacks that are triggered by events. In case of GitlLab these can be events like pushing some code, or creating an issue, or pushing some comments, create a merge request and so on.</p>



<p class="wp-block-paragraph">Somehow, is a way for an application to send data, trigger events, in real time to another application, even if the target application don&#8217;t ask for the data. </p>



<p class="wp-block-paragraph">In this post I will explain how to add a WebHook to a project and how to execute some external code when en event is triggered.</p>



<p class="wp-block-paragraph">I will use an <a href="https://flask.palletsprojects.com/">Flask</a> application, which will be triggered by GitLab WebHook.</p>



<h2 class="wp-block-heading" id="h-vm-configuration">VM configuration</h2>



<p class="wp-block-paragraph">The test VM is created on the OCI cloud. It is a RedHat VM but that is not very important. </p>



<p class="wp-block-paragraph">First I have to open the port <code>8200</code> (used  by Flask). RedHat use by default <code>firewalld</code> as firewall:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
# add 8200 port using tcp to the public zone
&#x5B;root@wb ~]# firewall-cmd --zone=public --add-port=8200/tcp
success
# list opened ports
&#x5B;root@wb ~]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens3
sources:
services: dhcpv6-client http ssh
ports: 8200/tcp
protocols:
forward: no
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
</pre></div>


<h2 class="wp-block-heading" id="h-the-flask-application">The Flask application </h2>



<p class="wp-block-paragraph">For example I create a small <code>Flask</code> application which is waiting for an event on <code>8200</code> port. The easiest application is to retrieve the <code>HTTP</code> frame. </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
# app.py 
from flask import Flask, request, abort
import json

app = Flask(__name__)

@app.route(&#039;/my_webhook&#039;, methods=&#x5B;&#039;POST&#039;])
def my_webhook():
    if request.method == &#039;POST&#039;:
        print(json.dumps(request.json, indent=2))
        return &#039;success&#039;, 200
    else:
        abort(400)

if __name__ == &#039;__main__&#039;:
    app.run(host=&#039;0.0.0.0&#039;, port=8200, debug=True)
</pre></div>


<p class="wp-block-paragraph">The Flask will launch a http server which is listen on all interfaces (<code>0.0.0.0</code>) en on port <code>8200</code><br>The path to be used in the HTTP POST call is <code>my_webhook</code><br>Also I used the debug mode to get the most traces.<br>The Flask application is waiting a POST request (line 10). And answer <code>success</code>.<br>Otherwise, return <code>400</code> HTTP code.</p>



<h3 class="wp-block-heading" id="h-start-the-flask-application">Start the Flask application </h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
(venv) &#x5B;opc@wb ~]$ python app.py
 * Serving Flask app &#039;app&#039; (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on all addresses.
   WARNING: This is a development server. Do not use it in a production deployment.
 * Running on http://172.168.0.40:8200/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 295-390-357
</pre></div>


<h2 class="wp-block-heading" id="h-gitlab-configuration">GitLab configuration </h2>



<p class="wp-block-paragraph">You must have the role  <code>maitainer</code> on your project, to have the rights to manage WebHooks.</p>



<p class="wp-block-paragraph">Select Settings -&gt; WebHooks from the left Menu</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="435" src="https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2024/05/image-45-1024x435.png" alt="" class="wp-image-33305" srcset="https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2024/05/image-45-1024x435.png 1024w, https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2024/05/image-45-300x127.png 300w, https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2024/05/image-45-768x326.png 768w, https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2024/05/image-45-1536x652.png 1536w, https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2024/05/image-45-2048x869.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">Once The WebHook was saved it can be tested. From <code>Test</code> button you can choose an event type to test. </p>



<p class="wp-block-paragraph">Let&#8217;s try with a <code>push</code> event:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="583" src="https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2024/05/image-46-1024x583.png" alt="" class="wp-image-33306" srcset="https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2024/05/image-46-1024x583.png 1024w, https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2024/05/image-46-300x171.png 300w, https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2024/05/image-46-768x438.png 768w, https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2024/05/image-46-1536x875.png 1536w, https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2024/05/image-46-2048x1167.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">When the event is triggered in GitLab, the Flask application must dump the http frame on the screen: </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
 * Running on http://172.168.0.40:8200/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 295-390-357
.....
{
  &quot;object_kind&quot;: &quot;push&quot;,   
  &quot;event_name&quot;: &quot;push&quot;,
  &quot;before&quot;: &quot;6aa30335b09*****53183fb28bb84aada5cf&quot;,
  &quot;after&quot;: &quot;a48e187ef217a******62498378e5023d355&quot;,
  &quot;ref&quot;: &quot;refs/heads/main&quot;,
  &quot;checkout_sha&quot;: &quot;a48e187ef21********9490562498378e5023d355&quot;,
  &quot;message&quot;: null,
  &quot;user_id&quot;: 11774125,
  &quot;user_name&quot;: &quot;your username &quot;,
  &quot;user_username&quot;: &quot;your.usernam&quot;,
  &quot;user_email&quot;: &quot;&quot;,
  &quot;user_avatar&quot;: &quot;https://gitlab.com/uploads/-/system/user/avatar/11774125/avatar.png&quot;,
  &quot;project_id&quot;: 38878393,
  &quot;project&quot;: {
    &quot;id&quot;: 38878393,
    .....
</pre></div>


<p class="wp-block-paragraph">On line 7 we can see the <code>push</code> event from GitLab.</p>



<h2 class="wp-block-heading" id="h-conclusion">Conclusion</h2>



<p class="wp-block-paragraph">The use of WebHooks from GitLab to run external code represents another facility in DevOps tools.</p>



<p class="wp-block-paragraph">Their implementation is easy and immediate. </p>



<p class="wp-block-paragraph">An example of use case is the integration with Ansible Automation Controller, to run Ansible jobs.</p>
<p>L’article <a href="https://www.dbi-services.com/blog/using-webhooks-with-gitlab-to-launch-external-tools/">Using WebHooks with GitLab to launch external tools</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbi-services.com/blog/using-webhooks-with-gitlab-to-launch-external-tools/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>REKEY operation on Oracle Database configured with Oracle Key Vault</title>
		<link>https://www.dbi-services.com/blog/rekey-operation-on-oracle-database-configured-with-oracle-key-vault/</link>
					<comments>https://www.dbi-services.com/blog/rekey-operation-on-oracle-database-configured-with-oracle-key-vault/#respond</comments>
		
		<dc:creator><![CDATA[Oracle Team]]></dc:creator>
		<pubDate>Tue, 02 Apr 2024 14:41:13 +0000</pubDate>
				<category><![CDATA[Oracle]]></category>
		<guid isPermaLink="false">https://www.dbi-services.com/blog/?p=32267</guid>

					<description><![CDATA[<p>REKEY Oracle database configured with Oracle Key Vault</p>
<p>L’article <a href="https://www.dbi-services.com/blog/rekey-operation-on-oracle-database-configured-with-oracle-key-vault/">REKEY operation on Oracle Database configured with Oracle Key Vault</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">by Alexandre Nestor</p>



<h1 class="wp-block-heading" id="h-introduction">Introduction</h1>



<p class="wp-block-paragraph">When Oracle database is configured with Oracle Key Vault, all mater encryption key (MEK) are stored on Oracle Key Vault server. </p>



<p class="wp-block-paragraph">Rekey is the operation of changing the MEK. </p>



<p class="wp-block-paragraph">In the previous article <a href="https://www.dbi-services.com/blog/clone-oracle-database-configured-with-oracle-key-vault-okv/">Clone Oracle Database configured with Oracle Key Vault (OKV)</a> I cloned a database <code>CDB01</code> to <code>CDB02</code> configured with OKV. At the end of the clone process the cloned database <code>CDB02</code> use the same keys as the source database. In a production environment this is not an acceptable solution.  The cloned <code>CDB02</code> database (which can be a clone for test purpose), need to use it&#8217;s own keys. To achieve this goal we need to REKEY the <code>CDB02</code> database. </p>



<p class="wp-block-paragraph">First we are going to create a wallet for <code>CDB02</code>.</p>



<p class="wp-block-paragraph">The we are going execute the REKEY operation, to generate new master encryption keys.<br>At the end to make the full separation between <code>CDB01</code> and <code>CDB02</code> we remove the rights for <code>CDB02</code> to read the wallet of <code>CDB01</code>.</p>



<h2 class="wp-block-heading" id="h-preparation">Preparation</h2>



<p class="wp-block-paragraph">As explained in the previous post, the RESTFul api is installed in <code>/home/oracle/okv</code></p>



<p class="wp-block-paragraph">I use a script to set the RESTFul API environnement:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
&#x5B;oracle@db okv]$ cat /home/oracle/okv/set_okv_rest_env.sh
export OKV_RESTCLI_CONFIG=$HOME/okv/conf
export JAVA_HOME=/usr/java/jdk-11.0.10
export OKV_HOME=$HOME/okv
export PATH=$PATH:$OKV_HOME/bin

&#x5B;oracle@db okv]$ source /home/oracle/okv/set_okv_rest_env.sh
</pre></div>


<p class="wp-block-paragraph">I use an SQL script to output the wallet status:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
&#x5B;oracle@db okv]$ cat $HOME/tde.sql
set pages 200
set line 300
col WRL_PARAMETER format a50
col status forma a10
col pdb_name  format a20
select pdb_id, pdb_name, guid from dba_pdbs;
select * from v$encryption_wallet where con_id != 2;
</pre></div>


<h2 class="wp-block-heading" id="h-the-initial-status-of-cdb02">The initial status of CDB02</h2>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
&#x5B;oracle@db ~]$ . oraenv &lt;&lt;&lt; CDB02
&#x5B;CDB02]&#x5B;oracle@db ~]$ sqlplus / as sysdba

SQL&gt; show parameter wallet_root

NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
wallet_root			     string	 /opt/oracle/admin/CDB02/wallet

SQL&gt; show parameter tde_configuration

NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
tde_configuration		     string	 KEYSTORE_CONFIGURATION=OKV|FIL

SQL&gt; @tde.sql

    PDB_ID PDB_NAME		GUID
---------- -------------------- --------------------------------
	 3 PDB01		0AE3AEC4EE5ACDB1E063A001A8ACB8BB
	 2 PDB$SEED		0AE38C7FF01EC651E063A001A8AC821E


WRL_TYPE  WRL_PARAMETER                       STATUS              WALLET_TYPE   WALLET_OR KEYSTORE FULLY_BAC CON_ID
-------- ----------------------------------- -------------------- ------------- --------- -------- --------- -------
FILE     /opt/oracle/admin/CDB02/wallet/tde/ OPEN_NO_MASTER_KEY    AUTOLOGIN    SINGLE      NONE     UNDEFINED  1
OKV                                          OPEN                  OKV          SINGLE      NONE     UNDEFINED  1
FILE                                         OPEN_NO_MASTER_KEY    AUTOLOGIN    SINGLE      UNITED   UNDEFINED  3
OKV                                          OPEN_UNKNONW_         OKV          SINGLE      UNITED   UNDEFINED  3

SQL&gt; exit; 

&#x5B;CDB02]&#x5B;oracle@db ~]$ /opt/oracle/admin/CDB02/wallet/okv/bin/okvutil list
Enter Oracle Key Vault endpoint password: endpoint_password
Unique ID                               Type            Identifier
600D0743-01D9-4F2F-BF6F-C9E8AC74FF2A	Symmetric Key	TDE Master Encryption Key: TAG CDB:CDB01 MEK first
6A752388-F93D-4F14-BF35-39E674CAAFED	Symmetric Key	TDE Master Encryption Key: TAG REKEY CDB01
AB294686-1FC4-4FE8-BFAD-F56BAD0A124B	Symmetric Key	TDE Master Encryption Key: TAG REKEY CDB01
BB0CC77A-10AD-4F55-BF0A-9F5A4C7F98C1	Symmetric Key	TDE Master Encryption Key: TAG CDB:DBTDEOKV:PDB1 MEK first

</pre></div>


<h2 class="wp-block-heading" id="h-create-a-wallet-for-cdb02">Create a wallet for CDB02</h2>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
&#x5B;CDB02]&#x5B;oracle@db json]$ $OKV_HOME/bin/okv manage-access wallet create --generate-json-input &gt; create_db_wallet_CDB02.json
&#x5B;CDB02]&#x5B;oracle@db json]$ cat create_db_wallet_CDB02.json
{
  &quot;service&quot; : {
    &quot;category&quot; : &quot;manage-access&quot;,
    &quot;resource&quot; : &quot;wallet&quot;,
    &quot;action&quot; : &quot;create&quot;,
    &quot;options&quot; : {
      &quot;wallet&quot; : &quot;ORA_CLONES&quot;,
      &quot;type&quot; : &quot;GENERAL&quot;,
      &quot;description&quot; : &quot;Wallet for Oracle Clones&quot;
    }
  }
}

&#x5B;CDB02]&#x5B;oracle@db json]$ $OKV_HOME/bin/okv manage-access wallet create --from-json create_db_wallet_CDB02.json
{
  &quot;result&quot; : &quot;Success&quot;
}
</pre></div>


<p class="wp-block-paragraph">Set the default wallet for CDB02</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
&#x5B;CDB02]&#x5B;oracle@db json]$ okv manage-access wallet set-default --generate-json-input &gt; set_default_wallet_CDB02.json


&#x5B;CDB02]&#x5B;oracle@db json]$ cat set_default_wallet_CDB02.json
{
  &quot;service&quot; : {
    &quot;category&quot; : &quot;manage-access&quot;,
    &quot;resource&quot; : &quot;wallet&quot;,
    &quot;action&quot; : &quot;set-default&quot;,
    &quot;options&quot; : {
      &quot;wallet&quot; : &quot;ORA_CLONES&quot;,
      &quot;endpoint&quot; : &quot;DB_CDB02&quot;,
      &quot;unique&quot; : &quot;FALSE&quot;
    }
  }
}

&#x5B;CDB02]&#x5B;oracle@db json]$ okv manage-access wallet set-default --from-json set_default_wallet_CDB02.json
{
  &quot;result&quot; : &quot;Success&quot;
}

# test 
&#x5B;CDB02]&#x5B;oracle@db json]$ $OKV_HOME/bin/okv manage-access wallet get-default --endpoint DB_CDB02
{
  &quot;result&quot; : &quot;Success&quot;,
  &quot;value&quot; : {
    &quot;defaultWallet&quot; : &quot;ORA_CLONES&quot;
  }
}

# list wallets access for endpoint DB_CDB02
&#x5B;CDB02]&#x5B;oracle@db json]$ $OKV_HOME/bin/okv manage-access wallet list-endpoint-wallets --endpoint DB_CDB02
{
  &quot;result&quot; : &quot;Success&quot;,
  &quot;value&quot; : {
    &quot;wallets&quot; : &#x5B; &quot;ORA_CLONES&quot;, &quot;ORA_DB&quot; ]
  }
}

</pre></div>


<h2 class="wp-block-heading" id="h-rekey-operation">REKEY operation </h2>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
&#x5B;CDB02]&#x5B;oracle@db json]$ sqlplus / as sysdba 

-- list all keys for CDB02
SQL&gt; set line 200
SQL&gt; col key_id format a40;
SQL&gt; select KEY_ID, KEYSTORE_TYPE,CREATION_TIME from V$ENCRYPTION_KEYS;

KEY_ID                                   KEYSTORE_TYPE	   CREATION_TIME
---------------------------------------- ----------------- ----------------------------
066477563C41354F9ABFFD71C439728D90	 OKV		   12-MAR-24 11.38.29.789446 AM +00:00
06389A1CCF31E64F17BFC1101D9700F83E	 OKV		   12-MAR-24 11.53.46.361951 AM +00:00
064A92E70C7DBB4FBCBFDE46A9226CFB0A	 OKV		   12-MAR-24 11.53.45.932774 AM +00:00
06FED2B8DA29444F57BF11BB545ED7E60D	 OKV		   12-MAR-24 11.20.59.949238 AM +00:00 

SQL&gt; ADMINISTER KEY MANAGEMENT SET ENCRYPTION KEY FORCE KEYSTORE IDENTIFIED BY &quot;endpoint_password&quot; container=all;

</pre></div>


<p class="wp-block-paragraph">Remove access from <code>CDB01</code> wallet:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
&#x5B;CDB02]&#x5B;oracle@db json]$ $OKV_HOME/bin/okv manage-access wallet remove-access --generate-json-input &gt; remove_access_walet_CDB02.json

&#x5B;CDB02]&#x5B;oracle@db json]$ cat remove_access_walet_CDB02.json
{
  &quot;service&quot; : {
    &quot;category&quot; : &quot;manage-access&quot;,
    &quot;resource&quot; : &quot;wallet&quot;,
    &quot;action&quot; : &quot;remove-access&quot;,
    &quot;options&quot; : {
      &quot;wallet&quot; : &quot;ORA_DB&quot;,
      &quot;endpoint&quot; : &quot;DB_CDB02&quot;
    }
  }
}

&#x5B;CDB02]&#x5B;oracle@db json]$ $OKV_HOME/bin/okv manage-access wallet remove-access --from-json remove_access_walet_CDB02.json
{
  &quot;result&quot; : &quot;Success&quot;
}

&#x5B;CDB02]&#x5B;oracle@db json]$ /opt/oracle/admin/CDB02/wallet/okv/bin/okvutil list
Enter Oracle Key Vault endpoint password:
Unique ID                               Type            Identifier
1B382343-A786-4F26-BFF9-35A8329A327C	Symmetric Key	TDE Master Encryption Key: MKID 0612F89A18C7984F27BF571A0420C58025
52B62409-6E8D-4F6F-BF08-F7DD73EC1938	Symmetric Key	TDE Master Encryption Key: MKID 06A9FD621A85A74F46BFD88BEB6082B9EB
2DE4025E-CF35-454D-9F60-33640DAAC067	Template	Default template for DB_CDB02

-- restart CDB02 to test if the database open withouth any issue
SQL&gt; startup force

SQL&gt; @$HOME/tde.sql

    PDB_ID PDB_NAME		GUID
---------- -------------------- --------------------------------
	 3 PDB01		0AE3AEC4EE5ACDB1E063A001A8ACB8BB
	 2 PDB$SEED		0AE38C7FF01EC651E063A001A8AC821E


WRL_TYPE    WRL_PARAMETER                       STATUS             WALLET_TYPE WALLET_OR KEYSTORE FULLY_BAC     CON_ID
----------- ----------------------------------- ------------------ ----------- --------- -------- --------- ----------
FILE        /opt/oracle/admin/CDB02/wallet/tde/ OPEN_NO_MASTER_KEY AUTOLOGIN   SINGLE      NONE       UNDEFINED          1
OKV                                             OPEN               OKV         SINGLE      NONE       UNDEFINED          1
FILE                                            OPEN_NO_MASTER_KEY AUTOLOGIN   SINGLE      UNITED     UNDEFINED          3
OKV                                             OPEN               OKV         SINGLE      NONE       UNDEFINED          3
</pre></div>


<p class="wp-block-paragraph">Database <code>CDB02</code> open correctly. </p>



<p class="wp-block-paragraph">List the accessible keys for <code>CDB02</code>:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
&#x5B;CDB02]&#x5B;oracle@db json]$ /opt/oracle/admin/CDB02/wallet/okv/bin/okvutil list
Enter Oracle Key Vault endpoint password:
Unique ID                               Type            Identifier
1B382343-A786-4F26-BFF9-35A8329A327C	Symmetric Key	TDE Master Encryption Key: MKID 0612F89A18C7984F27BF571A0420C58025
2DE4025E-CF35-454D-9F60-33640DAAC067	Template	Default template for DB_CDB02

</pre></div>


<p class="wp-block-paragraph">List the wallets accessible for <code>CDB02</code>:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
&#x5B;CDB02]&#x5B;oracle@db json]$ $OKV_HOME/bin/okv manage-access wallet list-endpoint-wallets --endpoint DB_CDB02
{
  &quot;result&quot; : &quot;Success&quot;,
  &quot;value&quot; : {
    &quot;wallets&quot; : &#x5B; &quot;ORA_CLONES&quot; ]
  }
}
</pre></div>


<p class="wp-block-paragraph">CDB02 has no more access to the CD01 wallet. </p>



<h2 class="wp-block-heading" id="h-conclusion">Conclusion</h2>



<p class="wp-block-paragraph">If the database is not configured with OKV, after a REKEY operation the wallet file, stored on local disk, must be saved. When the database is configured with OKV when a REKEY operation is issued we have to do &#8230;. nothing. The keys are automatically stored in OKV database without any intervention. Just only one remark. The endpoint, in our example <code>DB_CDB02</code>, need to have a default wallet configured. Otherwise the keys will not belongs to any wallet. That doesn&#8217;t mean that the CDB02 database cannot access them, but having keys outside wallets in OKV, increase the maintenance operations. </p>
<p>L’article <a href="https://www.dbi-services.com/blog/rekey-operation-on-oracle-database-configured-with-oracle-key-vault/">REKEY operation on Oracle Database configured with Oracle Key Vault</a> est apparu en premier sur <a href="https://www.dbi-services.com/blog">dbi Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbi-services.com/blog/rekey-operation-on-oracle-database-configured-with-oracle-key-vault/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Lazy Loading (feed)

Served from: www.dbi-services.com @ 2026-06-17 19:58:44 by W3 Total Cache
-->