<?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>Simon Krenger</title>
	<atom:link href="http://www.krenger.ch/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.krenger.ch</link>
	<description></description>
	<lastBuildDate>Fri, 17 May 2013 13:28:54 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>ORA-01031 on CREATE MATERIALIZED VIEW</title>
		<link>http://www.krenger.ch/blog/create-materialized-view-ora-01031/</link>
		<comments>http://www.krenger.ch/blog/create-materialized-view-ora-01031/#comments</comments>
		<pubDate>Fri, 17 May 2013 13:28:54 +0000</pubDate>
		<dc:creator>Simon Krenger</dc:creator>
				<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://www.krenger.ch/?p=2625</guid>
		<description><![CDATA[Ok, so here is a problem that a developer brought up. I thought that this problem is quite interesting and also a bit confusing. Obviously, according to Oracle, this is not a bug &#8211; it&#8217;s a feature! When issuing a CREATE MATERIALIZED VIEW statement for a different schema (as DBA), one might encounter the following [...]]]></description>
				<content:encoded><![CDATA[<p>Ok, so here is a problem that a developer brought up. I thought that this problem is quite interesting and also a bit confusing. Obviously, according to Oracle, this is not a bug &#8211; it&#8217;s a feature!</p>
<p>When issuing a <strong>CREATE MATERIALIZED VIEW statement for a different schema</strong> (as DBA), one might encounter the following error:</p>
<pre><code>dba@KDB01:SQL> CREATE MATERIALIZED VIEW simon.simon_mv AS SELECT * FROM dual;
CREATE MATERIALIZED VIEW simon.simon_mv AS SELECT * FROM dual
                                                         *
ERROR at line 1:
ORA-01031: insufficient privileges</code></pre>
<p><span id="more-2625"></span>For our setup let&#8217;s assume we have two users:</p>
<ul>
<li>User SIMONDBA (has the DBA privilege and is used to setup the DB server)</li>
<li>User SIMON (schema owner)</li>
</ul>
<p>We want to use the SIMONDBA user to create the objects for the schema SIMON. This is a standard approach to seperate the deployment user from the actual schema owner. So let&#8217;s create these two users and grant the privileges (DBA for the deployment user, CONNECT and RESOURCE for the schema owner):</p>
<pre><code>masterdba@KDB01:SQL> CREATE USER simondba IDENTIFIED BY tiger;

User created.

masterdba@KDB01:SQL> GRANT DBA TO simondba;

Grant succeeded.

masterdba@KDB01:SQL> CREATE USER simon IDENTIFIED BY tiger;

User created.

masterdba@KDB01:SQL> GRANT RESOURCE, CONNECT TO simon;

Grant succeeded.

masterdba@KDB01:SQL> ALTER USER simon QUOTA 100M ON users;

User altered.

masterdba@KDB01:SQL> GRANT CREATE MATERIALIZED VIEW TO simon;

Grant succeeded.</code></pre>
<p>So far, so good. The user SIMONDBA has all the privileges that come with the DBA role and the user SIMON has a limited set of privileges due to the RESOURCE and CONNECT roles. In addition to those roles, we want to grant CREATE MATERIALIZED VIEW to our schema owner.</p>
<p>Now let&#8217;s see what happens when we try to issue the statement as the deployment user (SIMONDBA):</p>
<pre><code>masterdba@KDB01:SQL> connect simondba@KDB01
Enter password:
Connected.
simondba@KDB01:SQL> CREATE MATERIALIZED VIEW simon.simon_mv AS SELECT * FROM dual;
CREATE MATERIALIZED VIEW simon.simon_mv AS SELECT * FROM dual
                                                         *
ERROR at line 1:
ORA-01031: insufficient privileges</code></pre>
<p>Err, what? I have the DBA privileges, so the problem must be that SIMON does not have the correct privileges! So let&#8217;s try with the user SIMON:</p>
<pre><code>simondba@KDB01:SQL> connect simon@KDB01
Enter password:
Connected.
simon@KDB01:SQL> CREATE MATERIALIZED VIEW simon_mv AS SELECT * FROM dual;

Materialized view created.</code></pre>
<p>Now the confusion is complete. Why can I create the materialized view while connected as SIMON, but not create the same view when connected as SIMONDBA? The user SIMONDBA has higher privileges than the user SIMON, so that should not happen! It turns out that this is a feature (at least according to Oracle).</p>
<p><strong>To solve the mystery, grant the CREATE TABLE privilege directly to SIMON</strong>:</p>
<pre><code>masterdba@KDB01:SQL> GRANT CREATE TABLE TO simon;

Grant succeeded.</code></pre>
<p>Now the CREATE MATERIALIZED VIEW statement works as expected:</p>
<pre><code>simondba@KDB01:SQL> CREATE MATERIALIZED VIEW simon.simon_mv AS SELECT * FROM dual;

Materialized view created.</code></pre>
<p>Now you might say: &#8220;But the RESOURCE role contains the CREATE TABLE privilege, why do I have to grant that privilege explicitly?&#8221;. That is correct and I have no answer for that&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krenger.ch/blog/create-materialized-view-ora-01031/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle InstantClient: TNSNAMES.ORA location</title>
		<link>http://www.krenger.ch/blog/oracle-instantclient-tnsnames-ora-location/</link>
		<comments>http://www.krenger.ch/blog/oracle-instantclient-tnsnames-ora-location/#comments</comments>
		<pubDate>Wed, 01 May 2013 21:06:15 +0000</pubDate>
		<dc:creator>Simon Krenger</dc:creator>
				<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Systems Engineering]]></category>
		<category><![CDATA[FAQ]]></category>
		<category><![CDATA[InstantClient]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[SQL*Plus]]></category>
		<category><![CDATA[TNSNAMES.ORA]]></category>
		<category><![CDATA[TNS_ADMIN]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Windows Server]]></category>

		<guid isPermaLink="false">http://www.krenger.ch/?p=2620</guid>
		<description><![CDATA[When you install the InstantClient binaries, you often want to use your existing TNSNAMES.ORA file containing all your databases. So how do you specify the location of your TNSNAMES.ORA file? The Oracle website has the answer: Always set the TNS_ADMIN environment variable or registry to the location of the tnsnames.ora file (full directory path only, [...]]]></description>
				<content:encoded><![CDATA[<p>When you install the <a href="http://www.oracle.com/technetwork/database/features/instant-client/index-100365.html">InstantClient</a> binaries, you often want to use your existing <a href="http://docs.oracle.com/cd/E11882_01/network.112/e10835/tnsnames.htm">TNSNAMES.ORA</a> file containing all your databases. So how do you <strong>specify the location of your TNSNAMES.ORA file</strong>?</p>
<p><span id="more-2620"></span>The <a href="http://www.oracle.com/technetwork/database/features/oci/ic-faq-094177.html#A5028">Oracle website has the answer</a>:</p>
<blockquote><p>Always set the TNS_ADMIN environment variable or registry to the location of the tnsnames.ora file (full directory path only, do not include the file name). This practice will ensure that you are using the appropriate tnsnames.ora for your application when running with Instant Client.</p></blockquote>
<p>So, for <strong>UNIX and Linux</strong> systems set the variable TNS_ADMIN like so in your <em>.profile</em> or <em>.bash_profile</em>:<br />
<code>export TNS_ADMIN=/opt/oracle/instantclient_11_2/</code></p>
<p>On <strong>Windows</strong> systems, set the environment variables via the Advanced System properties:</p>
<ul>
<li>Open CMD, enter <em>sysdm.cpl</em></li>
<li>In the Advanced tab, select <em>Environment Variables</em></li>
<li>Under &#8220;System Variables&#8221;, click on <em>New&#8230;</em> and enter &#8220;TNS_ADMIN&#8221; as the name and the path where your TNSNAMES.ORA resides as your value.</li>
</ul>
<p>Now, you can use your TNS names for your InstantClient, for example for SQL*Plus:<br />
<code>$ sqlplus simon@KDB01</code><br />
For more information on SQL*Plus configuration, please refer to the <a href="http://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_two.htm">Oracle documentation for SQL*Plus</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krenger.ch/blog/oracle-instantclient-tnsnames-ora-location/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Datapump with Database Link examples</title>
		<link>http://www.krenger.ch/blog/datapump-with-database-link-examples/</link>
		<comments>http://www.krenger.ch/blog/datapump-with-database-link-examples/#comments</comments>
		<pubDate>Fri, 22 Mar 2013 13:43:28 +0000</pubDate>
		<dc:creator>Simon Krenger</dc:creator>
				<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Datapump]]></category>
		<category><![CDATA[DB Link]]></category>
		<category><![CDATA[Migration]]></category>
		<category><![CDATA[Oracle Syntax]]></category>
		<category><![CDATA[Syntax]]></category>

		<guid isPermaLink="false">http://www.krenger.ch/?p=2557</guid>
		<description><![CDATA[Whenever one has to move large amounts of data from one database to another, storage space might become an issue. An option to circumvent this problem is to use a database link with Oracle Datapump to move the data from one database to another. This way, the data is exported across the network and imported [...]]]></description>
				<content:encoded><![CDATA[<p>Whenever one has to move large amounts of data from one database to another, storage space might become an issue. An option to circumvent this problem is to <strong>use a database link with Oracle Datapump to move the data from one database to another</strong>. This way, the data is exported across the network and imported directly into the target database.</p>
<p>In this post, I will <strong>provide an example</strong> on how to move data via a Oracle Datapump and a database link. This post is based on the excellent <a href="http://www.orafaq.com/wiki/Datapump#Network_import">entry in Oracle FAQ</a> and basically comments all the steps mentioned in the article.</p>
<p><span id="more-2557"></span><br />
<h3>Preparation</h3>
<p>Before we can export and import via a database link, we need to <strong>prepare the target database</strong>. First of all, on the new database, create a user with which you want to import a schema from another database. This step is optional if you want to move multiple schemas or use your DBA user to perform the import.</p>
<pre><code>SQL&gt; create user new_scott identified by tiger;
User created.

SQL&gt; grant connect, resource to new_scott;
Grant succeeded.

SQL&gt; grant read, write on directory MY_DMP_DIR to new_scott;
Grant succeeded.

SQL&gt; grant create database link to new_scott;
Grant succeeded.</code></pre>
<p>Now, <strong>create the database link</strong> which we will be using to perform the datapump import. If you are not sure about the syntax or how to create a database link, refer to the <a href="http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_5005.htm">Oracle documentation for &#8220;CREATE DATABASE LINK&#8221;</a>.</p>
<pre><code>SQL&gt; connect new_scott/tiger
Connected.

SQL&gt; create database link OLD_DB connect to scott identified by tiger  using 'olddb.krenger.ch';
Database link created.</code></pre>
<h3>Import one schema</h3>
<p>After creating the database link, you can then start the transfer using the <strong>standard</strong> &#8220;<strong>impdp</strong>&#8221; tools:<br />
<code>impdp new_scott/tiger directory=MY_DMP_DIR LOGFILE=dblink_transfer.log network_link=OLD_DB remap_schema=scott:new_scott<br />
</code><br />
Whereas I specified the following options:</p>
<table width="100%">
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
<tr>
<td>directory</td>
<td>The directory, where the logfile will be saved to</td>
</tr>
<tr>
<td>logfile</td>
<td>Name of the logfile (e.g. &#8220;dblink_transfer.log&#8221;)</td>
</tr>
<tr>
<td>network_link</td>
<td>The database link to be used for the import (created above using CREATE DATABASE LINK)</td>
</tr>
<tr>
<td>remap_schema</td>
<td>Specifies that the schema &#8220;scott&#8221; on the old database is imported into the schema &#8220;new_scott&#8221; on the new database</td>
</tr>
</table>
<h3>Import multiple schemas</h3>
<p>To import multiple schemas, I like to work with a user that has the DBA privilege:<br />
<code>impdp simondba@kdb01 directory=ADMIN_DUMP_DIR LOGFILE=dblink_transfer.log network_link=OLD_DB schemas=simon,scott,hr<br />
</code></p>
<table width="100%">
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
<tr>
<td>directory</td>
<td>The directory, where the logfile will be saved to</td>
</tr>
<tr>
<td>logfile</td>
<td>Name of the logfile (e.g. &#8220;dblink_transfer.log&#8221;)</td>
</tr>
<tr>
<td>network_link</td>
<td>The database link to be used for the import (created above using CREATE DATABASE LINK)</td>
</tr>
<tr>
<td>schemas</td>
<td>These schemas will be imported into the new database. Seperate by comma.</td>
</tr>
</table>
<p>For more information on the datapump import tool and its options, please refer to the <a href="http://docs.oracle.com/cd/E11882_01/server.112/e10701/dp_import.htm">Oracle documentation.</a> When importing data via a database link, the datapump import job is started on the target system (see <a href="http://docs.oracle.com/cd/E14072_01/server.112/e10820/statviews_3143.htm">DBA_DATAPUMP_JOBS</a>)</p>
<p>All work is performed on the target system. The only reference to the source systems is via the database link.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krenger.ch/blog/datapump-with-database-link-examples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mac OS X: Remote Desktop &#8220;/admin&#8221; switch</title>
		<link>http://www.krenger.ch/blog/mac-os-x-remote-desktop-admin-switch/</link>
		<comments>http://www.krenger.ch/blog/mac-os-x-remote-desktop-admin-switch/#comments</comments>
		<pubDate>Mon, 18 Mar 2013 06:28:26 +0000</pubDate>
		<dc:creator>Simon Krenger</dc:creator>
				<category><![CDATA[Systems Engineering]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[RDP]]></category>
		<category><![CDATA[Remote Desktop]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Windows Server]]></category>

		<guid isPermaLink="false">http://www.krenger.ch/?p=2584</guid>
		<description><![CDATA[In another post, a commenter asked how to resolve the &#8220;Windows Server: The terminal server has exceeded the maximum number of allowed connections&#8221; error when connecting from a Mac. It turns out you can connect to your server by adding &#8220;/console&#8221; to the end of the server name or IP. Thanks to Christian for his [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.krenger.ch/blog/windows-server-the-terminal-server-has-exceeded-the-maximum-number-of-allowed-connections/">In another post</a>, a commenter asked how to resolve the &#8220;<strong>Windows Server: The terminal server has exceeded the maximum number of allowed connections</strong>&#8221; error when connecting from a Mac.</p>
<p><span id="more-2584"></span><a href="http://www.krenger.ch/wp-content/uploads/2013/03/rdp-mac-console-switch.jpg"><img src="http://www.krenger.ch/wp-content/uploads/2013/03/rdp-mac-console-switch.jpg" alt="Mac: Remote Desktop Connection" width="517" height="168" class="aligncenter size-full wp-image-2587" /></a></p>
<p><strong>It turns out you can connect to your server by adding &#8220;/console&#8221; to the end of the server name or IP.</strong> Thanks to Christian for <a href="http://www.christiano.ch/wordpress/2009/08/04/microsoft-remote-desktop-connection-console-or-admin-session/">his post on the subject</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krenger.ch/blog/mac-os-x-remote-desktop-admin-switch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle DBMS_STATS.GATHER_SCHEMA_STATS example</title>
		<link>http://www.krenger.ch/blog/oracle-dbms_stats-gather_schema_stats-example/</link>
		<comments>http://www.krenger.ch/blog/oracle-dbms_stats-gather_schema_stats-example/#comments</comments>
		<pubDate>Wed, 30 Jan 2013 05:07:46 +0000</pubDate>
		<dc:creator>Simon Krenger</dc:creator>
				<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[DBMS_STATS]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[Oracle 11g]]></category>
		<category><![CDATA[Reference]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://www.krenger.ch/?p=2545</guid>
		<description><![CDATA[So here is another post I keep mainly for my own reference, since I regularly need to gather new schema statistics. The information here is based on the Oracle documentation for DBMS_STATS, where all the information is available. So if you want to COMPUTE the statistics (which means to actually consider every row and not [...]]]></description>
				<content:encoded><![CDATA[<p>So here is another post I keep mainly for my own reference, since I regularly need to <strong>gather new schema statistics</strong>. The information here is based on the <a href="http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_stats.htm#i1036456">Oracle documentation for DBMS_STATS</a>, where all the information is available.</p>
<p><span id="more-2545"></span>So if you want to <strong>COMPUTE the statistics</strong> (which means to actually consider every row and not just estimate the statistics), use the following syntax:</p>
<p><code>EXECUTE DBMS_STATS.GATHER_SCHEMA_STATS(ownname => 'SIMON', estimate_percent => NULL);</code></p>
<p>However, you can also just specify the name of the schema:</p>
<p><code>EXECUTE DBMS_STATS.GATHER_SCHEMA_STATS(ownname => 'SIMON');</code></p>
<p>This will use the constant <em>DBMS_STATS.AUTO_SAMPLE_SIZE</em> to have Oracle determine the appropriate sample size for good statistics. Find all other information (available parameters, usage) in the <a href="http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_stats.htm#i1036456">Oracle documentation</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krenger.ch/blog/oracle-dbms_stats-gather_schema_stats-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle NUMBER: Precision and scale</title>
		<link>http://www.krenger.ch/blog/oracle-number-precision-and-scale/</link>
		<comments>http://www.krenger.ch/blog/oracle-number-precision-and-scale/#comments</comments>
		<pubDate>Fri, 18 Jan 2013 08:01:12 +0000</pubDate>
		<dc:creator>Simon Krenger</dc:creator>
				<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Datatypes]]></category>
		<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.krenger.ch/?p=2528</guid>
		<description><![CDATA[So here is another post I keep for my own reference, since I keep forgetting about precision and scale, primarily which is which. The Oracle Concepts guide states that the NUMBER datatype stores fixed and floating-point numbers. A column with the NUMBER datatype can be defined as follows: column_name NUMBER (precision, scale) The precision defines [...]]]></description>
				<content:encoded><![CDATA[<p>So here is another post I keep for my own reference, since I keep forgetting about precision and scale, primarily which is which.</p>
<p>The <a href="//docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#i16209“">Oracle Concepts</a> guide states that the NUMBER datatype stores fixed and floating-point numbers. A column with the NUMBER datatype can be defined as follows:</p>
<p><span id="more-2528"></span><code>column_name NUMBER (precision, scale)</code></p>
<p>The <strong>precision</strong> defines the <strong>total number of digits</strong>.<br />
The <strong>scale</strong> defines the number of <strong>digits to the right of the decimal point</strong>.</p>
<p>If you specify a negative scale, Oracle Database rounds the actual data to the specified number of places to the left of the decimal point. For example, specifying (7,-2) means Oracle Database rounds to the nearest hundredths <a href="http://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#i16209">(source)</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krenger.ch/blog/oracle-number-precision-and-scale/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ORA-31001: Invalid resource handle or path name &#8220;/sys/acls/myacl.xml&#8221;</title>
		<link>http://www.krenger.ch/blog/ora-31001-invalid-resource-handle-or-path-name-sys-acls-myacl-xml/</link>
		<comments>http://www.krenger.ch/blog/ora-31001-invalid-resource-handle-or-path-name-sys-acls-myacl-xml/#comments</comments>
		<pubDate>Fri, 21 Dec 2012 07:56:40 +0000</pubDate>
		<dc:creator>Simon Krenger</dc:creator>
				<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[ORA-31001]]></category>
		<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Security Guide]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://www.krenger.ch/?p=2480</guid>
		<description><![CDATA[So this happens when you try to add a privilege to an ACL that does not exist: SQL&#62; EXEC DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE ('myacl.xml', 'SIMON', true, 'connect'); BEGIN DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE ('myacl.xml', 'SIMON', true, 'connect'); END; ERROR at line 1: ORA-31001: Invalid resource handle or path name "/sys/acls/myacl.xml" ORA-06512: at "SYS.DBMS_NETWORK_ACL_ADMIN", line 384 ORA-06512: at line 1 Oracle Database 11g [...]]]></description>
				<content:encoded><![CDATA[<p>So this happens when you try to add a privilege to an ACL that does not exist:<br />
<code>SQL&gt; EXEC DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE ('myacl.xml', 'SIMON', true, 'connect');<br />
BEGIN DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE ('myacl.xml', 'SIMON', true, 'connect'); END;<br />
<br />ERROR at line 1:<br />
ORA-31001: Invalid resource handle or path name "/sys/acls/myacl.xml"<br />
ORA-06512: at "SYS.DBMS_NETWORK_ACL_ADMIN", line 384<br />
ORA-06512: at line 1</code><br />
Oracle Database 11g introduced <strong>fine-grained access control</strong> to external network services using Access Control Lists (ACLs). This basically allows you to take control over which users access which network resources, regardless of package grants.<span id="more-2480"></span></p>
<p>In the Oracle Database Security Guide, <a href="http://docs.oracle.com/cd/B28359_01/network.111/b28531/authorization.htm#CIHDAJDJ">Oracle notes</a>:</p>
<blockquote><p>This feature enhances security for network connections because it restricts the external network hosts that a database user can connect to using the PL/SQL network utility packages such as UTL_TCP, UTL_SMTP, UTL_MAIL, UTL_HTTP, and UTL_INADDR. Otherwise, an intruder who gained access to the database could maliciously attack the network, because, by default, the PL/SQL utility packages are created with the EXECUTE privilege granted to PUBLIC users.</p></blockquote>
<h3>So how to fix ORA-31001?</h3>
<p>So why did you get an ORA-31001 error? The reason for this error is that the ACL you try to modify <strong>does not yet exist</strong>. To create such an ACL, use the <a href="http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_networkacl_adm.htm#BABEHFAG">DBMS_NETWORK_ACL_ADMIN</a> package and call the <a href="http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_networkacl_adm.htm#BABIGEGG">CREATE_ACL</a> procedure:</p>
<pre><code>BEGIN
  DBMS_NETWORK_ACL_ADMIN.CREATE_ACL (
    acl =&gt; 'myacl.xml',
    description =&gt; 'Network Access Control for SIMON',
    principal =&gt; 'SIMON',
    is_grant =&gt; TRUE,
    privilege =&gt; 'connect');
END;
/</code></pre>
<p>You can then <strong>check what ACLs you have already defined</strong> for your database using the following query:<br />
<code>SELECT any_path FROM resource_view WHERE any_path like '/sys/acls/%.xml';</code><br />
Since security is often a <strong>complicated matter</strong>, please make sure to read through the <a href="http://docs.oracle.com/cd/B28359_01/network.111/b28531/authorization.htm#CIHDAJDJ">Oracle documentation</a> before making any changes. You don&#8217;t want to have someone messing around with your database just because you mistakenly assigned a privilege to an unsecured schema owwner!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krenger.ch/blog/ora-31001-invalid-resource-handle-or-path-name-sys-acls-myacl-xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Service Wrapper 3.5.17 for Windows x64</title>
		<link>http://www.krenger.ch/blog/java-service-wrapper-3-5-17-for-windows-x64/</link>
		<comments>http://www.krenger.ch/blog/java-service-wrapper-3-5-17-for-windows-x64/#comments</comments>
		<pubDate>Fri, 14 Dec 2012 06:21:17 +0000</pubDate>
		<dc:creator>Simon Krenger</dc:creator>
				<category><![CDATA[Systems Engineering]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Service Wrapper]]></category>
		<category><![CDATA[Open Systems]]></category>
		<category><![CDATA[Tanuki]]></category>
		<category><![CDATA[Windows Server]]></category>

		<guid isPermaLink="false">http://www.krenger.ch/?p=2448</guid>
		<description><![CDATA[An anonymous commenter noticed that there was a new version of the Tanuki Service Wrapper available. So I hereby present the latest version of the wrapper. Merry christmas to all of you! As always, I don&#8217;t guarantee anything, so please note: Use this package at your own risk, I provide no support or guarantee that [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.krenger.ch/blog/java-service-wrapper-3-5-16-for-windows-x64/#comment-8759">An anonymous commenter noticed</a> that there was a new version of the Tanuki Service Wrapper available. So I hereby present the latest version of the wrapper. <strong>Merry christmas to all of you!</strong></p>
<p><span id="more-2448"></span>As always, I don&#8217;t guarantee anything, so please note:</p>
<blockquote><p>Use this package <strong>at your own risk</strong>, I provide no support or guarantee that this software works as advertised.</p>
<p>This software is provided &#8220;AS IS&#8221; and any expressed or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed.</p></blockquote>
<p>The following package includes the sources, the build log and all binary files for the Tanuki Java Service Wrapper 3.5.17 for Windows x64. To run the wrapper, the following three files from the archive are needed:</p>
<ul>
<li>bin/wrapper.exe</li>
<li>lib/wrapper.dll</li>
<li>lib/wrapper.jar</li>
</ul>
<p>For more information on the wrapper, please refer to the <a href="http://wrapper.tanukisoftware.com/doc/english/introduction.html">documentation provided</a> by Tanuki Software.</p>
<p><strong>Download: </strong><a href="http://www.krenger.ch/wp-content/uploads/2012/12/wrapper-windows-x86-64-3.5.17.zip">wrapper-windows-x86-64-3.5.17.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.krenger.ch/blog/java-service-wrapper-3-5-17-for-windows-x64/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Oracle 11g R2 response file example</title>
		<link>http://www.krenger.ch/blog/oracle-11g-r2-response-file-example/</link>
		<comments>http://www.krenger.ch/blog/oracle-11g-r2-response-file-example/#comments</comments>
		<pubDate>Fri, 07 Dec 2012 07:00:11 +0000</pubDate>
		<dc:creator>Simon Krenger</dc:creator>
				<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Automation]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Oracle 11g]]></category>
		<category><![CDATA[Oracle Enterprise Linux]]></category>
		<category><![CDATA[Oracle Universal Installer]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Unattended]]></category>

		<guid isPermaLink="false">http://www.krenger.ch/?p=1756</guid>
		<description><![CDATA[After installing the Operating System (in my case usually Red Hat Enterprise Linux or Oracle Enterprise Linux) and configuring all necessary parameters, one has to install the Oracle software. It is usually a good idea to use a response file to do this. There are a few reasons to use a response file: The installation [...]]]></description>
				<content:encoded><![CDATA[<p>After installing the Operating System (in my case usually Red Hat Enterprise Linux or Oracle Enterprise Linux) and configuring all necessary parameters, one has to <strong>install the Oracle software</strong>. It is usually a good idea to use a response file to do this.</p>
<p><span id="more-1756"></span>There are a few reasons to use a response file:</p>
<ul>
<li>The installation is reproducible (the most important point)</li>
<li>No X server is necessary when using a response file with the Oracle Universal Installer (OUI)</li>
<li>The installation is easily scriptable</li>
<li>Strictly enforcing the OFA or other policies on all hosts is much easier</li>
</ul>
<p>So after extracting the archive with the software downloaded from the Oracle website, we usually find an <strong>example response file</strong> in the &#8220;<em>response/</em>&#8221; folder of the software package. So here is an example of a response file:<br />
<code>oracle.install.option=INSTALL_DB_SWONLY<br />
UNIX_GROUP_NAME=oinstall<br />
INVENTORY_LOCATION=/home/oracle/oraInventory<br />
SELECTED_LANGUAGES=en<br />
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1<br />
ORACLE_BASE=/u01/app/oracle<br />
oracle.install.db.InstallEdition=EE<br />
oracle.install.db.DBA_GROUP=dba<br />
oracle.install.db.OPER_GROUP=dba<br />
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false<br />
DECLINE_SECURITY_UPDATES=true</code></p>
<p>Note that this is a <strong>very minimalistic response file</strong>, where only the software is installed (no database is created). Please refer to the <a href="http://docs.oracle.com/cd/E11882_01/install.112/e24321/app_nonint.htm">Oracle documentation</a> and the response file that Oracle provides as part of their software delivery package.</p>
<p>To install the software, execute the &#8220;<em>runInstaller</em>&#8221; script with the parameters &#8220;<strong>-silent -reponseFile
<path_to_file></strong>&#8220;. See <a href="http://www.krenger.ch/blog/11g-silent-installation-error/">this post</a> for more information on the syntax.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krenger.ch/blog/oracle-11g-r2-response-file-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nagios: Simple Oracle Check</title>
		<link>http://www.krenger.ch/blog/nagios-simple-oracle-check/</link>
		<comments>http://www.krenger.ch/blog/nagios-simple-oracle-check/#comments</comments>
		<pubDate>Wed, 28 Nov 2012 17:10:17 +0000</pubDate>
		<dc:creator>Simon Krenger</dc:creator>
				<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Systems Engineering]]></category>
		<category><![CDATA[BASH]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[SQL*Plus]]></category>

		<guid isPermaLink="false">http://www.krenger.ch/?p=2356</guid>
		<description><![CDATA[For Nagios, many, many Oracle plugins are available for checking database availability and performance. But if you just want to check if the instance is up and running (and not add more complexity), you can use the simple script provided here. In an earlier post, I showed how to install SQL*Plus on Debian and based [...]]]></description>
				<content:encoded><![CDATA[<p>For Nagios, <a href="http://exchange.nagios.org/directory/Plugins/Databases/Oracle">many, many Oracle plugins are available</a> for <strong>checking database availability</strong> and performance. But if you just want to check if the instance is up and running (and not add more complexity), you can use the simple script provided here.</p>
<p><span id="more-2356"></span>In an earlier post, I showed <a href="http://www.krenger.ch/blog/sqlplus-on-debian/">how to install SQL*Plus on Debian</a> and based on that tutorial, I wrote a little shell script to query a database (I called it check_oracle_dual.sh):</p>
<pre><code>#!/bin/bash

ORACLE_INSTANTCLIENT_FOLDER=/opt/oracle/instantclient_11_2/
ORACLE_SQLPLUS_BINARY=sqlplus

ORACLE_USERNAME=
ORACLE_PASSWORD=
HOST=
INSTANCE=test01
ASSYSDBA=0

VERBOSE=0

usage() {
cat << EOF
usage: $0 -h <host> -u <username> -p <password> [-i <SID>] [-s] [-v]

This script connects to the specified Oracle instance and executes a simple
statement. If that statement succeeds, the script returns 0.

OPTIONS:
   -h      Specify the host (required)
   -u      Oracle username (required)
   -p      Oracle password for the user (required)
   -i      SID of the instance (default: test01)
   -s      Force login AS SYSDBA
   -v      Verbose
EOF
}


while getopts "u:p:i:h:vs" OPTION; do
        case $OPTION in
                u)
                        ORACLE_USERNAME=$OPTARG
                        ;;
                p)
                        ORACLE_PASSWORD=$OPTARG
                        ;;
                i)
                        INSTANCE=$OPTARG
                        ;;
                v)
                        VERBOSE=1
                        ;;
                h)
                        HOST=$OPTARG
                        ;;
                s)
                        ASSYSDBA=1
                        ;;
                ?)
                        usage
                        exit 1
                        ;;
        esac
done

if [ -z "$ORACLE_USERNAME" ]; then
        echo "You must specify a username (-u)!"
        usage
        exit 1
fi


if [ -z "$ORACLE_PASSWORD" ]; then
        echo "You must specify a password (-p)!"
        usage
        exit 1
fi


if [ -z "$HOST" ]; then
        echo "You must specify a host (-h)!"
        usage
        exit 1
fi

if [[ "$ORACLE_USERNAME" == "sys" || "$ORACLE_USERNAME" == "SYS" ]]; then
        ASSYSDBA=1
fi

export LD_LIBRARY_PATH=$ORACLE_INSTANTCLIENT_FOLDER
export ORACLE_SID=$INSTANCE

CONNECT_STRING=$(echo $ORACLE_USERNAME/$ORACLE_PASSWORD@$HOST/$INSTANCE)

if [ $ASSYSDBA -eq 1 ]; then
        CONNECT_STRING="$CONNECT_STRING AS SYSDBA"
fi

SPOUT=$($ORACLE_INSTANTCLIENT_FOLDER/$ORACLE_SQLPLUS_BINARY -S "$CONNECT_STRING" << EOF
SET ECHO OFF
SET HEADING OFF
SELECT to_char(sysdate,'yyyy-mm-dd') FROM dual;
EOF
)

if [ $? -eq 0 ]; then
        TRIMMED=$(echo $SPOUT)
        echo "OK: $ORACLE_USERNAME@$INSTANCE, sysdate='$TRIMMED'"
        if [ $VERBOSE -eq 1 ]; then
                echo "| host=$HOST, username=$ORACLE_USERNAME, instance=$INSTANCE, as_sysdba=$ASSYSDBA"
        fi
        exit 0
else
        # Remove the \n from the output of SQL*Plus
        SPOUT=$(echo $SPOUT | tr '\n' ' ')
        echo "ERROR: sqlplus returned $? : $SPOUT"
        echo " | CONNECT_STRING=$CONNECT_STRING"
        exit 2
fi</code></pre>
<p><strong>Save this script</strong> (usually, you put it in the Nagios plugin folder, <em>/usr/lib/nagios/plugins/</em> in my case) and use chmod to make it executable (<em>chmod +x check_oracle_dual.sh</em>).</p>
<p>Then, define a new command in your Nagios configuration file (more information on <a href="http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html">Nagios configuration here</a>):</p>
<pre><code>define command{
        command_name    check_oracle_dual
        command_line    $USER1$/check_oracle_dual.sh -v -h $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ $ARG3$
}
</code></pre>
<p>After adding the command definition, <strong>add the service to an existing host</strong> like this (this queries the instance "dev01" on host "mydbhost" using the credentials "scott/tiger"):</p>
<pre><code>define service {
    use                     generic-service
    host_name               mydbhost
    service_description     Oracle Instance Query
    check_command           check_oracle_dual!scott!tiger!-i dev01
}
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.krenger.ch/blog/nagios-simple-oracle-check/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
