<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Oracle DBA in KSA</title>
	<atom:link href="http://ksadba.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://ksadba.wordpress.com</link>
	<description>Living &#38; Working in Kingdom of Saudi Arabia</description>
	<lastBuildDate>Tue, 03 Jan 2012 03:07:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='ksadba.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Oracle DBA in KSA</title>
		<link>http://ksadba.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://ksadba.wordpress.com/osd.xml" title="Oracle DBA in KSA" />
	<atom:link rel='hub' href='http://ksadba.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Oracle Pipelined Function for DBMS_SPACE.FREE_USAGE</title>
		<link>http://ksadba.wordpress.com/2011/06/27/oracle-pipelined-function-for-dbms_space-free_usage/</link>
		<comments>http://ksadba.wordpress.com/2011/06/27/oracle-pipelined-function-for-dbms_space-free_usage/#comments</comments>
		<pubDate>Mon, 27 Jun 2011 08:10:39 +0000</pubDate>
		<dc:creator>ksadba</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[dbms_space]]></category>
		<category><![CDATA[Pipelined Function]]></category>

		<guid isPermaLink="false">http://ksadba.wordpress.com/?p=424</guid>
		<description><![CDATA[This is a pipelined function to show dbms_space.space_usage output in a table instead of using dbms_output. dbms_space.space_usage will show you the details of blocks between LHWM (Low High Water Mark) and HHWM (High High Water Mark). Based on the output of this function, you can decide whether to shrink the segment or not. There are [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ksadba.wordpress.com&amp;blog=3930725&amp;post=424&amp;subd=ksadba&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is a pipelined function to show <b>dbms_space.space_usage</b> output in a table instead of using dbms_output.<br />
<br />
dbms_space.space_usage will show you the details of blocks between <b>LHWM</b> (Low High Water Mark) and <b>HHWM</b> (High High Water Mark). Based on the output of this function, you can decide whether to shrink the segment or not.</p>
<p>There are many online resources to explain pipelined functions so I will not do this here.</p>
<p>Here is the code:<br />
</p>
<p><font size="5" face="courier new"><br />
<pre class="brush: css;">
-- create object
create type space_usage_object as object 
(
   Segment_owner varchar2(30),
   segment_name varchar2(30),
   segment_type varchar2(30),
   partition_name varchar2(30),
   blocks_unformatted number,
   bytes_unformatted number,
   
   blocks_0_25 number,
   bytes_0_25 number,   

   blocks_25_50 number,
   bytes_25_50 number,   
   
   blocks_50_75 number,
   bytes_50_75 number,   
   
   blocks_75_100 number,
   bytes_75_100 number,            
   
   blocks_full number,
   bytes_full number
);


-- create type
CREATE TYPE space_usage_type AS TABLE OF space_usage_object;   

-- pipelined function
create or replace FUNCTION SPACE_USAGE (
  in_segment_owner        IN  VARCHAR2 ,
  in_segment_name  IN  VARCHAR2 ,
  in_segment_type  IN  VARCHAR2 ,
  in_partition_name       IN  VARCHAR2 := null)
  RETURN space_usage_type PIPELINED AS

 v_unformatted_blocks number;
 v_unformatted_bytes number;
 v_fs1_blocks number;
 v_fs1_bytes number;
 v_fs2_blocks number;
 v_fs2_bytes number;
 v_fs3_blocks number;
 v_fs3_bytes number;
 v_fs4_blocks number;
 v_fs4_bytes number;
 v_full_blocks number;
 v_full_bytes number;
 
 
begin


  dbms_space.space_usage(segment_owner =&gt; in_segment_owner,
                        segment_name =&gt; in_segment_name,
                        segment_type =&gt; in_segment_type,  
                        unformatted_blocks =&gt; v_unformatted_blocks, 
                        unformatted_bytes =&gt; v_unformatted_bytes,
                        fs1_blocks =&gt; v_fs1_blocks, 
                        fs1_bytes =&gt; v_fs1_bytes,
                        fs2_blocks =&gt; v_fs2_blocks,
                        fs2_bytes =&gt; v_fs2_bytes,
                        fs3_blocks =&gt; v_fs3_blocks,
                        fs3_bytes =&gt; v_fs3_bytes,
                        fs4_blocks =&gt; v_fs4_blocks, 
                        fs4_bytes =&gt; v_fs4_bytes,
                        full_blocks =&gt; v_full_blocks, 
                        full_bytes =&gt; v_full_bytes,
                        partition_name =&gt;  in_partition_name);
                        
  pipe row (space_usage_object (in_segment_owner, in_segment_name, in_segment_type, in_partition_name,
                              v_unformatted_blocks , v_unformatted_bytes, 
 v_fs1_blocks, v_fs1_bytes, v_fs2_blocks,  v_fs2_bytes,  v_fs3_blocks, 
 v_fs3_bytes, v_fs4_blocks , v_fs4_bytes , v_full_blocks , v_full_bytes ));

  RETURN ;
END;


-- selecting 
select * from table(space_usage ('OWNER', 'SEGMENT_NAME', 'SEGMENT_TYPE'));

</pre><br />
</font></p>
<p><em><br />
Hazem Ameen<br />
Senior Oracle DBA<br />
</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ksadba.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ksadba.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ksadba.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ksadba.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ksadba.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ksadba.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ksadba.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ksadba.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ksadba.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ksadba.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ksadba.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ksadba.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ksadba.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ksadba.wordpress.com/424/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ksadba.wordpress.com&amp;blog=3930725&amp;post=424&amp;subd=ksadba&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ksadba.wordpress.com/2011/06/27/oracle-pipelined-function-for-dbms_space-free_usage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eda39a036b3ab7f1ff7462687db4c6f2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ksadba</media:title>
		</media:content>
	</item>
		<item>
		<title>Bulk Deletion Performance with Foreign Keys Constraints (on delete cascade)</title>
		<link>http://ksadba.wordpress.com/2011/03/29/bulk-deletion-performance-with-foreign-keys-constraints-on-delete-cascade/</link>
		<comments>http://ksadba.wordpress.com/2011/03/29/bulk-deletion-performance-with-foreign-keys-constraints-on-delete-cascade/#comments</comments>
		<pubDate>Tue, 29 Mar 2011 12:50:30 +0000</pubDate>
		<dc:creator>ksadba</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Foreign Keys]]></category>
		<category><![CDATA[TX Locks]]></category>

		<guid isPermaLink="false">http://ksadba.wordpress.com/?p=351</guid>
		<description><![CDATA[The purpose of this post is to discourage DBAs from creating “Enabled” foreign keys on tables that are expected to have bulk operations.  I still suggest to create foreign keys but disable them so designers, DBAs and developers will still know which tables are related. Our test cases were run in our development environment which [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ksadba.wordpress.com&amp;blog=3930725&amp;post=351&amp;subd=ksadba&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The purpose of this post is to discourage DBAs from creating “Enabled” foreign keys on tables that are expected to have bulk operations.  I still suggest to create foreign keys but disable them so designers, DBAs and developers will still know which tables are related.</p>
<p>Our test cases were run in our development environment which is 10.2.0.5 RAC sitting on HP Itanium.</p>
<p>The target was to delete a few million rows from 2 tables which were related 1 to many with an enabled foreign key  “on delete cascade”.</p>
<p>The initial plan was simple:</p>
<p>1)      Delete from child table first so we can eliminate lookups from parent to child.</p>
<p>2)      Delete from parent .</p>
<p>3)      Use a nice parallel hint for both steps.</p>
<p>We tested our plan with about 35,000 rows.</p>
<p>First step went fine, but second step the query went for a long time, when we checked, we found that query is waiting for <strong>TX Lock</strong> even though we executed the query in the same session.</p>
<p>Why wait for TX Lock in the same session?</p>
<p>This is because the first query was using a parallel hint which created parallel sessions.  These parallel sessions locked the rows in the child table. You couldn&#8217;t move forward unless we issue a commit.</p>
<p>You can also produce the same behavior in a single instance environment without using any parallelism by doing the following simple steps:</p>
<p>1)      Delete child row</p>
<p>2)      Create a new session and then delete the parent row.</p>
<p>The deletion of the parent row will hang until you commit in the child row.<br />
&nbsp;</p>
<p><strong>Foreign Keys Performance</strong></p>
<p><em>The following test cases were executed for about 35,000 rows. Every time we delete, we copy the data back.</em></p>
<p>We deleted child data first, committed and then deleted from parent table, it took 75 seconds</p>
<p>We deleted directly from parent table, it took 75 seconds <em>(apparently there is no gain from deleting from child table first then deleting from parent table, bummer!)</em></p>
<p>We disabled foreign keys, delete from child, then delete from parent, <strong>total time was 12 seconds only, 6 times as fast</strong>.</p>
<p>&nbsp;</p>
<p><strong>Conclusion</strong></p>
<p>Foreign Keys are excellent for ERD diagrams and remind everybody which tables are related, but physically disable them and you should live happily every after.<br />
&nbsp;<br />
<em>Hazem Ameen<br />
Senior Oracle DBA</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ksadba.wordpress.com/351/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ksadba.wordpress.com/351/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ksadba.wordpress.com/351/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ksadba.wordpress.com/351/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ksadba.wordpress.com/351/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ksadba.wordpress.com/351/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ksadba.wordpress.com/351/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ksadba.wordpress.com/351/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ksadba.wordpress.com/351/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ksadba.wordpress.com/351/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ksadba.wordpress.com/351/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ksadba.wordpress.com/351/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ksadba.wordpress.com/351/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ksadba.wordpress.com/351/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ksadba.wordpress.com&amp;blog=3930725&amp;post=351&amp;subd=ksadba&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ksadba.wordpress.com/2011/03/29/bulk-deletion-performance-with-foreign-keys-constraints-on-delete-cascade/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eda39a036b3ab7f1ff7462687db4c6f2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ksadba</media:title>
		</media:content>
	</item>
		<item>
		<title>Oracle Date, Timestamp &amp; Time Zone Explained</title>
		<link>http://ksadba.wordpress.com/2011/02/14/oracle-date-timestamp-time-zone-explained/</link>
		<comments>http://ksadba.wordpress.com/2011/02/14/oracle-date-timestamp-time-zone-explained/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 09:14:39 +0000</pubDate>
		<dc:creator>ksadba</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Date]]></category>
		<category><![CDATA[Time Zone]]></category>
		<category><![CDATA[Timestamp]]></category>

		<guid isPermaLink="false">http://ksadba.wordpress.com/?p=313</guid>
		<description><![CDATA[Back in 9i Oracle introduced a new data type called Timestamp. Timestamp data type adds two new parts to the regular “Date” data type: Fraction of a second in microseconds ( 6 digits) Time Zone (shown only on selected functions like systimestamp and current_timestamp and shown on data types such as “Timestamp with time zone”) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ksadba.wordpress.com&amp;blog=3930725&amp;post=313&amp;subd=ksadba&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Back in 9i Oracle introduced a new data type called Timestamp.</p>
<p>Timestamp data type adds two new parts to the regular “Date” data type:</p>
<ol>
<li>Fraction of a second in microseconds <em>( 6 digits)</em> </li>
<li>Time Zone <em>(shown only on selected functions like systimestamp and current_timestamp and shown on data types such as “Timestamp with time zone”) </em></li>
</ol>
<p>Break down of Timestamp: <strong>2/9/2011 10:39:36.802604 AM +03:00</strong><br />
&#8220;2/9/2011 10:39:36&#8243; is exactly like older Date date type.<br />
&#8220;802604&#8243; is a fraction of seconds only shows only in timestamp data types.<br />
&#8220;+03:00&#8243; is Riyadh Time Zone.</p>
<p><strong><em>Why do I need a fraction of a second in my date, isn’t seconds enough?</em></strong></p>
<p>For most applications, up to second precision is enough, but some applications do require microseconds.</p>
<p>Applications like trading, biding such as eBay, and some physics applications were the operations start and finish in microseconds can benefit from timestamp.</p>
<p><strong><em>What is Time Zone?</em></strong></p>
<p>The actual definition you find it here <a href="http://en.wikipedia.org/wiki/Time_zone">http://en.wikipedia.org/wiki/Time_zone</a></p>
<p>Time Zone are like EST (Eastern Standard Time) or CST (Central Standard Time), etc… is determined by how far you are from Greenwich Line.</p>
<p>Here in Riyadh we are UTC + 3.00</p>
<p><em> </em></p>
<p><strong><em>Do I need Time Zone?</em></strong></p>
<p>Applications that gets deployed across multiple time zones will benefit from this feature greatly. Worldwide internet applications with one central database  or replicated worldwide databases  are some of application that utilize Time Zone. Prior to this Time Zone feature, we had to create a Date column that hold  database server date/time with database server time zone and an additional Date column that holds date/time with client’s time zone. Lots of manual conversion (not to forget Day Light Saving Time!). A time zone mess in short.</p>
<p>Here is a table that shows Timestamp data type compared to the older Date data type.</p>
<p><em> </em></p>
<p><em> </em></p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="213" valign="top"><strong>Date</strong></td>
<td width="213" valign="top"><strong>Equivalent Timestamp</strong></td>
<td width="213" valign="top"><strong>Explanation</strong></td>
</tr>
<tr>
<td width="213" valign="top">sysdate</td>
<td width="213" valign="top">systimestamp</td>
<td width="213" valign="top">System clock on the database server.</td>
</tr>
<tr>
<td width="213" valign="top">current_date</td>
<td width="213" valign="top">current_timestamp</td>
<td width="213" valign="top">Will show date/time in client time zone. If client’s time zone changes,  then output of these functions will   change accordingly. “current_timestamp” will show time zone part</td>
</tr>
<tr>
<td width="213" valign="top"></td>
<td width="213" valign="top">localtimestamp</td>
<td width="213" valign="top">Will show timestamp in client’s time zone. If client’s time zone   changes, then output of this function will change accordingly. This function will NOT show time zone as part of the output.</td>
</tr>
<tr>
<td colspan="3" width="638" style="text-align:center;">
<h2><span style="font-weight:bold;">Data Types</span></h2>
</td>
</tr>
<tr>
<td width="213" valign="top">Date</td>
<td width="213" valign="top">Timestamp</td>
<td width="213" valign="top">System clock on the database server.</td>
</tr>
<tr>
<td width="213" valign="top"><em>No Equivalent</em></td>
<td width="213" valign="top">Timestamp with Time Zone</td>
<td width="213" valign="top">Saves timestamp in client time zone. If client time zone changes, the saved value will NOT be converted to   new time zone. This data type will show time zone as part of the output.</td>
</tr>
<tr>
<td width="213" valign="top"><em>No Equivalent</em></td>
<td width="213" valign="top">Timestamp with Local Time Zone</td>
<td width="213" valign="top">Saves timestamp in client time zone. When selected back, the value shown to user will be converted to client’s current time zone. That means, if client’s time zone changes, then value shown to user will be converted to new time zone. This data type will NOT show time zone as part of the output.</td>
</tr>
</tbody>
</table>
<p>&nbsp;<br />
<strong><em>How can I know my database time zone?</em></strong><br />
SELECT dbtimezone FROM DUAL;<br />
<strong><em> </em></strong></p>
<p>&nbsp;<br />
<strong><em>How to know client’s time zone?</em></strong><br />
SELECT sessiontimezone FROM DUAL;<br />
<strong><em> </em></strong></p>
<p>&nbsp;<br />
<strong><em>How to change database time zone?</em></strong><br />
ALTER DATABASE SET TIME_ZONE = &#8216;+03:00&#8242;;</p>
<p>Then restart the database.<br />
&nbsp;<br />
<strong><em>How to change client time zone?</em></strong><br />
ALTER DATABASE SET TIME_ZONE=&#8217;+03:00&#8242;;</p>
<p>OR by using a named region<br />
ALTER DATABASE SET TIME_ZONE=&#8217;Asia/Riyadh&#8217;;<br />
&nbsp;</p>
<p>This later “alter” will change current_timestamp  output to :<br />
13-FEB-11 11.54.19.985565000 AM ASIA/RIYADH</p>
<p>OR by using environment variables</p>
<p>export ORA_SDTZ=&#8217;+05:00&#8242;</p>
<p>&nbsp;<br />
<strong><em>How to initially set up your database time zone?</em></strong><br />
CREATE DATABASE testdb<br />
. . .<br />
. . .<br />
SET TIME_ZONE=&#8217;+03:00&#8242;;</p>
<p>&nbsp;<br />
<strong><em>Where can I find a list of all time zones?</em></strong><br />
Look up this view: V$TIMEZONE_NAMES</p>
<p>Hope this helps.<br />
&nbsp;<br />
&nbsp;<br />
<em>Hazem Ameen</em><br />
<em>Senior Oracle DBA</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ksadba.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ksadba.wordpress.com/313/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ksadba.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ksadba.wordpress.com/313/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ksadba.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ksadba.wordpress.com/313/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ksadba.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ksadba.wordpress.com/313/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ksadba.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ksadba.wordpress.com/313/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ksadba.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ksadba.wordpress.com/313/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ksadba.wordpress.com/313/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ksadba.wordpress.com/313/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ksadba.wordpress.com&amp;blog=3930725&amp;post=313&amp;subd=ksadba&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ksadba.wordpress.com/2011/02/14/oracle-date-timestamp-time-zone-explained/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eda39a036b3ab7f1ff7462687db4c6f2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ksadba</media:title>
		</media:content>
	</item>
		<item>
		<title>Insert Append vs CTAS “Create Table as Select” to Copy Data</title>
		<link>http://ksadba.wordpress.com/2011/01/04/insert-append-vs-ctas-%e2%80%9ccreate-table-as-select%e2%80%9d-to-copy-data/</link>
		<comments>http://ksadba.wordpress.com/2011/01/04/insert-append-vs-ctas-%e2%80%9ccreate-table-as-select%e2%80%9d-to-copy-data/#comments</comments>
		<pubDate>Tue, 04 Jan 2011 10:51:45 +0000</pubDate>
		<dc:creator>ksadba</dc:creator>
				<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://ksadba.wordpress.com/?p=291</guid>
		<description><![CDATA[Some of the most basic tasks a DBA is asked to do, is to move data across schemas or tablespaces. This post compares 2 famous options: CTAS and Insert with append hint. Our comparison revealed that parallel CTAS is about 50% faster than Insert Append. Test Details: Table: 2 GB approx, no LOBs, source and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ksadba.wordpress.com&amp;blog=3930725&amp;post=291&amp;subd=ksadba&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Some of the most basic tasks a DBA  is asked to do, is to move data across schemas or tablespaces. This post compares 2 famous options:  CTAS and Insert with append hint. Our comparison revealed that parallel CTAS is about 50% faster than Insert Append.</p>
<p><strong>Test Details:</strong><br />
Table:  2 GB approx, no LOBs, source and target tables are not partitioned<br />
Oracle version: 10.2.0.4 installed on HP Itanium with 4 CPUs<br />
Instance: Single instance ( no RAC), database in noarchive mode<br />
File System: UFS</p>
<p>Here are the test results:</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td colspan="3" width="877" valign="top">
<p style="text-align:center;"><strong>Insert Append Test Cases</strong></p>
</td>
</tr>
<tr>
<td width="148" valign="top"><strong>Test Case</strong></td>
<td width="573" valign="top"><strong>SQL</strong></td>
<td width="156" valign="top"><strong>Exec in Secs</strong></td>
</tr>
<tr>
<td width="148" valign="top">no append</td>
<td width="573" valign="top">insert into dest select * from source1;&nbsp;</p>
<p>&nbsp;</td>
<td width="156" valign="top">189</td>
</tr>
<tr>
<td width="148" valign="top"><strong>append</strong></td>
<td width="573" valign="top">insert <strong><span style="color:#00ff00;"><em>/*+   append  */ </em></span></strong>into dest select * from source1;&nbsp;</p>
<p>&nbsp;</td>
<td width="156" valign="top">87</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td colspan="3" width="877" valign="top">
<p style="text-align:center;"><strong>CTAS Test Cases</strong></p>
</td>
</tr>
<tr>
<td width="148" valign="top"><strong>Test Case</strong></td>
<td width="573" valign="top"><strong>SQL</strong></td>
<td width="156" valign="top"><strong>Exec in Secs</strong></td>
</tr>
<tr>
<td width="148" valign="top">CTAS, no parallel</td>
<td width="573" valign="top">create table dest  as select * from source1;&nbsp;</p>
<p>&nbsp;</td>
<td width="156" valign="top">93</td>
</tr>
<tr>
<td width="148" valign="top">CTAS Parallel</td>
<td width="573" valign="top">alter session   force parallel ddl parallel 3;<br />
&nbsp;<br />
alter session   force parallel query parallel 3;&nbsp;<br />
create table dest  as select * from source1;&nbsp;</p>
<p>&nbsp;</td>
<td width="156" valign="top">
<h1><span style="color:#ff0000;"><strong>44</strong></span></h1>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;<br />
<em>Hazem Ameen</em><br />
<em>Senior Oracle DBA</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ksadba.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ksadba.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ksadba.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ksadba.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ksadba.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ksadba.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ksadba.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ksadba.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ksadba.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ksadba.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ksadba.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ksadba.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ksadba.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ksadba.wordpress.com/291/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ksadba.wordpress.com&amp;blog=3930725&amp;post=291&amp;subd=ksadba&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ksadba.wordpress.com/2011/01/04/insert-append-vs-ctas-%e2%80%9ccreate-table-as-select%e2%80%9d-to-copy-data/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eda39a036b3ab7f1ff7462687db4c6f2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ksadba</media:title>
		</media:content>
	</item>
		<item>
		<title>Data Scrambling in Oracle (including Arabic)</title>
		<link>http://ksadba.wordpress.com/2010/08/21/data-scrambling-in-oracle-including-arabic/</link>
		<comments>http://ksadba.wordpress.com/2010/08/21/data-scrambling-in-oracle-including-arabic/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 11:33:12 +0000</pubDate>
		<dc:creator>ksadba</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Scramble]]></category>

		<guid isPermaLink="false">http://ksadba.wordpress.com/?p=256</guid>
		<description><![CDATA[A regular part of a DBA job is moving production data to development environment. This sometimes poses a challenge as how to protect sensitive production data without spending more time more than you have to or buying or 3rd party tool to generate random values to replace existing sensitive production data. This post discusses an idea [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ksadba.wordpress.com&amp;blog=3930725&amp;post=256&amp;subd=ksadba&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A regular part of a DBA job is moving production data to development environment. This sometimes poses a challenge as how to protect sensitive production data without spending more time more than you have to or buying or 3<sup>rd</sup> party tool to generate random values to replace existing sensitive production data. This post discusses an idea we are currently using in our development environment.</p>
<p>Before detailing our scrambling solution, here is a common question: What is the difference between encryption and scrambling.</p>
<p>Here are some of these differences:</p>
<table border="1" cellspacing="0" cellpadding="3" width="700">
<tbody>
<tr>
<td bgcolor="#000000"><font color="#ffffff"><strong>Encryption</strong></font></td>
<td bgcolor="#000000"><font color="#ffffff"><strong>Scrambling</strong></font></td>
</tr>
<tr>
<td width="306" valign="top">Encryption is an algorithm applied to data usually you would need an   encryption key along with Oracle built-in packages</td>
<td width="306" valign="top">Replace existing characters or numbers with another character. The   end result is same string size but with different characters.</td>
</tr>
<tr>
<td width="306" valign="top">Support for Encryption is built in Oracle</td>
<td width="306" valign="top">Not built in Oracle. You have to develop your own.</td>
</tr>
<tr>
<td width="306" valign="top">Reversible.</td>
<td width="306" valign="top">Irreversible.</td>
</tr>
<tr>
<td width="306" valign="top">Encrypted column require an increase in size for DES, 3DES, 3DES encryptions</td>
<td width="306" valign="top">Same size.</td>
</tr>
<tr>
<td width="306" valign="top">Application needs to be aware of encrypted columns so data can be   encrypted/unencrypted</td>
<td width="306" valign="top">Application doesn’t need to be aware of it.</td>
</tr>
<tr>
<td width="306" valign="top">Suitable for production</td>
<td width="306" valign="top">Suitable for development</td>
</tr>
<tr>
<td width="306" valign="top">Near impossible to crack</td>
<td width="306" valign="top">Scrambling is easier to crack unless you generate random values.</td>
</tr>
<tr>
<td width="306" valign="top">New data is also encrypted</td>
<td width="306" valign="top">New data is not scrambled but in development it should be safe</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><strong><font size="4">How to Scramble Data in Oracle</font></strong></p>
<p>The best way to perform scrambling is through translate built-in function.</p>
<p>Here is an example:<br />
<pre class="brush: css;">
SELECT 'Hazem Ameen' as before_scrambling , TRANSLATE(lower('Hazem Ameen'),
'.@,0123456789abcdefghijklmnopqrstuvxyzابتثجحخدذرزسشصضطظعغفقكلمنوهي', '.@,4214563875qwertyuiop[kjhbvabcdefxzgباتنمكضصثقفغعهخحجدظزوةىرذشسؤ') after_scrambling
FROM dual;
</pre></p>
<table border="1" cellspacing="0" cellpadding="5">
<tbody>
<tr>
<td bgcolor="#000000"><font color="#ffffff"><strong>BEFORE_SCRAMBLING<br />
</strong></font></td>
<td bgcolor="#000000"><font color="#ffffff"><strong>AFTER_SCRAMBLING</strong></font></td>
</tr>
<tr>
<td>Hazem Ameen</td>
<td>iqgtj qjtth</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>It is really up to you how you want to apply it in your environment. At the end would have to execute a statement like this on every column that requires scrambling:</p>
<address><em>Update table_name set &lt;column_name_to_scrambled&gt; = </em></address>
<address><em>translate (&lt;column_name_to_scrambled&gt;, &#8216;.@,0123456789abcdefghijklmnopqrstuvxyzابتثجحخدذرزسشصضطظعغفقكلمنوهي&#8217;, &#8216;.@,4214563875qwertyuiop[kjhbvabcdefxzgباتنمكضصثقفغعهخحجدظزوةىرذشسؤ&#8217;)</em></address>
<p>Here are some tips on how to apply this in your environment:</p>
<ol>
<li>If you have too many columns or the process of scrambling repeats often, insert table name along with columns to be scrambled in a table, then develop a PL/SQL procedure to read this table and execute the update statement dynamically.</li>
<li>Updating large amount of data via a single update statement will take a very long time; instead you would open a cursor and loop through the data.</li>
<li>Be aware that triggers on the table will slow down this procedure dramatically. If you can disable them first before running this procedure.</li>
<li>This scrambling process doesn’t scramble dates or LOBS.</li>
</ol>
<p>&nbsp;</p>
<address><em>Hazem Ameen</em></address>
<address><em>Senior Oracle DBA</em><strong><br />
</strong></address>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ksadba.wordpress.com/256/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ksadba.wordpress.com/256/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ksadba.wordpress.com/256/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ksadba.wordpress.com/256/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ksadba.wordpress.com/256/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ksadba.wordpress.com/256/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ksadba.wordpress.com/256/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ksadba.wordpress.com/256/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ksadba.wordpress.com/256/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ksadba.wordpress.com/256/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ksadba.wordpress.com/256/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ksadba.wordpress.com/256/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ksadba.wordpress.com/256/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ksadba.wordpress.com/256/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ksadba.wordpress.com&amp;blog=3930725&amp;post=256&amp;subd=ksadba&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ksadba.wordpress.com/2010/08/21/data-scrambling-in-oracle-including-arabic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eda39a036b3ab7f1ff7462687db4c6f2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ksadba</media:title>
		</media:content>
	</item>
		<item>
		<title>Tuning PL/SQL with Multithreading &amp; DBMS_SCHEDULER</title>
		<link>http://ksadba.wordpress.com/2009/05/26/tuning-plsql-with-multithreading-dbms_scheduler/</link>
		<comments>http://ksadba.wordpress.com/2009/05/26/tuning-plsql-with-multithreading-dbms_scheduler/#comments</comments>
		<pubDate>Tue, 26 May 2009 07:17:37 +0000</pubDate>
		<dc:creator>ksadba</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[dbms_scheduler]]></category>
		<category><![CDATA[Multithreading]]></category>
		<category><![CDATA[PL/SQL]]></category>

		<guid isPermaLink="false">http://ksadba.wordpress.com/?p=209</guid>
		<description><![CDATA[We had a piece of PL/SQL code that copies data from remote view to a local table. This code executes once a day and took about 4 hours. As if this is not bad enough, we received a request to run this piece of code 3-4 times daily which will total up to about 16 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ksadba.wordpress.com&amp;blog=3930725&amp;post=209&amp;subd=ksadba&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We had a piece of PL/SQL code that copies data from remote view to a local table. This code executes once a day and took about 4 hours. As if this is not bad enough, we received a request to run this piece of code 3-4 times daily which will total up to about 16 hours per day.</p>
<p>The original code to copy data from a remote view consists of 3 steps:</p>
<ol>
<li>Copy over employee numbers (one column only) from remote view to local temp table. This step takes few seconds only.</li>
<li>Use employee numbers copied locally to do a lookup serially (lookup row by row) from remote view. This step takes about 4 hours to copy 20,000 rows. The reason it takes that long is one column from the view is an actual function. Most of the time is spent executing this function and for so many reasons (not all are technical) we can’t get to function to tune it.</li>
<li>Commit one time at the end.</li>
</ol>
<p>Here how the original code looks like:</p>
<p><span style="color:#008000;">&#8211; Step 1:<br />
&#8211; truncate local temp table so we can copy employee numbers<br />
&#8211; copy over employees numbers to local temp table from the remote view </span><br />
<pre class="brush: css;">
execute immediate 'truncate table temp_emp_no';
execute immediate 'truncate table employees';

insert into temp_emp_no select distinct EMPLOYEE_NUMBER from remote_employee_view@remote_link;
commit;
</pre>
</p>
<p><span style="color:#008000;">&#8211; Step 2:<br />
&#8211; Loop through copied over employee numbers and do a remote lookup 1 row at a time</span><br />
<pre class="brush: css;">
cursor c1 is
   select emp_no from temp_emp_no;

for i in c1 loop
   exit when c1%notfound;
   insert into employees
   select EMPLOYEE_NUMBER, first_name, last_name, RATE, PERIOD, total_rate
     from remote_employee_view@remote_link;
   where EMPLOYEE_NUMBER = i.emp_no;
end loop;

commit;
</pre><br />
At this point we were left with one option only which is run the PL/SQL code in parallel (multithreading), but as you might now, PL/SQL doesn’t support multithreading natively,</p>
<p>To simulate multithreading we need to accomplish 2 steps:</p>
<ol>
<li>Break the job in multiple pieces (threads).</li>
<li>Schedule every thread to run concurrently.</li>
</ol>
<p>Remember first step which is coping employee numbers only from remote view to local table. We hash-partitioned this local table into 4 partitions. Each of these partitions will translate into a thread as you will see.<br />
<pre class="brush: css;">
CREATE TABLE vb_emp_no
   (emp_no  VARCHAR2(30))
    PARTITION BY HASH (EMP_NO)
     PARTITIONS 4
/
</pre><br />
This is the thread code (stored procedure) which takes in a partition name as a parameter and copies employee data from remote view for that partition only.<br />
<pre class="brush: css;">
CREATE procedure refresh_employee_data_part (p_name in varchar2 )
  authid definer
is
  TYPE EmpCurTyp  IS REF CURSOR;
  v_emp_cursor    EmpCurTyp;
  sql_stmt varchar2(2048);
  v_emp_no varchar2(30);

begin
  sql_stmt := 'select emp_no from vb_emp_no partition(' || p_name || ')';
  open v_emp_cursor for sql_stmt ;

loop
  fetch v_emp_cursor into v_emp_no;
  EXIT WHEN v_emp_cursor%NOTFOUND;
  insert into employees
          (EMPLOYEE_NUMBER,
           VACATION_BALANCE,
           RATE, PERIOD, TOTAL_RATE)
  select distinct employee_number, vacation_balance, rate, period, total_rate
    from   remote_employee_view@remote_link;
  where  EMPLOYEE_NUMBER = v_emp_no;
end loop;

commit;
close v_emp_cursor;
end;
/
</pre><br />
This procedure glues all parts together. We schedule the previous procedure 4 times and achieve concurrency.<br />
<pre class="brush: css;">
CREATE procedure refresh_employees
  authid definer
is
begin
  execute immediate 'truncate table vb_emp_no';
  insert into vb_emp_no
  select distinct employee_number from remote_view@db_link;
  commit;
  execute immediate 'truncate table employees';

dbms_scheduler.create_job(job_name =&gt; dbms_scheduler.generate_job_name('VB_P1_'),
   job_type =&gt; 'PLSQL_BLOCK',
   job_action =&gt; 'begin refresh_employee_data_part(''VB_EMP_NO_P1''); end;',
   comments =&gt; 'Thread 1 to refresh employees',
   enabled =&gt; true,
   auto_drop =&gt; true);

dbms_scheduler.create_job(job_name =&gt; dbms_scheduler.generate_job_name('VB_P2_'),
   job_type =&gt; 'PLSQL_BLOCK',
   job_action =&gt; 'begin refresh_employee_data_part(''VB_EMP_NO_P2''); end;',
   comments =&gt; 'Thread 2 to refresh employees',
   enabled =&gt; true,
   auto_drop =&gt; true);

dbms_scheduler.create_job(job_name =&gt; dbms_scheduler.generate_job_name('VB_P3_'),
   job_type =&gt; 'PLSQL_BLOCK',
   job_action =&gt; 'begin refresh_employee_data_part(''VB_EMP_NO_P3''); end;',
   comments =&gt; 'Thread 3 to refresh employees',
   enabled =&gt; true,
   auto_drop = true);

dbms_scheduler.create_job(job_name =&gt; dbms_scheduler.generate_job_name('VB_P4_'),
   job_type =&gt; 'PLSQL_BLOCK',
   job_action =&gt; 'begin refresh_employee_data_part(''VB_EMP_NO_P4''); end;',
   comments =&gt; 'Thread 4 to refresh employees,
   enabled =&gt; true,
   auto_drop =&gt; true);

end;
/
</pre><br />
The procedure would finish immediately even if there are errors. To check the execution status look under DBA_SCHEDULER_JOB_RUN_DETAILS to look for errors and running time.</p>
<h2 style="text-align:center;"><span style="color:#000080;">End Result the job finished in 50 minutes more than 4x faster.</span></h2>
<p><em>Hazem Ameen<br />
Senior Oracle DBA</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ksadba.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ksadba.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ksadba.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ksadba.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ksadba.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ksadba.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ksadba.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ksadba.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ksadba.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ksadba.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ksadba.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ksadba.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ksadba.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ksadba.wordpress.com/209/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ksadba.wordpress.com&amp;blog=3930725&amp;post=209&amp;subd=ksadba&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ksadba.wordpress.com/2009/05/26/tuning-plsql-with-multithreading-dbms_scheduler/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eda39a036b3ab7f1ff7462687db4c6f2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ksadba</media:title>
		</media:content>
	</item>
		<item>
		<title>Virtual Private Database (VPD) Column Masking Simple Example</title>
		<link>http://ksadba.wordpress.com/2009/04/22/virtual-private-database-vpd-column-masking-simple-example/</link>
		<comments>http://ksadba.wordpress.com/2009/04/22/virtual-private-database-vpd-column-masking-simple-example/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 06:23:04 +0000</pubDate>
		<dc:creator>ksadba</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[column masking]]></category>
		<category><![CDATA[dbms_rls]]></category>
		<category><![CDATA[Virtual private database]]></category>
		<category><![CDATA[vpd]]></category>

		<guid isPermaLink="false">http://ksadba.wordpress.com/?p=200</guid>
		<description><![CDATA[Column masking is a simple way to hide you valuable data from certain users without having to apply encrypt/decrypt techniques and increase the column width to accommodate the new string like the old times. Through some simple configuration you can create policies to show your important columns as null without rewriting a single line of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ksadba.wordpress.com&amp;blog=3930725&amp;post=200&amp;subd=ksadba&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Column masking is a simple way to hide you valuable data from certain users without having to apply encrypt/decrypt techniques and increase the column width to accommodate the new string like the old times. Through some simple configuration you can create policies to show your important columns as null without rewriting a single line of code on your application side.</p>
<p>There are 3 steps for accomplish column masking:</p>
<ol>
<li> A function to be used by the policy (function policy) created in next step.</li>
<li> Use dbms_rls package to create the policy.</li>
<li> Assign “exempt access policy” to users to be excluded from the policy. These users can see all data with no masking.</li>
</ol>
<h2><span style="color:#000000;">Step 1: Create Function Policy</span></h2>
<p>This function will be called be the policy to create the column masking. Function name can be any name you select. In my case I called vpd_function. If predicate evaluated to true, then data will to show to all users. In my case I made sure that function will always evaluate to false by looking for (rowid = 0) which will never be true. I suggest creating the function under system account.<br />
<pre class="brush: css;">
CREATE OR REPLACE
FUNCTION vpd_function (obj_owner IN VARCHAR2, obj_name IN VARCHAR2)
RETURN VARCHAR2
AS
BEGIN
RETURN 'rowid = ''0''';
END vpd_function;
/
</pre></p>
<h2><span style="color:#000000;">Step 2: Create Policy</span></h2>
<p><pre class="brush: css;">
BEGIN
DBMS_RLS.ADD_POLICY(object_schema=&gt; 'SCOTT',
object_name=&gt; 'EMP',
policy_name=&gt; 'scott_emp_policy',
function_schema=&gt; 'SYSTEM',
policy_function=&gt; 'vpd_function',
sec_relevant_cols=&gt; 'JOB',
policy_type =&gt; DBMS_RLS.SHARED_STATIC,
sec_relevant_cols_opt=&gt; dbms_rls.ALL_ROWS);

END;
/
</pre></p>
<h2><span style="color:#000000;">Step 3: Exclude Some Users from Policy</span></h2>
<p>Users who need to see all the data without any masking need to be granted  “exempt access policy”</p>
<h2><span style="color:#000000;">Notes:</span></h2>
<ul>
<li>Dropping a table that has a policy will drop the policy but not the function policy.</li>
<li>Renaming the table will NOT drop the policy or disable it. The policy will remain active.</li>
<li>Export/Import will also export/import the policy along with the table, but will not export/import the function policy.</li>
<li>When exporting a table under a policy, make sure the user exporting the table has “exempt access policy” grant, otherwise, the column under the policy will always be null and column data will be lost.</li>
</ul>
<h2><span style="color:#000000;">Some Important Views</span></h2>
<p>dba_policies<br />
v$vpd_policy</p>
<p><em>Hazem Ameen<br />
Senior Oracle DBA</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ksadba.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ksadba.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ksadba.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ksadba.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ksadba.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ksadba.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ksadba.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ksadba.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ksadba.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ksadba.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ksadba.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ksadba.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ksadba.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ksadba.wordpress.com/200/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ksadba.wordpress.com&amp;blog=3930725&amp;post=200&amp;subd=ksadba&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ksadba.wordpress.com/2009/04/22/virtual-private-database-vpd-column-masking-simple-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eda39a036b3ab7f1ff7462687db4c6f2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ksadba</media:title>
		</media:content>
	</item>
		<item>
		<title>SPFILE Backup &amp; Restore Recommendations</title>
		<link>http://ksadba.wordpress.com/2009/03/14/spfile-backup-and-recovery/</link>
		<comments>http://ksadba.wordpress.com/2009/03/14/spfile-backup-and-recovery/#comments</comments>
		<pubDate>Sat, 14 Mar 2009 13:00:44 +0000</pubDate>
		<dc:creator>ksadba</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[backup spfile]]></category>
		<category><![CDATA[controlfile autobackup]]></category>
		<category><![CDATA[restore spfile]]></category>
		<category><![CDATA[rman]]></category>
		<category><![CDATA[RMAN-06564]]></category>
		<category><![CDATA[Spfile autobackup]]></category>

		<guid isPermaLink="false">http://ksadba.wordpress.com/?p=185</guid>
		<description><![CDATA[I&#8217;m always amazed as how a little file as the SPFILE can complicate situations &#8220;when you can really use a break&#8221;. For example, you shutdown your database gracefully just to find out that you can&#8217;t bring it up again due to the fact that you have bad parameters in your SPFILE or the file somehow [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ksadba.wordpress.com&amp;blog=3930725&amp;post=185&amp;subd=ksadba&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m always amazed as how a little file as the SPFILE can complicate situations &#8220;when you can really use a break&#8221;. For example, you shutdown your database gracefully just to find out that you can&#8217;t bring it up again due to the fact that you have bad parameters in your SPFILE or the file somehow got deleted and you just came to find out. So you want to recover a backup copy of SPFILE, that&#8217;s when you discover that you don&#8217;t really know how Oracle is backing up your SPFILE, where the file is (disk, tape or both) and how to recover it.</p>
<p>I hope this post will answer all these questions.</p>
<p>&nbsp;</p>
<h3><b>SPFILE Backup</b></h3>
<p>Our design goal is to have 2 backups of SPFILE: 1 on disk and the other backup on tape. This way you can first attempt to recover from disk which is faster, if you can&#8217;t then try the tape.</p>
<p>Here are the steps to accomplish our design (<em>Tested in 10.2.0.4 Linux 64-bit)</em>:</p>
<p>&nbsp;</p>
<p></p>
<h4><b>1)&nbsp;Enable control file auto backup to disk.</b></h4>
<p>Every time a change is made to control file, an auto backup will take place of both control file and SPFILE. Unfortunately SPFILE changes by itself don&#8217;t constitute an auto backup. In addition to auto backups when control file changes, every time you have a backup statement in your RMAN script (ex. backup database plus archive), an auto backup will be generated.</p>
<p>To enable control file auto backup:<br />
<font face="courier new"><br />
rman&gt; CONFIGURE CONTROLFILE AUTOBACKUP ON;<br />
</font></p>
<p>You can send your auto backups to anywhere on disk. The default is $ORACLE_HOME/dbs. I prefer sending auto backups to FRA (especially in a RAC environment). You can read about how to set up FRA and send auto backups to it <a title="here" href="http://ksadba.wordpress.com/2008/10/19/database-flashback-configuration-and-tips-for-rac/">here</a>.</p>
<p>Here is an example of sending auto backups to a specific location on disk:<br />
<font face="courier new"><br />
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO &#8216;/u04/backups/auto/%F&#8217;;<br />
</font><br />
<br />
Now you accomplished first design goal which is backup SPFILE to disk.</p>
<p>&nbsp;</p>
<h4><b>2)&nbsp;Include SPFILE in your RMAN backup sets to tape.</b></h4>
<p>The default behavior when you enable auto backup is NOT to backup SPFILE in RMAN backup pieces. To overwrite this behavior, this RMAN statement will create backup piece for SPFILE and implicitly create an auto backup on disk as configured in previous step.<br />
<font face="courier new"><br />
backup<br />
incremental level 0<br />
spfile format &#8216;spfile_%d_%s_%T.bak&#8217;  tag &#8216;spfile backup&#8217;<br />
database include current controlfile format &#8216;data_%d_%s_%T.bak&#8217;  tag &#8216;data backup&#8217;<br />
archivelog all format &#8216;arc_%d_%s_%T.bak&#8217;  tag &#8216;archive backup&#8217; delete input;<br />
</font></p>
<p>Now we accomplished second step which is backing up SPFILE to tape with your daily rman backup.</p>
<p>&nbsp;</p>
<h3><b>Recovery Scenarios</b></h3>
<p>Here are the most common recovery scenarios I came across, remember <font color="red">Oracle will not recover an SPFILE file to its original location while the database is up even if existing SPFILE is deleted.</font> You will get this <i>&#8220;RMAN-06564 must use the TO clause when the instance is started with SPFILE&#8221;</i>, which is a little confusing. So simply recover to a different location and do &#8220;cp&#8221;.</p>
<p>&nbsp;</p>
<h4><b>A)&nbsp;Recover latest SPFILE while database down</b></h4>
<p><font face="courier new"><br />
set dbid <em>&lt;your DBID&gt;</em></p>
<p>startup nomount;</p>
<p>restore spfile from autobackup;</p>
<p>shutdown immediate</p>
<p>startup<br />
</font></p>
<p>&nbsp;</p>
<h4><b>B)&nbsp;Recover from auto backup in Flashback Recovery Area, database up</b></h4>
<p>This is RAC/ASM with FRA placed in ASM<br />
<font face="courier new"><br />
RMAN&gt; restore spfile to &#8216;<em>&lt;path with filename&gt;</em>&#8216; from autobackup;<br />
Starting restore at 11-MAR-09<br />
allocated channel: ORA_DISK_1<br />
channel ORA_DISK_1: sid=128 instance=raca1 devtype=DISK<br />
recovery area destination: +ARCDG<br />
database name (or database unique name) used for search: RACA<br />
channel ORA_DISK_1: autobackup found in the recovery area<br />
channel ORA_DISK_1: autobackup found: +arcdg/RACA/AUTOBACKUP/2009_03_11/s_681250817.257.681250819</p>
<p>channel ORA_DISK_1: SPFILE restore from autobackup complete<br />
Finished restore at 11-MAR-09</p>
<p>Another syntax is to accomplish the same thing:</p>
<p>restore spfile to pfile &#8216;&lt;path and filename&gt;&#8217; from autobackup db_recovery_file_dest=&#8217;+ARCDG&#8217; db_name=&#8217;&lt;your db name&gt;&#8217;;<br />
</font></p>
<p>&nbsp;</p>
<h4><b>C)&nbsp;Recover a specific backup of SPFILE</b></h4>
<p>This is useful if you have bad parameters in your SPFILE and want to recover an older cleaner copy (SPFILE point in time recovery, now how about that )<br />
<font face="courier new"><br />
list backup of spfile;</p>
<p># select proper backup piece</p>
<p>restore spfile to &#8216;&lt;path and filename except original location when DB started&gt; from &#8216;&lt;backup piece or auto backup&gt;&#8217;;<br />
</font></p>
<p>&nbsp;</p>
<h4><b>D)&nbsp;Recover an SPFILE to PFILE</b></h4>
<p>Always useful if you want to read content of your parameter file.<br />
<font face="courier new"><br />
restore spfile to pfile &#8216;<em>&lt;your path and filename&gt;</em>&#8216;  from autobackup;<br />
</font><br />
<br />
&nbsp;<br />
<br />
<em>Hazem Ameen</em><br />
<em>Senior Oracle DBA</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ksadba.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ksadba.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ksadba.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ksadba.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ksadba.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ksadba.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ksadba.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ksadba.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ksadba.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ksadba.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ksadba.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ksadba.wordpress.com/185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ksadba.wordpress.com/185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ksadba.wordpress.com/185/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ksadba.wordpress.com&amp;blog=3930725&amp;post=185&amp;subd=ksadba&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ksadba.wordpress.com/2009/03/14/spfile-backup-and-recovery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eda39a036b3ab7f1ff7462687db4c6f2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ksadba</media:title>
		</media:content>
	</item>
		<item>
		<title>Oracle Streams: SET_TAG and Capture Rules (Skip DDL &amp; DML)</title>
		<link>http://ksadba.wordpress.com/2009/01/23/oracle-streams-set_tag-and-capture-rules-skip-ddl-dml/</link>
		<comments>http://ksadba.wordpress.com/2009/01/23/oracle-streams-set_tag-and-capture-rules-skip-ddl-dml/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 11:53:59 +0000</pubDate>
		<dc:creator>ksadba</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Capture Rules]]></category>
		<category><![CDATA[dbms_streams.set_tag]]></category>
		<category><![CDATA[Oracle Streams]]></category>

		<guid isPermaLink="false">http://ksadba.wordpress.com/?p=178</guid>
		<description><![CDATA[If you ever tried to use dbms_streams.set_tag function to avoid replicating DDL or DML in your Streams environment, we’ll you unpleasantly surprised that it doesn’t work (I hope you didn’t try it on production right way ). This post deals with steps you have to implement to get it working. First, every entry in the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ksadba.wordpress.com&amp;blog=3930725&amp;post=178&amp;subd=ksadba&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you ever tried to use dbms_streams.set_tag function to avoid replicating DDL or DML in your Streams environment, we’ll you unpleasantly surprised that it doesn’t work (I hope you didn’t try it on production right way ).</p>
<p>This post deals with steps you have to implement to get it working.</p>
<p>First, every entry in the redo log files has a tag associated with it. The default value for this tag is null. The capture process default behavior is not to check for tags at all, in other words, it will read and process every entry in the redo log regardless of it&#8217;s tag value. But what we want is for the capture process to read and process null tags only and ignore non-null tags (these are the DML or DDL that will be skipped).</p>
<p>So the question, how to change the capture process behavior so it will ignore non-null tags?<br />
The answer is by adjusting the capture rules for DML &amp; DDL (depends on whether you need to ignore both operations).</p>
<p>The following scripts assume you have the default Streams configuration without adding any additional custom rules.</p>
<p>Get Capture Rule name and rule condition.<br />
select rule_name, rule_condition<br />
from dba_streams_rules<br />
where rule_set_owner = &#8216;STRMADMIN&#8217;<br />
and streams_type = &#8216;CAPTURE&#8217;;</p>
<p>It should return 2 rows, 1 rule for DML and the other for DDL.</p>
<p>Here how the DDL capture rule looks like before changing:</p>
<p>((((:ddl.get_object_owner() = &#8216;schema name&#8217; or :ddl.get_base_table_owner() = ‘schema name&#8217;) and :ddl.get_source_database_name() = &#8216;database name&#8217; )) and (:ddl.get_compatible() &lt;= dbms_streams.compatible_10_2))</p>
<p>Now add condition to capture null tags only</p>
<p>BEGIN<br />
DBMS_RULE_ADM.ALTER_RULE (<br />
rule_name =&gt; &#8216;CWSAPP66&#8242;,<br />
condition =&gt; &#8216;((((:ddl.get_object_owner() = &#8221;CWSAPP&#8221; or :ddl.get_base_table_owner() = &#8221;CWSAPP&#8221;) and :ddl.get_source_database_name() = &#8221;CWSRD&#8221; ))<br />
and (:ddl.get_compatible() &lt;= dbms_streams.compatible_10_2) and <span style="color:#ff0000;">(:ddl.is_null_tag() = &#8221;Y&#8221;)</span>)&#8217;,<br />
evaluation_context =&gt; NULL);<br />
END;<br />
/</p>
<p>Now from a new session</p>
<p>dbms_streams.set_tag(‘01’);</p>
<p>DDL or DML changes will not get replicated</p>
<p>dbms_streams.set_tag(null); &#8212; go back to replicating everything</p>
<p>Remember if using bi-directional replication, you have to adjust capture rules in every site.</p>
<p><em>Hazem Ameen<br />
Senior Oracle DBA</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ksadba.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ksadba.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ksadba.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ksadba.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ksadba.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ksadba.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ksadba.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ksadba.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ksadba.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ksadba.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ksadba.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ksadba.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ksadba.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ksadba.wordpress.com/178/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ksadba.wordpress.com&amp;blog=3930725&amp;post=178&amp;subd=ksadba&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ksadba.wordpress.com/2009/01/23/oracle-streams-set_tag-and-capture-rules-skip-ddl-dml/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eda39a036b3ab7f1ff7462687db4c6f2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ksadba</media:title>
		</media:content>
	</item>
		<item>
		<title>Would you Let Women Drive in Saudi Arabia</title>
		<link>http://ksadba.wordpress.com/2009/01/20/would-you-let-women-drive-in-saudi-arabia/</link>
		<comments>http://ksadba.wordpress.com/2009/01/20/would-you-let-women-drive-in-saudi-arabia/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 03:12:30 +0000</pubDate>
		<dc:creator>ksadba</dc:creator>
				<category><![CDATA[Life in Saudi Arabia]]></category>
		<category><![CDATA[Saudi Arabia]]></category>
		<category><![CDATA[Saudian Culture]]></category>

		<guid isPermaLink="false">http://ksadba.wordpress.com/?p=173</guid>
		<description><![CDATA[Not so long ago, I was driving my van and sitting right next to me one of the mildest tempered people I knew in my life, my wife. However, this time, she was yelling at me saying, FOLLOW HIM, GET HIM. The person that made my wife yell was not a thief or an attacker, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ksadba.wordpress.com&amp;blog=3930725&amp;post=173&amp;subd=ksadba&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Not so long ago, I was driving my van and sitting right next to me one of the mildest tempered people I knew in my life, my wife.  However, this time, she was yelling at me saying, FOLLOW HIM, GET HIM.</p>
<p> The person that made my wife yell was not a thief or an attacker, but your common average driver in KSA.  The driving in Saudi is a combination of rude, aggressive, and in some cases flat out suicidal.  It definitely gets under your skin and you respond rather erratically like.</p>
<p>Back in USA people are scared of drunk drivers, but in Saudi, we are fearsome of most drivers and especially of teen drivers. There are young teens that barely can see over the wheel and driving an 8-15 passenger 4&#215;4 SUV.  It came no surprise that KSA has one of the highest car accident death rates in the world. </p>
<p>Knowing all risks involved, would you let your wife or daughter drive (if it is ever allowed)?  Even though is none of my business, but I don’t think so, not unless KSA fixes this domestic problem. Why would anybody want to take a risk on his wife’s or daughter’s life!</p>
<p>If you ever in KSA, here are some tips to help you cope with this issue:</p>
<p>Few expatriates elect not to own a car but rather relying on company’s transportation and taxis.</p>
<p>Some co-workers take longer and easier routes just to elude traffic and come to the job calmer.</p>
<p>Know the problematic routes and times of traffic congestion to avoid them.</p>
<p>Remind yourself to always remain calm. This is one fight you can’t really win.</p>
<p>Most expatriates buy 4&#215;4 SUVs; they are safer in case car accidents (God forbid).</p>
<p>Drive defensively, can’t stress this point enough.</p>
<p><em>Hazem Ameen</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ksadba.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ksadba.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ksadba.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ksadba.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ksadba.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ksadba.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ksadba.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ksadba.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ksadba.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ksadba.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ksadba.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ksadba.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ksadba.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ksadba.wordpress.com/173/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ksadba.wordpress.com&amp;blog=3930725&amp;post=173&amp;subd=ksadba&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ksadba.wordpress.com/2009/01/20/would-you-let-women-drive-in-saudi-arabia/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eda39a036b3ab7f1ff7462687db4c6f2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ksadba</media:title>
		</media:content>
	</item>
	</channel>
</rss>
