<?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>Deep Thinking in Our Life</title>
	<atom:link href="http://deepthinking99.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://deepthinking99.wordpress.com</link>
	<description>Lets Explore the Information Technology together . . .</description>
	<lastBuildDate>Thu, 03 Dec 2009 06:11:11 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='deepthinking99.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/86e6e4c1f636efd2eb20061bf9253f60?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Deep Thinking in Our Life</title>
		<link>http://deepthinking99.wordpress.com</link>
	</image>
			<item>
		<title>Oracle utilities secrets</title>
		<link>http://deepthinking99.wordpress.com/2009/12/03/oracle-utilities-secrets/</link>
		<comments>http://deepthinking99.wordpress.com/2009/12/03/oracle-utilities-secrets/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 06:11:11 +0000</pubDate>
		<dc:creator>Ida Bagus Enderajana</dc:creator>
				<category><![CDATA[Burleson Article]]></category>

		<guid isPermaLink="false">http://deepthinking99.wordpress.com/?p=807</guid>
		<description><![CDATA[Oracle has “secret” undocumented utilities that are so powerful that they are reluctant to release the details to the general public.  Oracle deliberately glosses-over these powerful utilities because they must write the documentation to the lowest common denominator, and these utilities can be extremely dangerous to Oracle professionals without the required work experience.
These utilities [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deepthinking99.wordpress.com&blog=4894307&post=807&subd=deepthinking99&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Oracle has “secret” undocumented utilities that are so powerful that they are reluctant to release the details to the general public.  Oracle deliberately glosses-over these powerful utilities because they must write the documentation to the lowest common denominator, and these utilities can be extremely dangerous to Oracle professionals without the required work experience.</p>
<p>These utilities are often left inside an Oracle distribution for use exclusively by Oracle technical support, but expert Oracle DBA&#8217;s find them invaluable for advanced database operations.  These undocumented utilities are described in the new book “Advanced Oracle Utilities: The Definitive Reference”.</p>
<p>A hidden Oracle utility is not a utility that is physically hidden in the Oracle software. Rather, a hidden utility is an executable or PL/SQL package that is either undocumented or where the documentation is difficult to find. For example, some PL/SQL packages are never loaded by the Oracle installer, yet their definitions remain in the operating system files.</p>
<p>The main directories where Oracle utilities reside are here:<br />
$ORACLE_HOME/bin &#8212; This contains the binary executables used by the Oracle server. Most of the tools discussed in the Oracle Utilities book reside in this directory.<br />
$ORACLE_HOME/plsql/demo &#8212; This contains a useful collection of SQL scripts related to many utilities, including the dbms_profiler utility.<br />
$ORACLE_HOME/rdbms/admin &#8212; This contains many SQL scripts used for creating PL/SQL packages and their required environments.<br />
$ORACLE_HOME/sqlplus/admin &#8212; This contains scripts used with autotrace and other utilities.<br />
$ORACLE_HOME/otrace/admin &#8212; This is the administration directory for the Oracle Trace diagnostic tool.<br />
$ORACLE_HOME/otrace/sysman &#8212; This is used by utilities such as oemctl and the Oracle Management Server (OMS).<br />
$ORACLE_HOME/otrace/lib &#8212; This contains facility files used with the oerr utility.</p>
<p>Many of these undocumented utilities such as TKPROF have surfaced from the obscure and entered mainstream Oracle toolkits while others remain hidden inside the O/S.<br />
Finding hidden Oracle utilities</p>
<p>The easiest way to find hidden utilities is to look for new packages within Oracle. The following query compares the packages in Oracle10g with new packages in Oracle11g, using a database link between two instances, each on a different release of Oracle:<br />
select<br />
object_name<br />
from<br />
dba_objects@oracle11g<br />
where<br />
owner      = &#8216;SYS&#8217;<br />
and<br />
object_type = &#8216;PACKAGE BODY&#8217;<br />
minus<br />
select<br />
object_name<br />
from<br />
dba_objects@oracle10g<br />
where<br />
owner     = &#8216;SYS&#8217;<br />
and<br />
object_type = &#8216;PACKAGE BODY&#8217;;</p>
<p>This query will quickly display all package bodies owned by SYS that exist in Oracle11g but not in Oracle10g.<br />
Finding hidden Oracle executable utilities</p>
<p>Discovering new binaries entails comparing two directories in the operating system and ignoring the duplicates entries. The dircmp UNIX command can be used to find only new entries within two directories:<br />
dircmp &#8212; s<br />
/u01/aoracle/product/9.0.3/bin<br />
/u01/oracle/product/10.2.0/bin</p>
<p>Here we compare the bin directory of 9i with Oracle 10.2.<br />
Using advanced Oracle utilities</p>
<p>Fortunately, these undocumented utilities are described in the new book “Advanced Oracle Utilities: The Definitive Reference”, where we see some extremely useful tools that are hidden inside Oracle:</p>
<p>BBED – This is the powerful Oracle block editor utility.  BBED allows you to view and update the contents of Oracle data blocks.  BBED should only be used by experts, or in conjunction with Oracle technical support.</p>
<p>Dbverify – This dbverify utility is very useful for</p>
<p>Oradebug &#8211; This powerful Oracle debugger has many valuable features for debugging Oracle sessions.</p>
<p>Orastack &#8211; This orastack memory stack utility allow you to see how RAM is being used within an Oracle session.</p>
<p>Again, these are just a small sample of the hidden utilities with Oracle</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deepthinking99.wordpress.com/807/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deepthinking99.wordpress.com/807/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deepthinking99.wordpress.com/807/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deepthinking99.wordpress.com/807/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deepthinking99.wordpress.com/807/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deepthinking99.wordpress.com/807/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deepthinking99.wordpress.com/807/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deepthinking99.wordpress.com/807/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deepthinking99.wordpress.com/807/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deepthinking99.wordpress.com/807/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deepthinking99.wordpress.com&blog=4894307&post=807&subd=deepthinking99&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://deepthinking99.wordpress.com/2009/12/03/oracle-utilities-secrets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1f3b6fbee19bb2cca5ced85efa030302?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">deepthinking99</media:title>
		</media:content>
	</item>
		<item>
		<title>Sequence of steps in Oracle SQL explain plan</title>
		<link>http://deepthinking99.wordpress.com/2009/11/26/ksjdhsjkhd/</link>
		<comments>http://deepthinking99.wordpress.com/2009/11/26/ksjdhsjkhd/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 07:19:01 +0000</pubDate>
		<dc:creator>Ida Bagus Enderajana</dc:creator>
				<category><![CDATA[Burleson Article]]></category>

		<guid isPermaLink="false">http://deepthinking99.wordpress.com/?p=801</guid>
		<description><![CDATA[When Codd and Date created the relational data model, the  				execution plan was an afterthought, largely because the SQL  				optimizer was always supposed to generate the best execution  				plan, and hence, there was not real need to understand the  				internal machinations of Oracle execution plans.
However,  				in the real world, all [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deepthinking99.wordpress.com&blog=4894307&post=801&subd=deepthinking99&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><span style="font-size:small;">When Codd and Date created the relational data model, the  				execution plan was an afterthought, largely because the SQL  				optimizer was always supposed to generate the best execution  				plan, and hence, there was not real need to understand the  				internal machinations of Oracle execution plans.</span></p>
<p>However,  				in the real world, all SQL tuning experts must be proficient in  				reading Oracle execution plans and understand the steps within a  				explain plans and the sequence that the steps are executed.   				To successfully understand an explain plan you must be able to  				know the order that the plan steps are executed.</p>
<p>Reading an explain plan is important for many  				reasons, and Oracle SQL tuning experts reveal the explain plans  				to check many things:</p>
<p><!--[if !supportLists]--> ·        				<!--[endif]-->Ensure that the tables will be  				joined in optimal order.</p>
<p><!--[if !supportLists]--> ·        				<!--[endif]-->Determine the most restrictive  				indexes to fetch the rows.</p>
<p><!--[if !supportLists]--> ·        				<!--[endif]-->Determine the best internal join  				method to use (e.g. nested loops, hash join).</p>
<p><!--[if !supportLists]--> ·        				<!--[endif]-->Determine that the SQL is  				executing the steps in the optimal order.</p>
<p>Reading SQL execution plans has always been  				difficult, but there are some tricks to help determine the  				correct order that the explain plan steps are executed.</p>
<p>&nbsp;</p>
<p><strong>Ordering the  				sequence of execution plan steps</strong></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">SQL execution plans are interpreted using a  				preorder traversal (reverse transversal) algorithm which you  				will see below.  				Preorder traversal is a fancy way of saying:</span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> <!--[if !supportLists]--> 1. <!--[endif]--> That  				to read an execution plan, look for the innermost indented  				statement. That is <strong><em><span style="text-decoration:underline;">generally</span></em></strong> the first  				statement executed but NOT always! (<a href="http://www.dba-oracle.com/t_order_sequence_sql_execution_explain_plans_steps.htm#example">see  				example here</a> where the innermost step is not the first step  				executed).<br />
</span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> <!--[if !supportLists]--> 2. I<!--[endif]-->n  				most cases, if there are two statements at the same level, the  				first statement is executed first.</span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">In other words, execution plans are read  				inside-out, starting with the most indented operation. Here are  				some general rules for reading an explain plan.</span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">1. The first statement is the one that has the  				most indentation.</span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">2. If two statements appear at the same level  				of indentation, the top statement is executed first.</span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">To see how this works, take a look at this  				plan. Which operation is first to execute?</span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;"> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span><span style="font-size:small;">| Id  					| Operation          					| Name | Rows  					| Bytes | Cost (%CPU)| Time     					|</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;">|   					0 | SELECT STATEMENT   					|      					|    					10 |   					650 |     					7  (15)|  					00:00:01 |</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;">|*  					1 |  HASH  					JOIN         					|      					|    					10 |   					650 |     					7  (15)|  					00:00:01 |</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;">|   					2 |   					TABLE ACCESS FULL| JOB  					|     					4 |   					160 |     					3    					(0)| 00:00:01 |</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;">|   					3 |   					TABLE ACCESS FULL| EMP  					|    					10 |   					250 |     					3    					(0)| 00:00:01 |</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</span></p>
<p><span style="font-size:small;"> </span></p>
</div>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">The answer is that the full table scan  				operation on the <em>job </em> table will execute first.  				Let’s look at another example plan and read it…</span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;"> </span><span style="font-size:small;">ID  Par  					Operation</span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> </span><span style="font-size:small;">0      					SELECT STATEMENT Optimizer=FIRST_ROWS </span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> </span><span style="font-size:small;">1    					0    					TABLE ACCESS (BY INDEX ROWID) OF &#8216;EMP&#8217; </span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> </span><span style="font-size:small;">2    					1     					NESTED LOOPS </span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> </span><span style="font-size:small;">3    					2       					TABLE ACCESS (FULL) OF &#8216;DEPT&#8217; </span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> </span><span style="font-size:small;">4    					2     					   INDEX (RANGE SCAN) OF &#8216;IX_EMP_01&#8242; (NON-UNIQUE) </span></p>
<p><span style="font-size:small;"> </span></p>
</div>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> <span style="font-size:small;"> By reviewing this hierarchy of  				SQL execution steps, we see that the order of operations is 3,4,  				2, 1.</span></span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> Here is the graph for  				this execution plan:</span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> <img src="http://www.dba-oracle.com/images/sql_execution_plan_steps.jpg" alt="" width="544" height="210" /></span> <span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">To see how this query executes,  				we traverse the tree in reverse order. From the left most,  				deepest child, traverse the tree moving up, and to the right  				through each branch.</span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> <img src="http://www.dba-oracle.com/images/img2B.jpg" alt="" width="404" height="218" /></span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;"> </span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span></p>
</div>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"><img src="http://www.dba-oracle.com/images/img2D.jpg" alt="" width="404" height="214" /></span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;"> </span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span></p>
</div>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> <img src="http://www.dba-oracle.com/images/img2F.jpg" alt="" width="389" height="182" /></span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;"> </span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span></p>
</div>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> <img src="http://www.dba-oracle.com/images/img31.jpg" alt="" width="409" height="188" /></span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;"> </span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span></p>
</div>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> <img src="http://www.dba-oracle.com/images/img33.jpg" alt="" width="440" height="225" /></span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;"> </span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span></p>
</div>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> <img src="http://www.dba-oracle.com/images/img35.jpg" alt="" width="500" height="205" /></span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">By reviewing this hierarchy of SQL execution steps, we see that the order of operations is 3,4,  				2, 1:</span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;"> </span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> SEQ  ID  					Par Operation</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> 0      					SELECT STATEMENT Optimizer=CHOOSE </span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> 3 					   1    					0    					TABLE ACCESS (BY INDEX ROWID) OF &#8216;EMP&#8217; </span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> 4   					  2    					1     NESTED  					LOOPS </span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> 2   					  3    					2       					TABLE ACCESS (FULL) OF &#8216;DEPT&#8217; </span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> 1   					  4    					2       					INDEX (RANGE SCAN) OF &#8216;IX_EMP_01&#8242; (NON-UNIQUE) </span></p>
<p><span style="font-size:small;"> </span></p>
</div>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">Understanding the sequence of  				explain plan steps is a critical skill, so let’s try some more  				examples:</span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">Consider this SQL query:</span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;">select<br />
a.empid,<br />
a.ename,<br />
b.dname </span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span><span style="font-size:small;">from<br />
emp a,<br />
dept b</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;">where<br />
a.deptno=b.deptno;</span></p>
<p><span style="font-size:small;"> </span></p>
</div>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">We get this execution plan:</span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;">Execution Plan</span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> </span><span style="font-size:small;">0</span><span style="font-size:small;"> </span> <span style="font-size:small;"> </span><span style="font-size:small;">SELECT STATEMENT Optimizer=CHOOSE (Cost=40  					Card=150000 Bytes=3300000)</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> </span><span style="font-size:small;">1</span><span style="font-size:small;"> </span><span style="font-size:small;">0</span><span style="font-size:small;"> </span><span style="font-size:small;">HASH  					JOIN (Cost=40 Card=150000 Bytes=3300000)</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> </span><span style="font-size:small;">2</span><span style="font-size:small;"> </span><span style="font-size:small;">1</span><span style="font-size:small;"> </span> <span style="font-size:small;"> </span><span style="font-size:small;">TABLE ACCESS (FULL) OF &#8216;DEPT&#8217; (Cost=2 Card=1  					Bytes=10)</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> </span><span style="font-size:small;">3</span><span style="font-size:small;"> </span><span style="font-size:small;">1</span><span style="font-size:small;"> </span> <span style="font-size:small;"> </span><span style="font-size:small;">TABLE ACCESS (FULL) OF &#8216;EMP&#8217; (Cost=37 Card=150000  					Bytes=1800000)</span></p>
<p><span style="font-size:small;"> </span></p>
</div>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">What is the order of operations here? </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"><strong> Answer:  Execution  				plan steps are 2, 3, 1 </strong></span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;"> </span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span></p>
</div>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">Consider this query:</span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;">select<br />
a.empid,<br />
a.ename,<br />
b.dname </span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span><span style="font-size:small;">from<br />
emp a,<br />
dept b</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;">where<br />
a.deptno=b.deptno;</span></p>
<p><span style="font-size:small;"> </span></p>
</div>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">We get this execution plan:</span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;"><br />
Execution Plan</span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> </span><span style="font-size:small;">0</span><span style="font-size:small;"> </span> <span style="font-size:small;"> </span><span style="font-size:small;">SELECT STATEMENT Optimizer=CHOOSE (Cost=864  					Card=150000 Bytes=3300000)</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> </span><span style="font-size:small;">1</span><span style="font-size:small;"> </span><span style="font-size:small;">0</span><span style="font-size:small;"> </span><span style="font-size:small;"> </span> <span style="font-size:small;"> HASH JOIN (Cost=864 Card=150000 Bytes=3300000)</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> </span><span style="font-size:small;">2</span><span style="font-size:small;"> </span><span style="font-size:small;">1</span><span style="font-size:small;"> </span> <span style="font-size:small;"> </span><span style="font-size:small;">TABLE ACCESS (BY INDEX ROWID) OF &#8216;DEPT&#8217; (Cost=826  					Card=1 Bytes=10)</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> </span><span style="font-size:small;">3</span><span style="font-size:small;"> </span><span style="font-size:small;">2</span><span style="font-size:small;"> </span> <span style="font-size:small;"> </span><span style="font-size:small;">INDEX (FULL SCAN) OF &#8216;IX_DEPT_01&#8242; (NON-UNIQUE)  					(Cost=26 Card=1)</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> </span><span style="font-size:small;">4</span><span style="font-size:small;"> </span><span style="font-size:small;">1</span><span style="font-size:small;"> </span> <span style="font-size:small;"> </span><span style="font-size:small;">TABLE ACCESS (FULL) OF &#8216;EMP&#8217; (Cost=37 Card=150000 Bytes=1800000)</span><span style="font-size:small;"><br />
</span><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
</div>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">What is the order of operations  				here? </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> <strong> Answer:  Execution  				plans steps are 3, 2, 4, 1</strong></span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;"> </span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span></p>
</div>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">Here is the same query, but slightly different  				plan:</span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;"><br />
select<br />
a.empid,<br />
a.ename,<br />
b.dname </span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span><span style="font-size:small;">from<br />
emp a,<br />
dept b</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;">where<br />
a.deptno=b.deptno;<br />
</span></p>
<p><span style="font-size:small;"> </span></p>
</div>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">We get this execution plan:</span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;"><br />
Execution Plan</span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> </span><span style="font-size:small;">0</span><span style="font-size:small;"> </span> <span style="font-size:small;"> </span><span style="font-size:small;">SELECT STATEMENT Optimizer=CHOOSE  					(Cost=39 Card=150000 Byte=3300000)</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> 1    0   					NESTED LOOPS (Cost=39 Card=150000 Bytes=3300000)</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> </span><span style="font-size:small;">2</span><span style="font-size:small;"> </span><span style="font-size:small;">1</span><span style="font-size:small;"> </span> <span style="font-size:small;"> </span><span style="font-size:small;">TABLE ACCESS (FULL) OF &#8216;DEPT&#8217; (Cost=2 Card=1  					Bytes=10)</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> </span><span style="font-size:small;">3</span><span style="font-size:small;"> </span><span style="font-size:small;">1</span><span style="font-size:small;"> </span> <span style="font-size:small;"> </span><span style="font-size:small;">TABLE ACCESS (FULL) OF &#8216;EMP&#8217; (Cost=37 Card=150000 Bytes=1800000)<br />
</span></p>
<p><span style="font-size:small;"> </span></p>
</div>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">What is the order of operations  				here? </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> <strong> Answer:  Execution  				plans steps are  				2,  				3, 1</strong></span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;"> </span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span></p>
</div>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"><a name="example"></a>Let’s find the SQL execution steps for a three  				table join:</span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;">select<br />
a.ename,<br />
a.salary,<br />
b.dname,<br />
c.bonus_amount,<br />
a.salary*c.bonus_amount </span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span><span style="font-size:small;">from<br />
emp a,<br />
dept b,<br />
bonus c</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;">where<br />
a.deptno=b.deptno<br />
and<br />
a.empid=c.empid;</span></p>
<p><span style="font-size:small;"> </span></p>
</div>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">What is the order of operations here? </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;"><br />
Execution  					Plan</span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span><span style="font-size:small;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> 0      					SELECT STATEMENT Optimizer=CHOOSE (Cost=168 Card=82  					Bytes=3936)</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> 1    					0    					TABLE ACCESS (BY INDEX ROWID) OF &#8216;EMP&#8217; (Cost=2 Card=1  					Bytes=12)</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> 2    					1     					NESTED LOOPS (Cost=168 Card=82 Bytes=3936)</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> 3    					 2       					MERGE JOIN (CARTESIAN) (Cost=4 Card=82 Bytes=2952)</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> 4    					3         					TABLE ACCESS (FULL) OF &#8216;DEPT&#8217; (Cost=2 Card=1  					Bytes=10)</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> 5    					3         					BUFFER (SORT) (Cost=2 Card=82 Bytes=2132)</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> 6    					5           					TABLE ACCESS (FULL) OF &#8216;BONUS&#8217; (Cost=2 Card=82 Bytes=2132)</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> 7    					2       					INDEX (RANGE SCAN) OF &#8216;IX_EMP_01&#8242; (NON-UNIQUE)  					(Cost=1 Card=1)</span><span style="font-size:small;"><br />
</span></p>
<p><span style="font-size:small;"> </span></p>
</div>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">This is a little tougher…. </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">The execution order is  				4,6,5,3,7,2,1. </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">Let’s diagram it!<br />
</span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"><img src="http://www.dba-oracle.com/images/img3C.jpg" alt="" width="271" height="287" /></span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;"> Here we see that step 2 has two children, three and seven,  					and step 3 has two children, four and five.  Step 5 has  					a lone child, step 6.</span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> Following our rules for preorder traversal, the  					execution plan steps start at step 4. </span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
</div>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;">Final Exam!  				What are the steps for this execution plan?</span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<p><span style="font-size:small;"> </span></p>
<div><span style="font-size:small;"> </span><span style="font-size:small;"> Execution Plan</span>
<p>&nbsp;</p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span></p>
<p><span style="font-size:small;"> </span>0      					 				<span style="font-size:small;"> SELECT STATEMENT Optimizer=CHOOSE (Cost=2871 Card=2  					Bytes=143)</span></p>
<p><span style="font-size:small;"> </span><span style="font-size:small;"> 1    					0    					 				<span style="font-size:small;"> UNION-ALL</span></span></p>
<p><span style="font-size:small;"><span style="font-size:small;"> </span></span><span style="font-size:small;"><span style="font-size:small;"> 2    					1     					 				<span style="font-size:small;"> SORT (GROUP BY) (Cost=2003 Card=1 Bytes=59)</span></span></span></p>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> 3    					2       					 				<span style="font-size:small;"> FILTER</span></span></span></span></p>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> 4    					3         					 				<span style="font-size:small;"> HASH JOIN (Cost=1999 Card=1 Bytes=59)</span></span></span></span></span></p>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> 5    					4           					 				<span style="font-size:small;"> INDEX (FAST FULL SCAN) OF &#8216;XIN8OPS_FLT_LEG&#8217; (UNIQUE) </span></span></span></span></span></span></p>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> 6    					4           					 				<span style="font-size:small;"> INDEX (RANGE SCAN) OF &#8216;XIN3BAG_TAG_FLT_LEG&#8217; (UNIQUE) </span></span></span></span></span></span></span></p>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> 7    					1     					 				<span style="font-size:small;"> SORT (GROUP BY) (Cost=868 Card=1 Bytes=84)</span></span></span></span></span></span></span></span></p>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span></span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> 8    					7       					 				<span style="font-size:small;"> FILTER</span></span></span></span></span></span></span></span></span></p>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span></span></span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> 9    					8         					 				<span style="font-size:small;"> NESTED LOOPS (Cost=864 Card=1 Bytes=84)</span></span></span></span></span></span></span></span></span></span></p>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span></span></span></span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> <span style="font-size:small;"> 10    9           					HASH JOIN (Cost=862 Card=1 Bytes=57)</span></span></span></span></span></span></span></span></span></span></span></p>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span></span></span></span></span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> <span style="font-size:small;"> 11   10             					INDEX (FAST FULL SCAN) OF &#8216;XIN1SCHED_FLT_LEG&#8217;  					(UNIQUE) </span></span></span></span></span></span></span></span></span></span></span></span></p>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span></span></span></span></span></span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> <span style="font-size:small;"> 12   10             					INDEX (FAST FULL SCAN) OF &#8216;XIN8OPS_FLT_LEG&#8217; (UNIQUE) </span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span></span></span></span></span></span></span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> <span style="font-size:small;"> 13    9           					 					 					 					INDEX (RANGE SCAN) OF &#8216;XIN2BAG_TAG_FLT_LEG&#8217; (UNIQUE) </span></span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span></span></span></span></span></span></span></span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></p>
</div>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><strong> Answer:  The order  				of operations is 5, 6, 4, 3, 2, 11, 12, 10, 13, 9, 8, 7, 1. </strong></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span> </span> </span> </span> </span> </span> </span> </span> </span> </span> </span> </span> </span> </span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deepthinking99.wordpress.com/801/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deepthinking99.wordpress.com/801/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deepthinking99.wordpress.com/801/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deepthinking99.wordpress.com/801/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deepthinking99.wordpress.com/801/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deepthinking99.wordpress.com/801/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deepthinking99.wordpress.com/801/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deepthinking99.wordpress.com/801/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deepthinking99.wordpress.com/801/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deepthinking99.wordpress.com/801/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deepthinking99.wordpress.com&blog=4894307&post=801&subd=deepthinking99&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://deepthinking99.wordpress.com/2009/11/26/ksjdhsjkhd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1f3b6fbee19bb2cca5ced85efa030302?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">deepthinking99</media:title>
		</media:content>

		<media:content url="http://www.dba-oracle.com/images/sql_execution_plan_steps.jpg" medium="image" />

		<media:content url="http://www.dba-oracle.com/images/img2B.jpg" medium="image" />

		<media:content url="http://www.dba-oracle.com/images/img2D.jpg" medium="image" />

		<media:content url="http://www.dba-oracle.com/images/img2F.jpg" medium="image" />

		<media:content url="http://www.dba-oracle.com/images/img31.jpg" medium="image" />

		<media:content url="http://www.dba-oracle.com/images/img33.jpg" medium="image" />

		<media:content url="http://www.dba-oracle.com/images/img35.jpg" medium="image" />

		<media:content url="http://www.dba-oracle.com/images/img3C.jpg" medium="image" />
	</item>
		<item>
		<title>Cloning Database using RMan</title>
		<link>http://deepthinking99.wordpress.com/2009/11/20/cloning-database-using-rman/</link>
		<comments>http://deepthinking99.wordpress.com/2009/11/20/cloning-database-using-rman/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 09:00:16 +0000</pubDate>
		<dc:creator>Ida Bagus Enderajana</dc:creator>
				<category><![CDATA[Oracle Database Backup]]></category>

		<guid isPermaLink="false">http://deepthinking99.wordpress.com/?p=795</guid>
		<description><![CDATA[

Overview
A powerful feature of RMAN is the ability to            duplicate (clone), a database from a backup. It is possible to create            a duplicate database on:

A remote server with the same file structure
A remote [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deepthinking99.wordpress.com&blog=4894307&post=795&subd=deepthinking99&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><tr>
<td width="941" height="10" valign="top">
<h2>Overview</h2>
<blockquote><p>A powerful feature of RMAN is the ability to            duplicate (clone), a database from a backup. It is possible to create            a duplicate database on:</p>
<ul>
<li>A remote server with the same file structure</li>
<li>A remote server with              a different file structure</li>
<li>The local server with a different file              structure</li>
</ul>
<p>A duplicate database           is distinct from a standby database, although            both types of databases are created with the <strong>DUPLICATE</strong> command.            A standby database is a copy of the primary database that you can            update continually or periodically by using archived logs from the            primary database. If the primary database is damaged or destroyed,            then you can perform failover to the standby database and effectively            transform it into the new primary database. A duplicate database, on            the other hand, cannot be used in this way: it is not intended for            failover scenarios and does not support the various standby recovery            and failover options.</p>
<p>To prepare for database duplication, you must            first create an auxiliary instance. For the duplication to work, you            must connect RMAN to both the target (primary) database and an            auxiliary instance started in NOMOUNT mode.</p>
<p>So long as RMAN is able to connect to the            primary and duplicate instances, the RMAN client can run on any            machine. However, all backups, copies of datafiles, and archived logs            used for creating and recovering the duplicate database must be            accessible by the server session on the duplicate host.</p>
<p>As part of the duplicating operation, RMAN            manages the following:</p>
<ul>
<li>Restores the target datafiles to the              duplicate database and performs incomplete recovery by using all              available backups and archived logs.</li>
<li>Shuts down and starts the auxiliary database.</li>
<li>Opens the duplicate database with the              RESETLOGS option after incomplete recovery to create the online redo              logs.</li>
<li>Generates a new, unique DBID for the              duplicate database.</li>
</ul>
</blockquote>
</td>
</tr>
<tr>
<td width="941" height="9" valign="top">
<h2>Preparing the Duplicate (Auxiliary) Instance for        Duplication</h2>
<p>Create an Oracle Password File</p>
<blockquote><p>First we must create a password          file for the duplicate instance.</p>
<p><strong>export ORACLE_SID=APP2<br />
orapwd file=orapwAPP2 password=manager entries=5 force=y</strong></p></blockquote>
<p>Ensure Oracle Net Connectivity to both        Instances</p>
<blockquote><p>Next add the appropriate entries          into the TNSNAMES.ORA and LISTENER.ORA files in the $TNS_ADMIN directory.</p></blockquote>
<p>LISTENER.ORA</p>
<blockquote><p><span style="color:#ff0000;">APP1 = Target          Database</span>, <span style="color:#008000;">APP2 = Auxiliary Database</span></p>
<p>LISTENER =<br />
(DESCRIPTION_LIST =<br />
(DESCRIPTION =<br />
(ADDRESS = (PROTOCOL = TCP)(HOST = gentic)(PORT =          1521))<br />
)<br />
)</p>
<p>SID_LIST_LISTENER =<br />
(SID_LIST =<br />
(SID_DESC =<br />
(GLOBAL_DBNAME = APP1.WORLD)<br />
(ORACLE_HOME = /opt/oracle/product/10.2.0)<br />
<strong><span style="color:#ff0000;">(SID_NAME = APP1)</span></strong><br />
)<br />
(SID_DESC =<br />
(GLOBAL_DBNAME = APP2.WORLD)<br />
(ORACLE_HOME = /opt/oracle/product/10.2.0)<br />
<strong><span style="color:#008000;">(SID_NAME = APP2)</span></strong><br />
)<br />
)</p></blockquote>
<p>TNSNAMES.ORA</p>
<blockquote><p><span style="color:#ff0000;">APP1 = Target          Database</span>, <span style="color:#008000;">APP2 = Auxiliary Database</span></p>
<p><strong><span style="color:#ff0000;"> APP1.WORLD</span></strong> =<br />
(DESCRIPTION =<br />
(ADDRESS_LIST =<br />
(ADDRESS = (PROTOCOL = TCP)(HOST = gentic)(PORT =          1521))<br />
)<br />
(CONNECT_DATA =<br />
(SERVICE_NAME = APP1.WORLD)<br />
)<br />
)</p>
<p><strong><span style="color:#008000;">APP2.WORLD</span></strong> =<br />
(DESCRIPTION =<br />
(ADDRESS_LIST =<br />
(ADDRESS = (PROTOCOL = TCP)(HOST = gentic)(PORT =          1521))<br />
)<br />
(CONNECT_DATA =<br />
(SERVICE_NAME = APP2.WORLD)<br />
)<br />
)</p></blockquote>
<p>SQLNET.ORA</p>
<blockquote><p>NAMES.DIRECTORY_PATH= (TNSNAMES)<br />
NAMES.DEFAULT_DOMAIN = WORLD<br />
NAME.DEFAULT_ZONE = WORLD<br />
USE_DEDICATED_SERVER = ON</p>
<p>Now restart the Listener</p>
<p><strong>lsnrctl stop<br />
lsnrctl start</strong></p></blockquote>
<p>Create an Initialization Parameter File        for the Auxiliary Instance</p>
<blockquote><p>Create an INIT.ORA parameter file          for the auxiliary instance, you can copy that from the target instance          and then modify the parameters.</p>
<p>### Duplicate Database<br />
### &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
# This is only used when you duplicate the database<br />
# on the same host to avoid name conflicts</p>
<p><strong>DB_FILE_NAME_CONVERT                       = (/u01/oracle/db/APP1/,/u01/oracle/db/APP2/)<br />
LOG_FILE_NAME_CONVERT                      = (/u01/oracle/db/APP1/,/u01/oracle/db/APP2/,<br />
/opt/oracle/db/APP1/,/opt/oracle/db/APP2/)<br />
</strong><br />
### Global database name is db_name.db_domain<br />
### &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>db_name                                    = APP2<br />
db_unique_name                             = APP2_GENTIC<br />
db_domain                                  = WORLD<br />
service_names                              = APP2<br />
instance_name                              = APP2</p>
<p>### Basic Configuration Parameters<br />
### &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>compatible                                 = 10.2.0.4<br />
db_block_size                              = 8192<br />
db_file_multiblock_read_count     = 32<br />
db_files                                   = 512<br />
control_files                              = /u01/oracle/db/APP2/con/APP2_con01.con,<br />
/opt/oracle/db/APP2/con/APP2_con02.con</p>
<p>### Database Buffer Cache, I/O<br />
### &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
# The Parameter SGA_TARGET enables Automatic Shared Memory Management</p>
<p>sga_target                                 = 500M<br />
sga_max_size                               = 600M</p>
<p>### REDO Logging without Data Guard<br />
### &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>log_archive_format                         = APP2_%s_%t_%r.arc<br />
log_archive_max_processes                  = 2<br />
log_archive_dest                           = /u01/oracle/db/APP2/arc</p>
<p>### System Managed Undo<br />
### &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>undo_management                            = auto<br />
undo_retention                             = 10800<br />
undo_tablespace                            = undo</p>
<p>### Traces, Dumps and Passwordfile<br />
### &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>audit_file_dest                            = /u01/oracle/db/APP2/adm/admp<br />
user_dump_dest                             = /u01/oracle/db/APP2/adm/udmp<br />
background_dump_dest                       = /u01/oracle/db/APP2/adm/bdmp<br />
core_dump_dest                             = /u01/oracle/db/APP2/adm/cdmp<br />
utl_file_dir                               = /u01/oracle/db/APP2/adm/utld<br />
remote_login_passwordfile                  = exclusive</p></blockquote>
<p>Create a full Database Backup</p>
<blockquote><p>Make sure that a full backup of the          target is accessible on the duplicate host. You can use the following          BASH script to backup the target database.</p>
<p>rman nocatalog target / &lt;&lt;-EOF<br />
configure retention policy to recovery window of 3 days;<br />
configure backup optimization on;<br />
configure controlfile autobackup on;<br />
configure default device type to disk;<br />
configure device type disk parallelism 1 backup type to compressed          backupset;<br />
configure datafile backup copies for device type disk to 1;<br />
configure maxsetsize to unlimited;<br />
configure snapshot controlfile name to &#8216;/u01/backup/snapshot_controlfile&#8217;;<br />
show all;</p>
<p>run {<br />
allocate channel ch1 type Disk maxpiecesize = 1900M;<br />
backup full database noexclude<br />
include current controlfile<br />
format &#8216;/u01/backup/datafile_%s_%p.bak&#8217;<br />
tag &#8216;datafile_daily&#8217;;<br />
}</p>
<p>run {<br />
allocate channel ch1 type Disk maxpiecesize = 1900M;<br />
backup archivelog all<br />
delete all input<br />
format &#8216;/u01/backup/archivelog_%s_%p.bak&#8217;<br />
tag &#8216;archivelog_daily&#8217;;<br />
}</p>
<p>run {<br />
allocate channel ch1 type Disk maxpiecesize =          1900M;<br />
backup format &#8216;/u01/backup/controlfile_%s.bak&#8217;          current controlfile;<br />
}</p>
<p>crosscheck backup;<br />
list backup of database;<br />
report unrecoverable;<br />
report schema;<br />
report need backup;<br />
report obsolete;<br />
delete noprompt expired backup of database;<br />
delete noprompt expired backup of controlfile;<br />
delete noprompt expired backup of archivelog all;<br />
delete noprompt obsolete recovery window of 3 days;<br />
quit<br />
EOF</p></blockquote>
<h2>Creating a Duplicate Database on the Local Host</h2>
<blockquote><p>Before beginning RMAN duplication, use SQL*Plus to          connect to the auxiliary instance and start it in NOMOUNT mode. If you          do not have a server-side initialization parameter file for the          auxiliary instance in the default location, then you must specify the          client-side initialization parameter file with the PFILE parameter on          the DUPLICATE command.</p>
<p><img src="http://www.akadia.com/img/ora_duplicate_database_rman_1.gif" border="0" alt="" width="428" height="204" /></p></blockquote>
<p>Get original Filenames from TARGET</p>
<blockquote><p>To rename the database files you can use the SET          NEWNAME command. Therefore, get the original filenames from the target          and modify these names in the DUPLICATE command.</p>
<p><strong>ORACLE_SID=<span style="color:#ff0000;">APP1</span><br />
export ORACLE_SID</strong></p>
<p>set feed off<br />
set pagesize 10000<br />
column name format a40 heading &#8220;Datafile&#8221;<br />
column file# format 99 heading &#8220;File-ID&#8221;</p>
<p>select  name, file# from v$dbfile;</p>
<p>column member format a40 heading &#8220;Logfile&#8221;<br />
column group# format 99 heading &#8220;Group-Nr&#8221;</p>
<p>select  member, group# from v$logfile;</p>
<p>Datafile                                           File-ID<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-  &#8212;&#8212;-<br />
/u01/oracle/db/APP1/sys/APP1_sys1.dbf                    1<br />
/u01/oracle/db/APP1/sys/APP1_undo1.dbf                   2<br />
/u01/oracle/db/APP1/sys/APP1_sysaux1.dbf                 3<br />
/u01/oracle/db/APP1/usr/APP1_users1.dbf                  4</p>
<p>Logfile                                           Group-Nr<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8211;<br />
/u01/oracle/db/APP1/rdo/APP1_log1A.rdo                   1<br />
/opt/oracle/db/APP1/rdo/APP1_log1B.rdo                   1<br />
/u01/oracle/db/APP1/rdo/APP1_log2A.rdo                   2<br />
/opt/oracle/db/APP1/rdo/APP1_log2B.rdo                   2<br />
/u01/oracle/db/APP1/rdo/APP1_log3A.rdo                   3<br />
/opt/oracle/db/APP1/rdo/APP1_log3B.rdo                   3<br />
/u01/oracle/db/APP1/rdo/APP1_log4A.rdo                   4<br />
/opt/oracle/db/APP1/rdo/APP1_log4B.rdo                   4<br />
/u01/oracle/db/APP1/rdo/APP1_log5A.rdo                   5<br />
/opt/oracle/db/APP1/rdo/APP1_log5B.rdo                   5<br />
/u01/oracle/db/APP1/rdo/APP1_log6A.rdo                   6<br />
/opt/oracle/db/APP1/rdo/APP1_log6B.rdo                   6<br />
/u01/oracle/db/APP1/rdo/APP1_log7A.rdo                   7<br />
/opt/oracle/db/APP1/rdo/APP1_log7B.rdo                   7<br />
/u01/oracle/db/APP1/rdo/APP1_log8A.rdo                   8<br />
/opt/oracle/db/APP1/rdo/APP1_log8B.rdo                   8<br />
/u01/oracle/db/APP1/rdo/APP1_log9A.rdo                   9<br />
/opt/oracle/db/APP1/rdo/APP1_log9B.rdo                   9<br />
/u01/oracle/db/APP1/rdo/APP1_log10A.rdo                 10<br />
/opt/oracle/db/APP1/rdo/APP1_log10B.rdo                 10</p></blockquote>
<p>Create Directories for the duplicate Database</p>
<blockquote><p><strong>mkdir -p /u01/oracle/db/APP2<br />
mkdir -p /opt/oracle/db/APP2<br />
cd /opt/oracle/db/APP2<br />
mkdir con rdo<br />
cd /u01/oracle/db/APP2<br />
mkdir adm arc con rdo sys tmp usr bck<br />
cd adm<br />
mkdir admp bdmp cdmp udmp utld</strong></p></blockquote>
<p><strong>Create Symbolic Links to Password and INIT.ORA File</strong></p>
<blockquote><p>Oracle must be able to locate the Password and INIT.ORA File.</p>
<p><strong>cd $ORACLE_HOME/dbs<br />
ln -s /home/oracle/config/10.2.0/orapwAPP2 orapwAPP2<br />
ln -s /home/oracle/config/10.2.0/initAPP2.ora initAPP2.ora</strong></p></blockquote>
<p><strong>Duplicate the Database</strong></p>
<blockquote><p>Now you are ready to duplicate the database APP1          to APP2.</p>
<p><strong>ORACLE_SID=<span style="color:#008000;">APP2</span><br />
export ORACLE_SIDsqlplus sys/manager as sysdba<br />
startup force nomount pfile=&#8217;/home/oracle/config/10.2.0/initAPP2.ora&#8217;;<br />
exit;</p>
<p></strong></p>
<p><strong>rman TARGET sys/manager@APP1          AUXILIARY sys/manager@APP2</strong></p>
<p><span style="color:#0000ff;">Recovery          Manager: Release 10.2.0.4.0 &#8211; Production on Tue Oct 28 12:00:13 2008<br />
Copyright (c) 1982, 2007, Oracle. All rights reserved.<br />
connected to target database: APP1 (DBID=3191823649)<br />
connected to auxiliary database: APP2 (not mounted)</span></p>
<p><strong>RUN<br />
{<br />
SET NEWNAME FOR DATAFILE 1 TO &#8216;/u01/oracle/db/APP2/sys/APP2_sys1.dbf&#8217;;<br />
SET NEWNAME FOR DATAFILE 2 TO &#8216;/u01/oracle/db/APP2/sys/APP2_undo1.dbf&#8217;;<br />
SET NEWNAME FOR DATAFILE 3 TO &#8216;/u01/oracle/db/APP2/sys/APP2_sysaux1.dbf&#8217;;<br />
SET NEWNAME FOR DATAFILE 4 TO &#8216;/u01/oracle/db/APP2/usr/APP2_users1.dbf&#8217;;<br />
DUPLICATE TARGET DATABASE TO APP2<br />
PFILE = /home/oracle/config/10.2.0/initAPP2.ora<br />
NOFILENAMECHECK<br />
LOGFILE GROUP 1 (&#8216;/u01/oracle/db/APP2/rdo/APP2_log1A.rdo&#8217;,<br />
&#8216;/opt/oracle/db/APP2/rdo/APP2_log1B.rdo&#8217;) SIZE 10M REUSE,<br />
GROUP 2 (&#8216;/u01/oracle/db/APP2/rdo/APP2_log2A.rdo&#8217;,<br />
&#8216;/opt/oracle/db/APP2/rdo/APP2_log2B.rdo&#8217;) SIZE 10M REUSE,<br />
GROUP 3 (&#8216;/u01/oracle/db/APP2/rdo/APP2_log3A.rdo&#8217;,<br />
&#8216;/opt/oracle/db/APP2/rdo/APP2_log3B.rdo&#8217;) SIZE 10M REUSE,<br />
GROUP 4 (&#8216;/u01/oracle/db/APP2/rdo/APP2_log4A.rdo&#8217;,<br />
&#8216;/opt/oracle/db/APP2/rdo/APP2_log4B.rdo&#8217;) SIZE 10M REUSE,<br />
GROUP 5 (&#8216;/u01/oracle/db/APP2/rdo/APP2_log5A.rdo&#8217;,<br />
&#8216;/opt/oracle/db/APP2/rdo/APP2_log5B.rdo&#8217;) SIZE 10M REUSE,<br />
GROUP 6 (&#8216;/u01/oracle/db/APP2/rdo/APP2_log6A.rdo&#8217;,<br />
&#8216;/opt/oracle/db/APP2/rdo/APP2_log6B.rdo&#8217;) SIZE 10M REUSE,<br />
GROUP 7 (&#8216;/u01/oracle/db/APP2/rdo/APP2_log7A.rdo&#8217;,<br />
&#8216;/opt/oracle/db/APP2/rdo/APP2_log7B.rdo&#8217;) SIZE 10M REUSE,<br />
GROUP 8 (&#8216;/u01/oracle/db/APP2/rdo/APP2_log8A.rdo&#8217;,<br />
&#8216;/opt/oracle/db/APP2/rdo/APP2_log8B.rdo&#8217;) SIZE 10M REUSE,<br />
GROUP 9 (&#8216;/u01/oracle/db/APP2/rdo/APP2_log9A.rdo&#8217;,<br />
&#8216;/opt/oracle/db/APP2/rdo/APP2_log9B.rdo&#8217;) SIZE 10M REUSE,<br />
GROUP 10 (&#8216;/u01/oracle/db/APP2/rdo/APP2_log10A.rdo&#8217;,<br />
&#8216;/opt/oracle/db/APP2/rdo/APP2_log10B.rdo&#8217;) SIZE 10M REUSE;<br />
}</strong></p>
<p>The whole, long output is not shown here, but          check, that RMAN was able to open the duplicate database with the          RESETLOGS option.</p>
<p><span style="color:#0000ff;">&#8230;..<br />
&#8230;..<br />
contents of Memory Script:<br />
{<br />
Alter clone database open resetlogs;<br />
}<br />
executing Memory Scriptdatabase opened<br />
Finished Duplicate Db at 28-OCT-08</p>
<p></span></p>
<p>As the final step, eliminate or uncomment the         <span style="font-family:&amp;">DB_FILE_NAME_CONVERT</span> and         <span style="font-family:&amp;">LOG_FILE_NAME_CONVERT</span> in the INIT.ORA          file and restart the database.</p></blockquote>
<p>initAPP2.ora</p>
<blockquote><p>### Duplicate Database<br />
### &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
# This is only used when you duplicate the database<br />
# on the same host to avoid name conflicts<br />
# DB_FILE_NAME_CONVERT =  (/u01/oracle/db/APP1/,/u01/oracle/db/APP2/)<br />
# LOG_FILE_NAME_CONVERT = (/u01/oracle/db/APP1/,/u01/oracle/db/APP2/,<br />
/opt/oracle/db/APP1/,/opt/oracle/db/APP2/)</p>
<p><strong>sqlplus / as sysdba<br />
shutdown immediate;<br />
startup;</strong></p>
<p><span style="color:#0000ff;">Total System          Global Area 629145600 bytes<br />
Fixed Size 1269064 bytes<br />
Variable Size 251658936 bytes<br />
Database Buffers 373293056 bytes<br />
Redo Buffers 2924544 bytes<br />
Database mounted.<br />
Database opened.</span></p></blockquote>
<h2>Creating a Duplicate Database  to Remote          Host</h2>
<blockquote><p>This scenario is exactly the same as described for the          local host. Copy the RMAN Backup files to the remote host on the same          directory as on the localhost.</p>
<p><img src="http://www.akadia.com/img/ora_duplicate_database_rman_2.gif" border="0" alt="" width="464" height="212" /></p>
<p><strong>cd /u01/backup<br />
scp gentic:/u01/backup/* .</strong></p>
<p>The other steps are the same as described under «Creating a Duplicate Database on the Local Host».</p></blockquote>
</td>
</tr>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deepthinking99.wordpress.com/795/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deepthinking99.wordpress.com/795/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deepthinking99.wordpress.com/795/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deepthinking99.wordpress.com/795/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deepthinking99.wordpress.com/795/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deepthinking99.wordpress.com/795/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deepthinking99.wordpress.com/795/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deepthinking99.wordpress.com/795/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deepthinking99.wordpress.com/795/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deepthinking99.wordpress.com/795/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deepthinking99.wordpress.com&blog=4894307&post=795&subd=deepthinking99&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://deepthinking99.wordpress.com/2009/11/20/cloning-database-using-rman/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1f3b6fbee19bb2cca5ced85efa030302?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">deepthinking99</media:title>
		</media:content>

		<media:content url="http://www.akadia.com/img/ora_duplicate_database_rman_1.gif" medium="image" />

		<media:content url="http://www.akadia.com/img/ora_duplicate_database_rman_2.gif" medium="image" />
	</item>
		<item>
		<title>Database Link Survival Guide</title>
		<link>http://deepthinking99.wordpress.com/2009/11/20/database-link-survival-guide/</link>
		<comments>http://deepthinking99.wordpress.com/2009/11/20/database-link-survival-guide/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 08:58:29 +0000</pubDate>
		<dc:creator>Ida Bagus Enderajana</dc:creator>
				<category><![CDATA[Oracle Admin]]></category>

		<guid isPermaLink="false">http://deepthinking99.wordpress.com/?p=793</guid>
		<description><![CDATA[

Overview
A database link is a schema object in one database that enables you           to access objects on another database. The other database need not be an Oracle Database           system. However,      [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deepthinking99.wordpress.com&blog=4894307&post=793&subd=deepthinking99&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><tr>
<td width="1052" height="5" valign="top">
<h1>Overview</h1>
<blockquote><p>A database link is a schema object in one database that enables you           to access objects on another database. The other database need not be an Oracle Database           system. However,            <img src="http://www.akadia.com/img/ora_database_link_0.gif" border="0" alt="" hspace="10" vspace="10" width="128" height="160" align="left" />to access non-Oracle systems you must use           Oracle Heterogeneous Services.</p>
<table id="AutoNumber4" border="0" cellspacing="0" cellpadding="0" width="53%">
<tbody>
<tr>
<td width="100%">Once you have created a database link, you                 can use it to refer to tables and views on the other database. In SQL statements,                 you can refer to a table or view on the other database by appending @dblink to the                 table or view name. You can query a table or view on the other database with the                 SELECT statement. You can also access remote tables and views using any INSERT,                 UPDATE, DELETE, or LOCK TABLE statement.</td>
</tr>
</tbody>
</table>
</blockquote>
</td>
</tr>
<tr>
<td width="1052" height="5" valign="top">
<blockquote><p><img src="http://www.akadia.com/img/ora_database_link_1.gif" border="0" alt="" width="676" height="318" /></p></blockquote>
<h1>Prerequisites</h1>
<blockquote>
<ul>
<li>You must have the CREATE DATABASE LINK system             privilege.</li>
<li>You must have the CREATE SESSION system privilege on the remote             Oracle database.</li>
<li>You must be able to connect to the remote database.</li>
<li>Check GLOBAL_NAMES &#8211; to setup the name of the database             link.</li>
</ul>
</blockquote>
<p>DB_NAME</p>
<blockquote><p>The DB_NAME parameter is the SID of the database and is the name           used when creating the database. It is specified within the INIT.ORA parameter file or in           the CREATE DATABASE command.</p>
<p>select name, value from v$parameter where name =           &#8216;db_name&#8217;;</p></blockquote>
<p>DB_DOMAN</p>
<blockquote><p>The DB_DOMAIN parameter is the value of the domain           to which the database belongs. It can be the same as defined in the DNS &#8211; and is usually           the company name. However you can set a DB_DOMAIN value which is not part of the           DNS.</p>
<p>select name, value from v$parameter where name =           &#8216;db_domain&#8217;;</p></blockquote>
<p>GLOBAL_NAMES</p>
<blockquote><p>GLOBAL_NAMES dictates how you might connect to a database. This           variable is either <strong>TRUE</strong> or <strong>FALSE</strong> and if it is set to TRUE it enforces           database links to have the same name as the remote database to which they are connecting.           Usually GLOBAL_NAMES is set to TRUE.</p>
<p>select name, value from v$parameter where name =           &#8216;global_names&#8217;;</p></blockquote>
<p>Setting the Name of the Database Link</p>
<blockquote><p>You can query GLOBAL_NAME on the remote database to find out how           the name of the database name has to be on the local database.</p>
<p>CELLAR&gt; sqlplus system/&#8230;@GENTIC</p>
<p>SQL&gt; <strong>select global_name from global_name;</p>
<p></strong> <span style="color:#0000ff;">GENTIC.COMPANY.COM</span></p>
<p>So you have to set the database link name to GENTIC.COMPANY.COM if           GLOBAL_NAMES is TRUE.</p></blockquote>
<p>SQLNET</p>
<blockquote><p>Setup your TNSNAMES.ORA so you can connect to the remote           database.</p>
<p><span style="color:#ff00ff;"><strong>GENTIC</strong></span> =<br />
(DESCRIPTION =<br />
(ADDRESS = (PROTOCOL = TCP)(HOST = gentic.company.com)(PORT = 1521))<br />
(CONNECT_DATA =<br />
(SERVER = DEDICATED)<br />
(SERVICE_NAME = GENTIC.COMPANY.COM)<br />
)<br />
)</p>
<p>CELLAR =<br />
(DESCRIPTION =<br />
(ADDRESS = (PROTOCOL = TCP)(HOST = cellar.company.com)(PORT = 1521))<br />
(CONNECT_DATA =<br />
(SERVER = DEDICATED)<br />
(SERVICE_NAME = CELLAR.COMPANY.COM)<br />
)<br />
)</p></blockquote>
<h1>Refer to Remote Table(s)</h1>
<blockquote><p>Suppose you want to refer to the table scott.aTable on GENTIC from           CELLAR. On CELLAR the same name scott.aTable should be used &#8211; so you don&#8217;t have to change           any code.</p>
<p>sqlplus system/&#8230;.@CELLAR</p>
<p>SQL&gt; <strong>CREATE DATABASE LINK           GENTIC.COMPANY.COM<br />
CONNECT TO</strong> <strong>scott IDENTIFIED BY           &#8230;..<br />
USING &#8216;<span style="color:#ff00ff;">GENTIC</span>&#8216;;<br />
</strong><br />
<span style="color:#0000ff;">Database link created.</span></p>
<p>SQL&gt; <strong>DESC           scott.aTable@GENTIC.COMPANY.COM;</strong></p>
<p><span style="color:#0000ff;">Name                                                Null?    Type<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8211;<br />
</span> <span style="color:#0000ff;">LANGUAGE                                            NOT NULL VARCHAR2(2)<br />
ACTIVE                                              NOT NULL NUMBER<br />
TEXT                                                         VARCHAR2(20)</span></p>
<p>SQL&gt; <strong>SELECT * FROM           scott.aTable@GENTIC.COMPANY.COM;<br />
</strong><br />
<span style="color:#0000ff;">no rows selected</span></p>
<p>SQL&gt; <strong>CREATE SYNONYM scott.aTable FOR           scott.aTable@GENTIC.COMPANY.COM;<br />
</strong><br />
<span style="color:#0000ff;">Synonym created.</span></p>
<p>SQL&gt; <strong>SELECT *</strong> <strong>FROM scott.aTable;<br />
</strong><br />
<span style="color:#0000ff;">no rows selected</span></p>
<p>SQL&gt; <strong>INSERT INTO scott.aTable(language,           active, text) VALUES (&#8216;de&#8217;,1,&#8217;german&#8217;);</strong><br />
SQL&gt; <strong>INSERT INTO scott.aTable(language, active, text) VALUES           (&#8216;en&#8217;,1,&#8217;english&#8217;);</strong><br />
SQL&gt; <strong>INSERT INTO scott.aTable(language, active, text) VALUES           (&#8216;fr&#8217;,1,&#8217;french&#8217;);</strong><br />
SQL&gt; <strong>INSERT INTO scott.aTable(language, active, text) VALUES           (&#8216;it&#8217;,1,&#8217;italian&#8217;);</strong><br />
SQL&gt; <strong>INSERT INTO scott.aTable(language, active, text) VALUES           (&#8216;ru&#8217;,0,&#8217;russian&#8217;);</strong><br />
SQL&gt; <strong>COMMIT;</strong></p>
<p>SQL&gt; <strong>SELECT *</strong> <strong>FROM scott.aTable;</strong><strong><br />
</strong><br />
<span style="color:#0000ff;">LANGUA     ACTIVE TEXT<br />
&#8212;&#8212; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
de              1           german<br />
en              1           english<br />
fr              1           french<br />
it              1           italian<br />
ru              0           russian</span></p>
<table id="AutoNumber1" border="1" cellspacing="3" cellpadding="3" width="90%" bgcolor="#ffff00">
<tbody>
<tr>
<td width="100%" bgcolor="#ffff00">As you can see, accessing the               remote table is fully transparent to the application. Exactly the same syntax can be               used for the remote table if you create a synonym for the remote table.</td>
</tr>
</tbody>
</table>
</blockquote>
<h1>Executing Remote Procedures</h1>
<blockquote><p>You can also execute remote procedures &#8230;</p>
<p><img src="http://www.akadia.com/img/ora_database_link_2.gif" border="0" alt="" width="669" height="217" /></p>
<p>&#8230; here an example without synonym.</p>
<p>sqlplus system/&#8230;.@CELLAR</p>
<p>SQL&gt; <strong>DESC</strong> <strong>scott.aPackage@GENTIC.COMPANY.COM;</strong></p>
<p><span style="color:#0000ff;">PROCEDURE aProcedure</p>
<p>Argument           Name                            Type                              In/Out Default?<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212; &#8212;&#8212;&#8211;<br />
USER_ID                                            NUMBER(10)                        IN<br />
A_NAME                                             VARCHAR2(32)            IN<br />
A_CONTENT                                VARCHAR2(4000)          IN<br />
A_DEFAULT                                NUMBER(1)                         IN</span></p>
<pre>SQL&gt; <strong>EXECUTE</strong><strong> scott.aPackage.aProcedure@GENTIC.COMPANY.COM(1,'Test','Test',0);
</strong>
<span style="color:#0000ff;">PL/SQL procedure successfully completed.</span></pre>
<p>And now the same with synonyms.</p>
<p>SQL&gt; <strong>CREATE SYNONYM scott.aPackage for           scott.aPackage@GENTIC.COMPANY.COM;</strong><br />
<span style="color:#0000ff;"><br />
Synonym created.</span></p>
<p>SQL&gt; <strong>EXECUTE</strong> <strong>scott.aPackage.aProcedure(1,&#8217;Test&#8217;,'Test&#8217;,0);</strong></p>
<p><span style="color:#0000ff;">PL/SQL procedure successfully completed.</span></p>
<table id="AutoNumber1" border="1" cellspacing="3" cellpadding="3" width="90%" bgcolor="#ffff00">
<tbody>
<tr>
<td width="100%" bgcolor="#ffff00">As you can see, executing               remote procedures is fully transparent to the application. Exactly the same syntax               can be used for the remote package if you create a synonym for the remote               package.</td>
</tr>
</tbody>
</table>
</blockquote>
<h1>Distributed / In-Doubt Transactions</h1>
<blockquote><p>A <strong>distributed transaction</strong> includes one or more statements           that, individually or as a group, update data on two or more distinct nodes of a           distributed database.</p>
<p>The <strong>two-phase commit</strong> mechanism ensures that all nodes either           commit or perform a rollback together. What happens if the transaction fails because of a           system or network error? The transaction becomes <strong>in-doubt</strong>.</p>
<p>Distributed transactions can become in-doubt in the following           ways:</p>
<ul>
<li>A server machine running Oracle software crashes.</li>
<li>A network connection between two or more Oracle databases             involved in distributed processing is disconnected.</li>
<li>An unhandled software error occurs.</li>
</ul>
<p>The RECO process automatically resolves in-doubt transactions when           the machine, network, or software problem is resolved. Until RECO can resolve the           transaction, the data is locked for both reads and writes. Oracle blocks reads because it           cannot determine which version of the data to display for a query.</p></blockquote>
<p>Manually Committing an In-Doubt Transaction</p>
<blockquote><p>Suppose, the database  server GENTIC crashes           during a distributed transaction.</p>
<p><img src="http://www.akadia.com/img/ora_database_link_3.gif" border="0" alt="" width="680" height="270" /></p>
<p>Prepare distributed transaction</p>
<p>SQL&gt; CREATE SYNONYM scott.aTable FOR           scott.aTable@GENTIC.COMPANY.COM;<br />
SQL&gt; SELECT * from scott.aTable;<br />
SQL&gt; CREATE TABLE scott.bTable (count NUMBER);</p>
<p>Start the distributed transaction</p>
<p>SQL&gt; INSERT INTO scott.bTable (count) values           (1);<br />
SQL&gt; INSERT INTO scott.bTable (count) values (2);<br />
SQL&gt; INSERT INTO scott.bTable (count) values (3);<br />
SQL&gt; INSERT INTO scott.bTable (count) values (4);<br />
SQL&gt; INSERT INTO scott.bTable (count) values (5);<br />
SQL&gt; INSERT INTO scott.aTable(language, active, text) VALUES (&#8216;de&#8217;,1,&#8217;german&#8217;);<br />
SQL&gt; INSERT INTO scott.aTable(language, active, text) VALUES (&#8216;en&#8217;,1,&#8217;english&#8217;);<br />
SQL&gt; INSERT INTO scott.aTable(language, active, text) VALUES (&#8216;fr&#8217;,1,&#8217;french&#8217;);<br />
SQL&gt; INSERT INTO scott.aTable(language, active, text) VALUES (&#8216;it&#8217;,1,&#8217;italian&#8217;);<br />
SQL&gt; INSERT INTO scott.aTable(language, active, text) VALUES (&#8216;ru&#8217;,0,&#8217;russian&#8217;);<br />
SQL&gt; UPDATE scott.bTable SET count = 2 WHERE count = 1;</p>
<p>Now shutdown the distributed database</p>
<p>GENTIC&gt; sqlplus / as sysdba;<br />
shutdown abort;</p>
<p>Now try to COMMIT the distributed           transaction</p>
<p>SQL&gt; commit;</p>
<p><span style="color:#0000ff;">ERROR at line 1:<br />
ORA-02054: transaction 1.37.5070 in-doubt<br />
ORA-02068: following severe error from GENTIC<br />
ORA-03113: end-of-file on communication channel</span></p>
<p>Now check the DBA_2PC_PENDING view for the           LOCAL_TRAN_ID.</p>
<p>SET LINESIZE 500;<br />
COL LOCAL_TRAN_ID FORMAT A13<br />
COL GLOBAL_TRAN_ID FORMAT A50<br />
COL STATE FORMAT A8<br />
COL MIXED FORMAT A3<br />
COL HOST FORMAT A10<br />
COL COMMIT# FORMAT A10</p>
<p><strong>SELECT LOCAL_TRAN_ID, GLOBAL_TRAN_ID, STATE, MIXED, HOST, COMMIT#<br />
FROM DBA_2PC_PENDING</strong><br />
/</p>
<p><span style="color:#0000ff;">LOCAL_TRAN_ID           GLOBAL_TRAN_ID                                  STATE    MIX HOST       COMMIT#<br />
&#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8211; &#8212; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;<br />
<strong>1.37.5070</strong> CELLAR.COMPANY.COM.a05b1b48.1.37.5070 prepared no  cellar     15508150</span></p>
<p>Now manually commit or rollback force the in-doubt transaction as           user SYS</p>
<p>SQL&gt; exit;</p>
<p>sqlplus / as sysdba</p>
<p>SQL&gt; <strong>COMMIT FORCE &#8216;1.37.5070&#8242;;</strong></p>
<p><span style="color:#0000ff;">Commit complete.</span></p>
<p>Manually remove an entry from the data dictionary</p>
<p>SQL&gt; <strong>EXECUTE           DBMS_TRANSACTION.PURGE_LOST_DB_ENTRY(&#8216;1.37.5070&#8242;);</strong></p>
<p><span style="color:#0000ff;">PL/SQL procedure successfully completed.</span></p>
<p>More Information to Distributed Transactions can be found           <strong><a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/ds_txnman.htm#ADMIN032" target="_top">here</a></strong></p></blockquote>
<h1><strong>Database Link Types</strong></h1>
<blockquote><p>When you create a database link, you must decide who will have access to it. The           following sections describe how to create the basic types of links.</p></blockquote>
<p>Following are examples of private database links</p>
<blockquote>
<table id="AutoNumber2" border="1" cellspacing="3" cellpadding="3" width="90%">
<tbody>
<tr>
<th width="311" align="left" valign="bottom">SQL Statement</th>
<th width="465" align="left" valign="bottom">Result</th>
</tr>
<tr>
<td width="311" align="left" valign="top"><code>CREATE DATABASE LINK <em>link_name</em>;</code></td>
<td width="465" align="left" valign="top">A private link using the global database name to the remote database.The link uses the userid/password of the connected user. So if                 <code>scott</code> uses the link in a query, the link establishes a connection to                 the remote database as <code>scott</code>.</td>
</tr>
<tr>
<td width="311" align="left" valign="top"><code>CREATE DATABASE LINK <em>link_name<br />
</em> CONNECT TO user                 IDENTIFIED BY ...<br />
USING 'service';</code></td>
<td width="465" align="left" valign="top">A private fixed               user link to the database with service name <span style="font-family:&quot;">service</span>.               The link connects to the remote database with the userid/password regardless of the               connected user.</td>
</tr>
<tr>
<td width="311" align="left" valign="top"><code>CREATE DATABASE LINK <em>link_name<br />
</em> CONNECT TO                 CURRENT_USER USING 'service';</code></td>
<td width="465" align="left" valign="top">A private link to               the database with service name <span style="font-family:&quot;">service</span>. The link uses               the userid/password of the current user to log onto the remote database.</td>
</tr>
</tbody>
</table>
</blockquote>
<p>Following are examples of public database links</p>
<blockquote><p>sdasd</p>
<table id="AutoNumber3" border="1" cellspacing="3" cellpadding="3" width="90%">
<tbody>
<tr>
<th width="352" height="16" align="left" valign="bottom">SQL               Statement</th>
<td width="425" height="16"><strong>Result</strong></td>
</tr>
<tr>
<td width="352" height="12" align="left" valign="top"><code>CREATE PUBLIC DATABASE LINK <em>link_name</em>;</code></td>
<td width="425" height="12" valign="top">A public link to the remote database. The               link uses the userid/password of the connected user. So if <code>scott</code> uses               the link in a query, the link establishes a connection to the remote database as               <code>scott</code>.</td>
</tr>
<tr>
<td width="352" height="33" align="left" valign="top"><code>CREATE PUBLIC DATABASE LINK <em>link_name<br />
</em> CONNECT TO CURRENT_USER               USING 'service';</code></td>
<td width="425" height="33" valign="top">A public link to the database with service               name <span style="font-family:&quot;">service</span>. The link uses the userid/password of               the current user to log onto the remote database.</td>
</tr>
<tr>
<td width="352" height="33" align="left" valign="top"><code>CREATE PUBLIC DATABASE LINK <em>link_name<br />
</em> CONNECT TO user               IDENTIFIED BY ....;</code></td>
<td width="425" height="33" valign="top">A public fixed user link. The link connects               to the remote database with the userid/password.</td>
</tr>
</tbody>
</table>
</blockquote>
</td>
</tr>
<p>&nbsp;</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deepthinking99.wordpress.com/793/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deepthinking99.wordpress.com/793/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deepthinking99.wordpress.com/793/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deepthinking99.wordpress.com/793/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deepthinking99.wordpress.com/793/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deepthinking99.wordpress.com/793/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deepthinking99.wordpress.com/793/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deepthinking99.wordpress.com/793/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deepthinking99.wordpress.com/793/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deepthinking99.wordpress.com/793/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deepthinking99.wordpress.com&blog=4894307&post=793&subd=deepthinking99&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://deepthinking99.wordpress.com/2009/11/20/database-link-survival-guide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1f3b6fbee19bb2cca5ced85efa030302?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">deepthinking99</media:title>
		</media:content>

		<media:content url="http://www.akadia.com/img/ora_database_link_0.gif" medium="image" />

		<media:content url="http://www.akadia.com/img/ora_database_link_1.gif" medium="image" />

		<media:content url="http://www.akadia.com/img/ora_database_link_2.gif" medium="image" />

		<media:content url="http://www.akadia.com/img/ora_database_link_3.gif" medium="image" />
	</item>
		<item>
		<title>Manually configure the Oracle 10g EM dbconsole</title>
		<link>http://deepthinking99.wordpress.com/2009/11/20/manually-configure-the-oracle-10g-em-dbconsole/</link>
		<comments>http://deepthinking99.wordpress.com/2009/11/20/manually-configure-the-oracle-10g-em-dbconsole/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 08:31:14 +0000</pubDate>
		<dc:creator>Ida Bagus Enderajana</dc:creator>
				<category><![CDATA[Oracle Grid Control]]></category>

		<guid isPermaLink="false">http://deepthinking99.wordpress.com/?p=790</guid>
		<description><![CDATA[

Overview




When you choose to create a preconfigured database during               the Oracle 10g installation, you can select the Oracle Enterprise Manager (OEM)               interface that you want to use [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deepthinking99.wordpress.com&blog=4894307&post=790&subd=deepthinking99&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><tr>
<td width="509" height="17" valign="top">
<h2>Overview</h2>
</td>
</tr>
<tr>
<td colspan="2" width="605" height="74" valign="top">
<blockquote><p>When you choose to create a <strong>preconfigured database</strong> during               the Oracle 10g installation, you can select the Oracle Enterprise Manager (OEM)               interface that you want to use to manage the database. The following options are               available:</p>
<ul>
<li> <strong>Database Grid Control</strong></li>
</ul>
<blockquote><p>This option is available only if an <strong>Oracle Management Agent                 is installed</strong> on the system. When the Installer detects an Oracle Management                 Agent on the system, it allows you to choose this option and specify the Oracle                 Management Service that you want to use to manage the database.</p>
<p>If an Oracle Management Agent is not installed, you must choose                 to use Database Control to manage the database. However, if you install Oracle                 Management Agent after you install Oracle Database, you can then use Grid Control                 to manage this database.</p></blockquote>
<ul>
<li> <strong>Database Control</strong></li>
</ul>
<blockquote><p>This option is selected by default if an <strong>Oracle Management                 Agent is not installed</strong> on the system. However, even if a Management Agent is                 installed, you can still choose to configure Database Control to manage the                 database.</p></blockquote>
</blockquote>
<p>Custom installation</p>
<blockquote><p>If you choose the Custom installation type or the Advanced               database configuration option during the installation, the Installer does not display               the OEM setup screens. Instead, it runs the Database Configuration Assistant (DBCA)               in interactive mode, which enables you to create a custom database.</p>
<p>DBCA also enables you to specify the Oracle Enterprise Manager               interface that you want to use. Furthermore, you can also use DBCA after the               installation to configure Database Control for a database that was not previously               configured to use it.</p>
<p>However, if you decide to setup your own Database, you must               install the Database Control manually.</p></blockquote>
<p>Setup your own Database and manually install the Database             Control</p>
<blockquote><p>The Database Control relies on various underlying technologies to               discover, monitor, and administer the Oracle Database environment.</p>
<p>From the Database Control, you can monitor and administer a single               Oracle Database instance.</p>
<p>The Database Control Framework consists of the Database Control               and its underlying technologies:</p>
<ul>
<li> A local version of the Oracle Management Service designed to                 work with the local database or clustered database.</li>
<li> A local Oracle Management Repository installed in the local                 database and designed to store management data for the Database Control.</li>
</ul>
</blockquote>
</td>
</tr>
<tr>
<td colspan="2" width="605" height="74" valign="top">
<blockquote><p><img src="http://www.akadia.com/img/ora10g-dbconsole-architecture.gif" border="0" alt="" width="442" height="485" align="left" /></p></blockquote>
</td>
</tr>
<tr>
<td colspan="2" width="605" height="74" valign="top">
<blockquote><p>The following steps have to be performed.</p></blockquote>
<p>Create your own Database</p>
<blockquote><p>More information to setup your own               Database can be found here:</p>
<table id="AutoNumber4" style="height:20px;" border="0" cellspacing="0" cellpadding="0" width="70%">
<tbody>
<tr>
<td width="50%" height="20">
<ul>
<li> <a href="http://www.akadia.com/services/ora_w2k_install_10g.html" target="_top">For Windows 2000</a></li>
</ul>
</td>
<td width="50%" height="20">
<ul>
<li> <a href="http://www.akadia.com/services/ora_linux_install_10g.html" target="_top">For                       Linux</a></li>
</ul>
</td>
</tr>
</tbody>
</table>
</blockquote>
<p>Create the Database Control Repository and setup the OC4J             Application Server</p>
<blockquote><p>Make sure, that you can connect to the               Repository Database (Test it with SQL*Plus). Examples for Setup Files can be found               here:</p>
<table id="AutoNumber3" style="height:78px;" border="0" cellspacing="0" cellpadding="3" width="90%">
<tbody>
<tr>
<td width="50%" height="30" valign="top">Windows</td>
<td width="50%" height="30" valign="top">Linux</td>
</tr>
<tr>
<td width="50%" height="16"><a href="http://www.akadia.com/download/documents/listener-windows.txt" target="_top">LISTENER.ORA</a></td>
<td width="50%" height="16"><a href="http://www.akadia.com/download/documents/listener-linux.txt" target="_top">listener.ora</a></td>
</tr>
<tr>
<td width="50%" height="16"><a href="http://www.akadia.com/download/documents/sqlnet-windows.txt" target="_top">SQLNET.ORA</a></td>
<td width="50%" height="16"><a href="http://www.akadia.com/download/documents/sqlnet-linux.txt" target="_top">sqlnet.ora</a></td>
</tr>
<tr>
<td width="50%" height="16"><a href="http://www.akadia.com/download/documents/tnsnames-windows.txt" target="_top">TNSNAMES.ORA</a></td>
<td width="50%" height="16"><a href="http://www.akadia.com/download/documents/tnsnames-linux.txt" target="_top">tnsnames.ora</a></td>
</tr>
</tbody>
</table>
<p>Now start the Oracle EM dbconsole Build               Script (<span style="font-family:&quot;">$ORACLE_HOME/bin/emca</span> for Linux and <span style="font-family:&quot;">$ORACLE_HOME\Bin\emca.bat</span> for Windows).</p>
<p><strong>$ emca -repos create<br />
$ emca -config dbcontrol db</strong></p>
<p><span style="color:#0000ff;">STARTED EMCA at Fri May 14 10:43:22 MEST               2004<br />
Enter the following information about the database<br />
to be configured.</span></p>
<p><span style="color:#0000ff;">Listener port number:</span> <strong>1521</strong><span style="color:#0000ff;"><br />
Database SID:</span> <strong>AKI1</strong><span style="color:#0000ff;"><br />
Service name:</span> <strong>AKI1.WORLD</strong><span style="color:#0000ff;"><br />
Email address for notification:</span> <strong>martin dot zahn at akadia dot ch</strong><span style="color:#0000ff;"><br />
Email gateway for notification:</span> <strong>mailhost</strong><span style="color:#0000ff;"><br />
Password for dbsnmp:</span> <strong>xxxxxxx</strong><span style="color:#0000ff;"><br />
Password for sysman:</span> <strong>xxxxxxx</strong><span style="color:#0000ff;"><br />
Password for sys:</span> <strong>xxxxxxx</strong></p>
<p><span style="color:#0000ff;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
You have specified the following settings</p>
<p>Database ORACLE_HOME: /opt/oracle/product/10.1.0<br />
Enterprise Manager ORACLE_HOME: /opt/oracle/product/10.1.0</p>
<p>Database host name &#8230;&#8230;&#8230;.: akira<br />
Listener port number &#8230;&#8230;&#8230;: 1521<br />
Database SID &#8230;&#8230;&#8230;&#8230;&#8230;..: AKI1<br />
Service name &#8230;&#8230;&#8230;&#8230;&#8230;..: AKI1<br />
Email address for notification: martin dot zahn at akadia dot ch<br />
Email gateway for notification: mailhost<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Do you wish to continue? [yes/no]: <strong>yes</strong><br />
AM oracle.sysman.emcp.EMConfig updateReposVars<br />
INFO: Updating file ../config/repository.variables &#8230;</span></p>
<p><span style="color:#0000ff;"><strong>Now wait about 10 Minutes to               complete!</strong></span></p>
<p><span style="color:#0000ff;">M oracle.sysman.emcp.EMConfig               createRepository<br />
INFO: Creating repository &#8230;<br />
M oracle.sysman.emcp.EMConfig perform<br />
INFO: Repository was created successfully<br />
M oracle.sysman.emcp.util.PortQuery findUsedPorts<br />
INFO: Searching services file for used port<br />
AM oracle.sysman.emcp.EMConfig getProperties<br />
&#8230;&#8230;&#8230;..<br />
&#8230;&#8230;&#8230;..<br />
INFO: Starting the DBConsole &#8230;<br />
AM oracle.sysman.emcp.EMConfig perform<br />
INFO: DBConsole is started successfully<br />
INFO: &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; The Enterprise Manager URL is               <strong>http://akira:5500/em</strong> &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;<br />
Enterprise Manager configuration is completed successfully<br />
FINISHED EMCA at Fri May 14 10:55:25 MEST 2004</span></p></blockquote>
<p>Try to connect to the database Control</p>
<blockquote><p>http://akira:5500/em</p>
<p><img src="http://www.akadia.com/img/ora10g-dbconsole.gif" border="0" alt="" width="444" height="329" /></p>
<p>If you look at the installed schemas, you can now find the SYSMAN               schema, which is the database Control Repository.</p></blockquote>
<p>Troubleshooting</p>
<blockquote><p>If you have troubles to connect, check your local configuration which can be found in <span style="font-family:&quot;">$ORACLE_HOME/&lt;hostname&gt;_&lt;SERVICE_NAME&gt;.</span> For               Example our DbConsole Setup Directory looks as follows:</p>
<p>$ <strong>pwd</strong><br />
<span style="color:#0000ff;">/opt/oracle/product/10.1.0/akira_AKI1/sysman/config</p>
<p>$</span> <strong>ls -l</strong><span style="color:#0000ff;"><br />
-rw-r&#8211;r&#8211;    b64InternetCertificate.txt<br />
-rw-r&#8211;r&#8211;    emagentlogging.properties<br />
-rw-r&#8211;r&#8211;    emd.properties<br />
-rw-r&#8211;r&#8211;    emomsintg.xml<br />
-rw-r&#8211;r&#8211;    emomslogging.properties<br />
<strong>-rw-r&#8211;r&#8211;    emoms.properties</strong><br />
-rw-r&#8211;r&#8211;    OUIinventories.add</span></p>
<p>The most important file is <strong><span style="font-family:&quot;">emoms.properties</span></strong>, where you can find all the configuration               parameters.</p>
<p><span style="color:#0000ff;">#Fri May 14 10:54:49 CEST 2004<br />
oracle.sysman.emSDK.svlt.ConsoleServerName=<br />
akira_Management_Service<br />
oracle.sysman.eml.mntr.emdRepPwd=0b878f6184e8319d<br />
emdrep.ping.pingCommand=/bin/ping &lt;hostname&gt;<br />
oracle.sysman.eml.mntr.emdRepPort=1521<br />
oracle.sysman.eml.mntr.emdRepDBName=AKI1.WORLD<br />
oracle.sysman.emSDK.svlt.ConsoleMode=standalone<br />
oracle.sysman.emRep.dbConn.statementCacheSize=30<br />
oracle.sysman.db.isqlplusUrl=<br />
http\://akira\:5560/isqlplus/dynamic<br />
oracle.sysman.emSDK.svlt.ConsoleServerPort=5500<br />
oracle.sysman.eml.mntr.emdRepRAC=FALSE<br />
oracle.sysman.emSDK.emd.rt.useMonitoringCred=true<br />
oracle.sysman.eml.mntr.emdRepPwdEncrypted=TRUE<br />
oracle.sysman.db.isqlplusWebDBAUrl=<br />
http\://akira\:5560/isqlplus/dba/dynamic<br />
oracle.sysman.emSDK.svlt.ConsoleServerHost=akira<br />
oracle.sysman.emSDK.svlt.ConsoleServerHTTPSPort=5500<br />
oracle.sysman.eml.mntr.emdRepServer=akira<br />
oracle.sysman.eml.mntr.emdRepSID=AKI1<br />
oracle.sysman.emSDK.sec.ReuseLogonPassword=true<br />
oracle.sysman.eml.mntr.emdRepConnectDescriptor=<br />
(DESCRIPTION\=(ADDRESS_LIST\=<br />
(ADDRESS\=(PROTOCOL\=TCP)(HOST\=akira)(PORT\<br />
=1521)))(CONNECT_DATA\=(SERVICE_NAME\=AKI1)))<br />
oracle.sysman.eml.mntr.emdRepUser=SYSMAN<br />
oracle.sysman.db.adm.conn.statementCacheSize=2<br />
oracle.sysman.db.perf.conn.statementCacheSize=30</span></p></blockquote>
<p>Automatically start and stop the DB-Console</p>
<blockquote><p><strong>$ emctl start dbconsole<br />
$ emctl stop dbconsole<br />
$ emctl status dbconsole</strong></p>
<p><span style="color:#0000ff;">Oracle Enterprise Manager 10g Database<br />
Control Release 10.1.0.2.0<br />
Copyright (c) 1996, 2004 Oracle Corporation.<br />
All rights reserved.</p>
<p>http://akira:5500/em/console/aboutApplication</p>
<p>Oracle Enterprise Manager 10g is running.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Logs are generated in directory<br />
/opt/oracle/product/10.1.0/akira_AKI1/sysman/log</span></p>
<p><strong><a href="http://www.akadia.com/download/documents/dbconsole.txt" target="_top">Here</a></strong> you can find a start/stop script               for the DB-Console for Gentoo Linux.</p></blockquote>
</td>
</tr>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deepthinking99.wordpress.com/790/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deepthinking99.wordpress.com/790/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deepthinking99.wordpress.com/790/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deepthinking99.wordpress.com/790/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deepthinking99.wordpress.com/790/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deepthinking99.wordpress.com/790/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deepthinking99.wordpress.com/790/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deepthinking99.wordpress.com/790/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deepthinking99.wordpress.com/790/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deepthinking99.wordpress.com/790/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deepthinking99.wordpress.com&blog=4894307&post=790&subd=deepthinking99&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://deepthinking99.wordpress.com/2009/11/20/manually-configure-the-oracle-10g-em-dbconsole/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1f3b6fbee19bb2cca5ced85efa030302?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">deepthinking99</media:title>
		</media:content>

		<media:content url="http://www.akadia.com/img/ora10g-dbconsole-architecture.gif" medium="image" />

		<media:content url="http://www.akadia.com/img/ora10g-dbconsole.gif" medium="image" />
	</item>
		<item>
		<title>How to load Data very fast using Partition Exchange</title>
		<link>http://deepthinking99.wordpress.com/2009/11/20/how-to-load-data-very-fast-using-partition-exchange/</link>
		<comments>http://deepthinking99.wordpress.com/2009/11/20/how-to-load-data-very-fast-using-partition-exchange/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 08:26:02 +0000</pubDate>
		<dc:creator>Ida Bagus Enderajana</dc:creator>
				<category><![CDATA[Oracle PL-SQL]]></category>

		<guid isPermaLink="false">http://deepthinking99.wordpress.com/?p=786</guid>
		<description><![CDATA[

Overview




One of the great features about partitioning,            and most specifically range-based partitioning, is the ability to load            data quickly and easily with minimal impact on the current       [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deepthinking99.wordpress.com&blog=4894307&post=786&subd=deepthinking99&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><tr>
<td width="773" height="17" valign="top">
<h3>Overview</h3>
</td>
</tr>
<tr>
<td colspan="2" width="874" height="10" valign="top">
<blockquote><p>One of the great features about partitioning,            and most specifically range-based partitioning, is the ability to load            data quickly and easily with minimal impact on the current            users using:</p>
<p><strong>alter table call exchange            partition data_2007 with table call_temp;</strong></p>
<p>This command swaps over the definitions of the            named partition and the CALL table, so that the data suddenly exists            in the right place in the partitioned table. Moreover, with the            inclusion of the two optional extra clauses, index definitions will be            swapped and Oracle will not check whether the data actually belongs in            the partition &#8211; so the exchange is very quick.</p></blockquote>
<h3>Example with no Parent Child Relation</h3>
<blockquote><p>In this example, the primary key and the            partition key in the partitioned table CALL both are build on the same            column <span style="font-family:Verdana;">«<span style="color:#ff0000;">id</span>»</span>.            Therefore the primary key on CALL can be a LOCAL index and the indexes            doesn&#8217;t become UNUSABLE (must not be rebuild) after the EXCHANGE.</p>
<p><span style="color:#0000ff;">&#8211; Create            the Partition Table (Destination Table)</span></p>
<p>CREATE TABLE call (<br />
<strong><span style="color:#ff0000;">id</span></strong> NUMBER(12,6),<br />
v1    VARCHAR2(10),<br />
data  VARCHAR2(100)<br />
)<br />
<strong>PARTITION BY RANGE(<span style="color:#ff0000;">id</span>) ( </strong> <span style="color:#0000ff;">&#8211; Partion Key = Primary Key</span><strong><br />
PARTITION call_partition VALUES LESS THAN (MAXVALUE)<br />
);</strong></p>
<p><span style="color:#0000ff;">&#8211; Next,            create the temporary Table which is used to load the Data offline</span></p>
<p>CREATE TABLE call_temp (<br />
id    NUMBER(12,6),<br />
v1    VARCHAR2(10),<br />
data  VARCHAR2(100)<br />
);</p>
<p><span style="color:#0000ff;">&#8211; Load            1&#8242;000&#8242;000 Rows into the offline Table</span></p>
<p>INSERT /*+ append ordered full(s1) use_nl(s2) */<br />
INTO call_temp<br />
SELECT<br />
TRUNC((ROWNUM-1)/500,6),<br />
TO_CHAR(ROWNUM),<br />
RPAD(&#8216;X&#8217;,100,&#8217;X')<br />
FROM<br />
all_tables s1,<br />
all_tables s2<br />
WHERE<br />
ROWNUM &lt;= 1000000;</p>
<p><span style="color:#0000ff;">&#8211; Add            LOCAL Primary Key to the Partition Table as a local Index</span></p>
<p>ALTER TABLE call<br />
ADD CONSTRAINT pk_call PRIMARY KEY(<strong><span style="color:#ff0000;">id</span></strong>)<br />
<strong>USING INDEX (CREATE INDEX pk_call ON CALL(<span style="color:#ff0000;">id</span>) NOLOGGING           <span style="color:#ff0000;">LOCAL</span>);</strong></p>
<p><span style="color:#0000ff;">&#8211; Add Primary Key to the offline Table</span></p>
<p>ALTER TABLE call_temp<br />
ADD CONSTRAINT pk_call_temp PRIMARY KEY(id)<br />
USING INDEX (CREATE INDEX pk_call_temp ON call_temp(id) NOLOGGING);</p>
<p><span style="color:#0000ff;">&#8211; Now swap the offline Table into the Partition</span></p>
<p><strong>ALTER TABLE CALL<br />
EXCHANGE PARTITION call_partition WITH TABLE call_temp<br />
INCLUDING INDEXES<br />
WITHOUT VALIDATION;</strong></p>
<pre><span style="color:#0000ff;">Elapsed: 00:00:00.01</span></pre>
<p>Oracle is checking that the exchange <strong>won’t            cause a uniqueness problem</strong>. The query is searching the entire CALL            table (excluding the partition we are exchanging) to see if there are            any duplicates of the rows which we are loading. This is particularly            daft, since the unique constraint is maintained through a local index,            so it must include the partitioning key ID, which means there is only            one legal partition in which a row can be, and we have already            promised (through the without validation clause) that all the rows            belong where we are putting them.</p>
<p><span style="color:#0000ff;">&#8211; For the next load, first            truncate the CALL Table, then process the next load.</span></p>
<p>TRUNCATE TABLE call;</p>
<p>ALTER TABLE CALL<br />
EXCHANGE PARTITION call_partition WITH TABLE call_temp<br />
INCLUDING INDEXES<br />
WITHOUT VALIDATION;</p></blockquote>
<h3>Example with  Parent Child Relation</h3>
<blockquote><p>In this example, the primary key and the            partition key in the partitioned table CALL are NOT the same. The            primary key is build on the column <span style="font-family:Verdana;"> <span style="color:#ff0000;">«</span><strong><span style="color:#ff0000;">id</span></strong><span style="color:#ff0000;">»</span>,            but the partition key is build on <span style="color:#000080;">«</span><strong><span style="color:#000080;">created_date</span></strong><span style="color:#000080;">»</span></span>.            Therefore the primary key on CALL must be a GLOBAL index and the            indexes must be maintained using the clause <code>UPDATE GLOBAL            INDEXES</code> in the EXCHANGE.</p>
<p><span style="color:#0000ff;">&#8211; Create            and populate a small lookup table<br />
</span><br />
CREATE TABLE lookup (<br />
id                       NUMBER(10),<br />
description   VARCHAR2(50)<br />
);</p>
<p>ALTER TABLE lookup ADD (<br />
CONSTRAINT pk_lookup PRIMARY KEY (id)<br />
);</p>
<p>INSERT INTO lookup (id, description) VALUES (1, &#8216;ONE&#8217;);<br />
INSERT INTO lookup (id, description) VALUES (2, &#8216;TWO&#8217;);<br />
INSERT INTO lookup (id, description) VALUES (3, &#8216;THREE&#8217;);<br />
COMMIT;</p>
<p><span style="color:#0000ff;">&#8211; Create and populate a temporary table to load            the data<br />
</span><br />
CREATE TABLE call_temp (<br />
id                       NUMBER(10),<br />
created_date  DATE,<br />
lookup_id     NUMBER(10),<br />
data          VARCHAR2(50)<br />
);</p>
<p><span style="color:#0000ff;">&#8211; Load the temporary table</span></p>
<p>DECLARE<br />
l_lookup_id    lookup.id%TYPE;<br />
l_create_date  DATE;<br />
BEGIN<br />
FOR i IN 1 .. 1000000 LOOP<br />
IF MOD(i, 3) = 0 THEN<br />
l_create_date := ADD_MONTHS(SYSDATE, -24);<br />
l_lookup_id   := 2;<br />
ELSIF MOD(i, 2) = 0 THEN<br />
l_create_date := ADD_MONTHS(SYSDATE, -12);<br />
l_lookup_id   := 1;<br />
ELSE<br />
l_create_date := SYSDATE;<br />
l_lookup_id   := 3;<br />
END IF;<br />
INSERT INTO call_temp (id, created_date, lookup_id, data)<br />
VALUES (i, l_create_date, l_lookup_id, &#8216;Loaded Data for &#8216; ||            i);<br />
END LOOP;<br />
COMMIT;<br />
END;<br />
/</p>
<p><span style="color:#0000ff;">&#8211; Apply Primary Key to the CALL_TEMP table.</span></p>
<p>ALTER TABLE call_temp ADD (<br />
CONSTRAINT pk_call_temp PRIMARY KEY (id)<br />
);</p>
<p><span style="color:#0000ff;">&#8211; Add Key and Foreign Key Constraint to the            CALL_TEMP table.<br />
</span><br />
CREATE INDEX idx_call_temp_created_date ON call_temp(created_date);<br />
CREATE INDEX idx_call_temp_lookup_id ON call_temp(lookup_id);</p>
<p>ALTER TABLE call_temp ADD (<br />
CONSTRAINT fk_call_temp_lookup_id<br />
FOREIGN KEY (lookup_id)<br />
REFERENCES lookup(id)<br />
);</p>
<p><span style="color:#0000ff;">&#8211; Next we create a new table with the            appropriate partition structure<br />
&#8211; to act as the destination table. The destination must have the<br />
&#8211; same constraints and indexes defined.</span></p>
<p>CREATE TABLE call (<br />
<strong><span style="color:#ff0000;">id</span></strong> NUMBER(10),<br />
<strong><span style="color:#000080;">created_date</span></strong> DATE,<br />
lookup_id     NUMBER(10),<br />
data          VARCHAR2(50)<br />
)<br />
<strong>PARTITION BY RANGE (<span style="color:#000080;">created_date</span>)<br />
(PARTITION call_temp_created_date VALUES LESS THAN (MAXVALUE));</strong></p>
<p><span style="color:#0000ff;">&#8211; Add Primary Key to CALL which must be GLOBAL</span></p>
<p>ALTER TABLE call ADD<br />
CONSTRAINT pk_call PRIMARY KEY (<strong><span style="color:#ff0000;">id</span></strong>)<br />
<strong>USING INDEX (CREATE INDEX pk_call ON CALL(<span style="color:#ff0000;">id</span>)           <span style="color:#ff0000;">GLOBAL</span></strong><br />
);</p>
<p><span style="color:#0000ff;">&#8211; Add Keys and Foreign Key Constraint to the            CALL table<br />
&#8211; which can be LOCAL</span></p>
<p>CREATE INDEX idx_call_created_date ON call(created_date) LOCAL;<br />
CREATE INDEX idx_call_lookup_id ON call(lookup_id) LOCAL;</p>
<p>ALTER TABLE call ADD (<br />
CONSTRAINT fk_call_lookup_id<br />
FOREIGN KEY (lookup_id)<br />
REFERENCES lookup(id)<br />
);</p>
<p><span style="color:#0000ff;">&#8211; With this destination table in place we can            start the conversion.<br />
&#8211; We now switch the segments associated with the source table and the<br />
&#8211; partition in the destination table using EXCHANGE PARTITION<br />
</span><br />
SET TIMING ON;<br />
<strong>ALTER TABLE call<br />
EXCHANGE PARTITION call_temp_created_date<br />
WITH TABLE call_temp<br />
WITHOUT VALIDATION<br />
<span style="color:#ff0000;">UPDATE GLOBAL INDEXES;</span></strong></p>
<p><span style="color:#0000ff;">Elapsed:            00:00:27.19</span></p>
<p>This is significantly slower than in the            previous example!</p>
<p>The <code>UPDATE GLOBAL INDEXES</code> is needed            because without it that would leave the global indexes associated with            the partition in an <code>UNUSABLE</code> state. If the <code>UPDATE            GLOBAL INDEXES</code> clause is added, <strong>the performance is reduced</strong> since the index rebuild is part of the issued DDL. The index updates            are logged and it should only be used when the number of rows is low            and data must stay available. For <strong>larger numbers of rows index            rebuilds are more efficient</strong> and allow index reorganization.</p></blockquote>
</td>
</tr>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deepthinking99.wordpress.com/786/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deepthinking99.wordpress.com/786/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deepthinking99.wordpress.com/786/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deepthinking99.wordpress.com/786/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deepthinking99.wordpress.com/786/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deepthinking99.wordpress.com/786/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deepthinking99.wordpress.com/786/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deepthinking99.wordpress.com/786/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deepthinking99.wordpress.com/786/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deepthinking99.wordpress.com/786/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deepthinking99.wordpress.com&blog=4894307&post=786&subd=deepthinking99&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://deepthinking99.wordpress.com/2009/11/20/how-to-load-data-very-fast-using-partition-exchange/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1f3b6fbee19bb2cca5ced85efa030302?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">deepthinking99</media:title>
		</media:content>
	</item>
		<item>
		<title>Bulk Insert</title>
		<link>http://deepthinking99.wordpress.com/2009/11/20/bulk-insert/</link>
		<comments>http://deepthinking99.wordpress.com/2009/11/20/bulk-insert/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 08:10:22 +0000</pubDate>
		<dc:creator>Ida Bagus Enderajana</dc:creator>
				<category><![CDATA[Oracle PL-SQL]]></category>

		<guid isPermaLink="false">http://deepthinking99.wordpress.com/?p=782</guid>
		<description><![CDATA[The Old Fashioned Way
A quick glance at the following Code should make one point very clear: This is               straightforward code; unfortunately, it takes a lot of time to run &#8211; it is          [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deepthinking99.wordpress.com&blog=4894307&post=782&subd=deepthinking99&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The Old Fashioned Way</p>
<blockquote><p>A quick glance at the following Code should make one point very clear: This is               straightforward code; unfortunately, it takes a lot of time to run &#8211; it is               &#8220;old-fashioned&#8221; code, so let&#8217;s improve it using collections and bulk processing.</p>
<p>CREATE OR REPLACE PROCEDURE test_proc IS<br />
BEGIN<br />
<span style="color:#0000ff;"><strong>FOR x IN (SELECT * FROM all_objects)</strong><br />
<strong>LOOP</strong></span><br />
INSERT INTO t1<br />
(owner, object_name, subobject_name, object_id,<br />
data_object_id, object_type, created, last_ddl_time,<br />
timestamp, status, temporary, generated, secondary)<br />
VALUES<br />
(x.owner, x.object_name, x.subobject_name, x.object_id,<br />
x.data_object_id, x.object_type, x.created,<br />
x.last_ddl_time, x.timestamp, x.status, x.temporary,<br />
x.generated, x.secondary);<br />
<span style="color:#0000ff;"><strong>END LOOP;</strong></span><br />
COMMIT;<br />
END test_proc;<br />
/</p>
<p>CREATE TABLE t1 AS SELECT * FROM all_objects WHERE 1 = 2;</p>
<p>SQL&gt; set timing on;<br />
SQL&gt; exec test_proc;</p>
<p>PL/SQL procedure successfully completed.</p>
<p><strong>Elapsed: 00:00:12.84</strong><br />
SQL&gt; exec test_proc;</p>
<p>PL/SQL procedure successfully completed.</p>
<p><strong>Elapsed: 00:00:15.03</strong><br />
SQL&gt; exec test_proc;</p>
<p>PL/SQL procedure successfully completed.</p>
<p><strong>Elapsed: 00:00:12.54</strong></p>
<p>Very slow &#8211; do not use it in that way!</p></blockquote>
<p>USING Bulk Collect</p>
<blockquote><p>Converting to collections and bulk processing can increase the volume and complexity               of your code. If you need a <strong>serious boost in performance</strong>, however, that               increase is well-justified.</p>
<p>Collections, an evolution of PL/SQL tables that allows us to <strong>manipulate many               variables at once</strong>, as a unit. Collections, coupled with two new features               introduced with Oracle 8i, BULK_COLLECT and FORALL, can dramatically increase the               performance of data manipulation code within PL/SQL.</p>
<p>CREATE OR REPLACE PROCEDURE test_proc (p_array_size IN PLS_INTEGER DEFAULT 100)<br />
IS<br />
<span style="color:#0000ff;"><strong>TYPE ARRAY IS TABLE OF all_objects%ROWTYPE;</strong></span><br />
l_data ARRAY;</p>
<p>CURSOR c IS SELECT * FROM all_objects;</p>
<p>BEGIN<br />
OPEN c;<br />
<strong><span style="color:#0000ff;">LOOP<br />
FETCH c BULK COLLECT INTO l_data LIMIT               p_array_size;</span></strong></p>
<p><strong><span style="color:#008000;">FORALL i IN 1..l_data.COUNT<br />
INSERT INTO t1 VALUES l_data(i);</span></strong></p>
<p>EXIT WHEN c%NOTFOUND;<br />
<strong><span style="color:#0000ff;">END LOOP;</span></strong><br />
CLOSE c;<br />
END test_proc;<br />
/</p>
<p>SQL&gt; exec test_proc;</p>
<p>PL/SQL procedure successfully completed.</p>
<p><strong>Elapsed: 00:00:03.34</strong><br />
SQL&gt; exec test_proc;</p>
<p>PL/SQL procedure successfully completed.</p>
<p><strong>Elapsed: 00:00:03.20</strong><br />
SQL&gt; exec test_proc;</p>
<p>PL/SQL procedure successfully completed.</p>
<p><strong>Elapsed: 00:00:03.90</strong></p></blockquote>
<p>Eliminate CURSOR LOOP at all</p>
<blockquote><p>You may eliminate the CURSOR Loop at all, the resulting Procedure is compacter and               the performance is more or less the same.</p>
<p>CREATE OR REPLACE PROCEDURE test_proc<br />
IS<br />
<strong><span style="color:#0000ff;">TYPE TObjectTable IS TABLE OF ALL_OBJECTS%ROWTYPE;<br />
ObjectTable$ TObjectTable;</span></strong></p>
<p>BEGIN<br />
<strong><span style="color:#0000ff;">SELECT * BULK COLLECT INTO ObjectTable$<br />
FROM ALL_OBJECTS;</span></strong></p>
<p><strong><span style="color:#0000ff;">FORALL x in               ObjectTable$.First..ObjectTable$.Last<br />
INSERT INTO t1 VALUES ObjectTable$(x) ;</span></strong><br />
END;<br />
/</p>
<p>SQL&gt; exec test_proc;</p>
<p>PL/SQL procedure successfully completed.</p>
<p><strong>Elapsed: 00:00:03.51</strong><br />
SQL&gt; exec test_proc;</p>
<p>PL/SQL procedure successfully completed.</p>
<p><strong>Elapsed: 00:00:03.35</strong><br />
SQL&gt; exec test_proc;</p>
<p>PL/SQL procedure successfully completed.</p>
<p><strong>Elapsed: 00:00:04.46</strong></p></blockquote>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deepthinking99.wordpress.com/782/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deepthinking99.wordpress.com/782/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deepthinking99.wordpress.com/782/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deepthinking99.wordpress.com/782/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deepthinking99.wordpress.com/782/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deepthinking99.wordpress.com/782/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deepthinking99.wordpress.com/782/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deepthinking99.wordpress.com/782/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deepthinking99.wordpress.com/782/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deepthinking99.wordpress.com/782/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deepthinking99.wordpress.com&blog=4894307&post=782&subd=deepthinking99&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://deepthinking99.wordpress.com/2009/11/20/bulk-insert/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1f3b6fbee19bb2cca5ced85efa030302?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">deepthinking99</media:title>
		</media:content>
	</item>
		<item>
		<title>Scripting Oracle RMAN Commands</title>
		<link>http://deepthinking99.wordpress.com/2009/11/20/scripting-oracle-rman-commands/</link>
		<comments>http://deepthinking99.wordpress.com/2009/11/20/scripting-oracle-rman-commands/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 07:47:41 +0000</pubDate>
		<dc:creator>Ida Bagus Enderajana</dc:creator>
				<category><![CDATA[Oracle Database Backup]]></category>

		<guid isPermaLink="false">http://deepthinking99.wordpress.com/?p=779</guid>
		<description><![CDATA[Many DBAs have discovered how Oracle Recovery Manager (Oracle RMAN) can reliably back up, restore, and recover Oracle Database instances. Among its many features is the ability to script the commands for batch-centric, hands-off execution. This article discusses the ways to script Oracle RMAN commands in Oracle Database 11g and how to pick the right [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deepthinking99.wordpress.com&blog=4894307&post=779&subd=deepthinking99&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Many DBAs have discovered how Oracle Recovery Manager (Oracle RMAN) can reliably back up, restore, and recover Oracle Database instances. Among its many features is the ability to script the commands for batch-centric, hands-off execution. This article discusses the ways to script Oracle RMAN commands in Oracle Database 11g and how to pick the right approach for your specific needs.</p>
<p>Why Script?</p>
<p>Why create a script for Oracle RMAN commands? There are two primary reasons:</p>
<p>1. Most Oracle RMAN activities are batch-oriented and can be automated. For instance, backing up a database is a repetitive activity and not something you would want to execute interactively.</p>
<p>2. Scripts provide consistency. For tasks of an ad hoc nature, such as recovering a database from a backup, automation is not strictly required. When a script is used to execute the activity, however, the action will be the same, regardless of the experience and expertise of the DBA performing the recovery.</p>
<p>There are two ways to script Oracle RMAN commands in Oracle Database 11g:</p>
<p>1. Use a command file. A command file is a text file residing in the file system.</p>
<p>2. Use a stored script. This script is stored in the Oracle RMAN catalog database and executed from the Oracle RMAN command prompt.</p>
<p>Command Files</p>
<p>Oracle RMAN command files are plain-text files and similar to shell scripts in UNIX or batch files in Microsoft Windows. Listing 1 shows a very simple example command file—named backup_ts_users.rman—used to back up the USERS tablespace. The file extension .rman is not necessary, but it is helpful in making the meaning of the file clear.</p>
<p>Code Listing 1: Command file for backing up USERS tablespace</p>
<p>connect target /<br />
connect catalog rman/secretpass@rmancat</p>
<p>run {<br />
allocate channel c1 type disk format &#8216;/orabak/%U&#8217;;<br />
backup tablespace users;<br />
}</p>
<p>You can call a command file in several ways. From the Oracle RMAN prompt, you can call the example command file as follows:</p>
<p>RMAN&gt; @backup_ts_users.rman</p>
<p>Note that the command file is executed by the @ sign. It is important, however, to provide the full name of the command file, including the extension. (The Oracle RMAN executable does not expect or apply a default extension.)</p>
<p>You can also call the command file directly from the command line as</p>
<p>rman @backup_ts_users.rman</p>
<p>This approach for calling the script is highly useful in shell scripts or batch files for making backups. Also note that instead of using the @ sign to call the command file, you can use the cmdfile parameter as follows:</p>
<p>rman cmdfile=backup_ts_users.rman</p>
<p>Note that the CONNECT clauses are inside the backup_ts_users.rman command file, so there is no reason to provide the password in the command line—meaning that you can eliminate the risk of accidental exposure of the password. Had we not included the password of the catalog user rman inside the command file, we would have had to call the Oracle RMAN executable like this:</p>
<p>rman target=/ catalog=<br />
rman/secretpass@rmancat</p>
<p>If this command were executed, someone on the server could easily get the password of the catalog user by checking the process. When the command file contains the connection information—including the password—for the catalog user, the sensitive information is not visible to anyone watching the process. Note that you should also set the permissions of the command file in such a way that nonadmin users will not be able to read it.</p>
<p>Passing parameters. The backup_ts_users.rman command file works well, but it’s too specific. It forces the output of the backup to one specific directory and backs up only one tablespace (USERS). If you want to back up to a different location or back up a different tablespace, you have to create a new script.</p>
<p>A better strategy is to make an Oracle RMAN command file parameter-driven. Rather than hard-coding specific values in the script, you can include parameters whose values are passed at runtime. Listing 2 shows a modified version of the backup_ts_users .rman command file, named backup_ts_generic.rman. Instead of actual values, the new command file includes the parameters (also known as placeholders or substitution variables) &amp;1 and &amp;2. With a parameter-driven command file, you can define any number of parameters in this manner and pass the values at runtime.</p>
<p>Code Listing 2: Parameter-driven command file</p>
<p>connect target /<br />
connect catalog rman/secretpass@rmancat</p>
<p>run {<br />
allocate channel c1 type disk format &#8216;&amp;1/%U&#8217;;<br />
backup tablespace &amp;2;<br />
}</p>
<p>A shell script, named backup_ts_generic.sh, calls the backup_ts_generic.rman command file with the values /tmp as the backup location (for parameter &amp;1) and USERS as the tablespace name (for parameter &amp;2):</p>
<p>$ORACLE_HOME/bin/rman &lt;&lt;EOF<br />
@backup_ts_generic.rman &#8220;/tmp&#8221; USERS<br />
EOF</p>
<p>You can make this shell script even more generic, so that the parameters are passed from the command line of the file system itself. For example, if you modify the second line in the backup_ts_generic.sh shell script so it reads</p>
<p>@backup_ts_generic.rman &#8220;/tmp&#8221; $1</p>
<p>you will be able to call the backup_ts_generic.rman command file, provide /tmp as the backup location, and pass the tablespace name in the command line. For instance, if you want to back up the MYTS1 tablespace, you can issue</p>
<p>backup_ts_generic.sh MYTS1</p>
<p>Logging. When you run Oracle RMAN scripts via an automated mechanism such as cron in UNIX or Scheduler in Windows, you are not physically watching the command window, so how do you know the output of the Oracle RMAN commands? The output is especially crucial when command execution results in an error and you need to examine the output. To capture the output, you can use the log parameter in the Oracle RMAN command line:</p>
<p>rman cmdfile=backup_ts_users.rman log=backup_ts_users.log</p>
<p>Now the output of the backup_ts_generic.rman command file will be recorded in a file named backup_ts_users.log instead of appearing on the screen. You can view this file later to examine the results of the Oracle RMAN run.</p>
<p>Stored Scripts</p>
<p>Although command files work pretty well in most cases, they have one huge drawback. A command file should be available on the server where the Oracle RMAN backup is to be run. Otherwise, from within the command file, you have to connect from the Oracle RMAN client to the server by using a connect string:</p>
<p>connect target sys/oracle123@remotedb</p>
<p>There are several problems with this setup. First, this modified command file needs to store the password of SYS or some other user with the SYSDBA privilege. In a security-conscious environment, that may not be acceptable. Second, the Oracle RMAN client may be not be compatible with the Oracle Database release. Finally, for performance reasons, you may very well want to run the Oracle RMAN client on the same server as the database itself. But what if you have databases on different servers? You will have to replicate a command file script to all servers. And when you modify the script, you will have to make sure it is copied to all those servers again.</p>
<p>The solution? With Oracle RMAN stored scripts, you can create scripts that are stored inside the Oracle RMAN catalog and not on the server itself. Listing 3 shows an example stored script called backup_ts_users. Because it is stored inside the Oracle RMAN catalog, you will need to connect to the catalog first, as shown in the listing. To execute this script, all you have to do is call it with the execute command from the Oracle RMAN prompt:</p>
<p>RMAN&gt; run { execute script<br />
backup_ts_users; }</p>
<p>Code Listing 3: Stored script for backing up USERS tablespace</p>
<p>C:\&gt; rman<br />
RMAN&gt; connect target /<br />
RMAN&gt; connect catalog rman/secretpass@rmancat<br />
RMAN&gt; create script backup_ts_users<br />
2&gt; comment &#8216;Tablespace Users Backup&#8217;<br />
3&gt; {<br />
4&gt;      allocate channel c1 type disk format &#8216;c:\temp\%U&#8217;;<br />
5&gt;      backup tablespace users;<br />
6&gt; }</p>
<p>The backup_ts_users stored script created in Listing 3 is available only to the target database to which it is currently connected. It is a local stored script, and you can’t execute a local script created for one database in another. To execute a script in multiple databases, create a global stored script by using the keyword GLOBAL between CREATE and SCRIPT. For instance, to create the script shown in Listing 3 as a global stored script, replace</p>
<p>create script backup_ts_users</p>
<p>with</p>
<p>create global script backup_ts_users</p>
<p>Once created, this global stored script can be executed in any database connected to this catalog. If you need to modify the script, there is no need to copy it to all servers or databases; it’s automatically available for execution to all databases connecting to the catalog.</p>
<p>If the global stored script already exists and you want to update it, replace CREATE with REPLACE—</p>
<p>replace global script backup_ts_users</p>
<p>—and include the updated script text.</p>
<p>Parameterization. This backup_ts_users stored script has a very specific purpose: backing up the USERS tablespace. What if you want to back up a different tablespace? Rather than creating multiple scripts, you can create a generic stored script to back up any tablespace (as you did with the command files earlier).</p>
<p>Listing 4 shows how to create a parameterized stored script. In place of the tablespace name, Listing 4 uses the &amp;1 parameter, whose value is passed at runtime. When a parameter-driven stored script is created, Oracle RMAN asks for an example value for any parameter used. When &amp;1 is included as a parameter in line 5, Oracle RMAN asks for an example value. Enter users or any other example tablespace you may want to pass. Remember, the stored script merely asks for an example value; it does not store the value you used in the script itself.</p>
<p>Code Listing 4: Parameter-driven stored script</p>
<p>RMAN&gt; create script backup_ts_any<br />
2&gt; comment &#8216;Any Tablespace Backup&#8217;<br />
3&gt; {<br />
4&gt;      allocate channel c1 type disk format &#8216;c:\temp\%U&#8217;;<br />
5&gt;      backup tablespace &amp;1;<br />
Enter value for 1: users<br />
users;<br />
6&gt; }<br />
7&gt;</p>
<p>created script backup_ts_any</p>
<p>With the parameterized stored script created, pass the value of the parameter via a USING clause. For example, to back up the SYSTEM tablespace by using this backup_ts_any stored script, use the following Oracle RMAN command:</p>
<p>run { execute script<br />
backup_ts_any using &#8216;SYSTEM&#8217;; }</p>
<p>Administration. Oracle RMAN provides features to help administer stored scripts.</p>
<p>To display the list of stored scripts, use the list script names command as follows:</p>
<p>RMAN&gt; list script names;</p>
<p>List of Stored Scripts in Recovery Catalog<br />
Scripts of Target Database ARUPLAP1<br />
Script Name<br />
Description<br />
&#8212;&#8212;&#8212;&#8212;<br />
backup_ts_any<br />
Any Tablespace Backup</p>
<p>backup_ts_users<br />
Tablespace Users Backup</p>
<p>This command displays the names of local as well as global stored scripts.</p>
<p>To display the global scripts only, use the following command:</p>
<p>RMAN&gt; list global script names;</p>
<p>RMAN&gt; print global script<br />
backup_ts_level1_any;</p>
<p>If the stored script you want to print is local, omit the keyword GLOBAL in the command.</p>
<p>To drop a script, such as backup_ts_level1_any, use the following command:</p>
<p>RMAN&gt; delete global script<br />
backup_ts_level1_any;</p>
<p>What if you want to create a stored script from a script file in the file system? You can import the file into the catalog. Here is an example:</p>
<p>RMAN&gt; create script backup_ts_users<br />
from file &#8216;backup_ts_users.rman&#8217;;</p>
<p>Conversely, you can create a file from a stored script (or export a stored script to a file). Here is an example:</p>
<p>RMAN&gt; print script backup_ts_users<br />
to file &#8216;backup_ts_users.rman&#8217;;</p>
<p>Conclusion</p>
<p>Oracle RMAN scripts provide capabilities not only for automation but also for consistency of execution. This article presented two ways to script RMAN commands: via OS-level command files and through scripts stored in a catalog database. Both approaches enable creation of generic scripts that use parameters whose values can be passed at execution time.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deepthinking99.wordpress.com/779/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deepthinking99.wordpress.com/779/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deepthinking99.wordpress.com/779/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deepthinking99.wordpress.com/779/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deepthinking99.wordpress.com/779/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deepthinking99.wordpress.com/779/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deepthinking99.wordpress.com/779/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deepthinking99.wordpress.com/779/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deepthinking99.wordpress.com/779/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deepthinking99.wordpress.com/779/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deepthinking99.wordpress.com&blog=4894307&post=779&subd=deepthinking99&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://deepthinking99.wordpress.com/2009/11/20/scripting-oracle-rman-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1f3b6fbee19bb2cca5ced85efa030302?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">deepthinking99</media:title>
		</media:content>
	</item>
		<item>
		<title>Rewriting SQL for faster performance</title>
		<link>http://deepthinking99.wordpress.com/2009/11/20/rewriting-sql-for-faster-performance/</link>
		<comments>http://deepthinking99.wordpress.com/2009/11/20/rewriting-sql-for-faster-performance/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 07:20:31 +0000</pubDate>
		<dc:creator>Ida Bagus Enderajana</dc:creator>
				<category><![CDATA[Burleson Article]]></category>

		<guid isPermaLink="false">http://deepthinking99.wordpress.com/?p=776</guid>
		<description><![CDATA[Because SQL is a declarative language, you can write the same query in many forms, each getting the same result but with vastly different execution plans and performance.  Re-writing SQL for easier readability (and maintenance) plus faster performance is an important tuning tool.
Rewrite SQL to remove subqueries – Subqueries can be very problematic from [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deepthinking99.wordpress.com&blog=4894307&post=776&subd=deepthinking99&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Because SQL is a declarative language, you can write the same query in many forms, each getting the same result but with vastly different execution plans and performance.  Re-writing SQL for easier readability (and maintenance) plus faster performance is an important tuning tool.</p>
<p>Rewrite SQL to remove subqueries – Subqueries can be very problematic from a performance perspective.</p>
<p>Rewriting the SQL in PL/SQL  &#8211; For certain queries rewriting SQL in PL/SQL can result in more than a 20x performance improvement.</p>
<p>Rewrite SQL to simplify query &#8211; Decomposing a query into multiple queries using the WITH clause (or global temporary tables) greatly aids performance.</p>
<p>In this example, we select all books that do not have any sales.  Note that this is a non-correlated sub-query, but it could be re-written in several ways.<br />
select<br />
book_key<br />
from<br />
book<br />
where<br />
book_key NOT IN (select book_key from sales);</p>
<p>There are serious problems with subqueries that may return NULL values. It is a good idea to discourage the use of the NOT IN clause (which invokes a sub-query) and to prefer NOT EXISTS (which invokes a correlated sub-query), since the query returns no rows if any rows returned by the sub-query contain null values.<br />
select<br />
book_key<br />
from<br />
book<br />
where<br />
NOT EXISTS (select book_key from sales);</p>
<p>Subqueries can often be re-written to use a standard outer join, resulting in faster performance.  As we may know, an outer join uses the plus sign (+) operator to tell the database to return all non-matching rows with NULL values.  Hence we combine the outer join with a NULL test in the WHERE clause to reproduce the result set without using a sub-query.<br />
select<br />
b.book_key<br />
from<br />
book  b,<br />
sales s<br />
where<br />
b.book_key = s.book_key(+)<br />
and<br />
s.book_key IS NULL;</p>
<p>This execution plan will also be faster by eliminating the sub-query.<br />
Rewriting SQL for better readability and faster response time speed</p>
<p>Here is an actual example of a poorly-written SQL query.  It&#8217;s hard to read, and the execution plan is horrible:<br />
SELECT ART.DEMO_MEMBER DEMO_MEMBER,<br />
(SELECT PARAMETER_VALUE<br />
FROM    PPM_CIA_PREMIUM_VAL CIA_VAL<br />
WHERE   CIA_VAL.PRD_DEMO_CHRSTC_MEMBER = ART.DEMO_MEMBER<br />
AND CIA_NAME IN (&#8216;Baseline&#8217;)<br />
AND PRMA_MKT_MEMBER = ?<br />
AND INVOICE_TYPE_NAME IN (&#8216;Weekly&#8217;)<br />
AND GROUP_TYPE_CODE = &#8216;C&#8217;<br />
) WEEKLY_VALS,<br />
(SELECT PARAMETER_VALUE<br />
FROM    PPM_CIA_PREMIUM_VAL CIA_VAL<br />
WHERE   CIA_VAL.PRD_DEMO_CHRSTC_MEMBER = ART.DEMO_MEMBER<br />
AND CIA_NAME IN (&#8216;Baseline&#8217;)<br />
AND PRMA_MKT_MEMBER = ?<br />
AND INVOICE_TYPE_NAME IN (&#8216;Monthly&#8217;)<br />
AND GROUP_TYPE_CODE = &#8216;C&#8217;<br />
) MONTHLY_VALS,<br />
(SELECT PARAMETER_VALUE<br />
FROM    PPM_CIA_PREMIUM_VAL CIA_VAL<br />
WHERE   CIA_VAL.PRD_DEMO_CHRSTC_MEMBER = ART.DEMO_MEMBER<br />
AND CIA_NAME IN (&#8216;Baseline&#8217;)<br />
AND PRMA_MKT_MEMBER = ?<br />
AND INVOICE_TYPE_NAME IN (&#8216;90Day&#8217;)<br />
AND GROUP_TYPE_CODE = &#8216;C&#8217;<br />
) NINETYDAY_VALS,<br />
(SELECT PARAMETER_VALUE<br />
FROM    PPM_CIA_PREMIUM_VAL CIA_VAL<br />
WHERE   CIA_VAL.PRD_DEMO_CHRSTC_MEMBER = ART.DEMO_MEMBER<br />
AND CIA_NAME IN (&#8216;Baseline&#8217;)<br />
AND PRMA_MKT_MEMBER = ?<br />
AND INVOICE_TYPE_NAME IN (&#8216;Annual&#8217;)<br />
AND GROUP_TYPE_CODE = &#8216;C&#8217;<br />
)      ANNUAL_VALS,<br />
&#8216;C&#8217; AS GROUP_TYPE_CODE<br />
FROM<br />
(SELECT DISTINCT PRD_DEMO_CHRSTC_MEMBER DEMO_MEMBER<br />
FROM             PPM_CIA_PREMIUM_VAL<br />
WHERE            CIA_NAME IN (&#8216;Baseline&#8217;)<br />
AND PRMA_MKT_MEMBER = ?<br />
AND INVOICE_TYPE_NAME IN (&#8216;Weekly&#8217; ,<br />
&#8216;Monthly&#8217;,<br />
&#8216;Annual&#8217; ,<br />
&#8216;90Day&#8217;)<br />
AND GROUP_TYPE_CODE = &#8216;C&#8217;<br />
GROUP BY         PRD_DEMO_CHRSTC_MEMBER<br />
) ART</p>
<p>UNION ALL<br />
SELECT   ART.DEMO_MEMBER DEMO_MEMBER,<br />
(SELECT PARAMETER_VALUE<br />
FROM    PPM_CIA_PREMIUM_VAL CIA_VAL<br />
WHERE   CIA_VAL.PRD_DEMO_CHRSTC_MEMBER = ART.DEMO_MEMBER<br />
AND CIA_NAME IN (&#8216;Baseline&#8217;)<br />
AND PRMA_MKT_MEMBER = ?<br />
AND INVOICE_TYPE_NAME IN (&#8216;Weekly&#8217;)<br />
AND GROUP_TYPE_CODE = &#8216;T&#8217;<br />
) WEEKLY_VALS,<br />
(SELECT PARAMETER_VALUE<br />
FROM    PPM_CIA_PREMIUM_VAL CIA_VAL<br />
WHERE   CIA_VAL.PRD_DEMO_CHRSTC_MEMBER = ART.DEMO_MEMBER<br />
AND CIA_NAME IN (&#8216;Baseline&#8217;)<br />
AND PRMA_MKT_MEMBER = ?<br />
AND INVOICE_TYPE_NAME IN (&#8216;Monthly&#8217;)<br />
AND GROUP_TYPE_CODE = &#8216;T&#8217;<br />
) MONTHLY_VALS,<br />
(SELECT PARAMETER_VALUE<br />
FROM    PPM_CIA_PREMIUM_VAL CIA_VAL<br />
WHERE   CIA_VAL.PRD_DEMO_CHRSTC_MEMBER = ART.DEMO_MEMBER<br />
AND CIA_NAME IN (&#8216;Baseline&#8217;)<br />
AND PRMA_MKT_MEMBER = ?<br />
AND INVOICE_TYPE_NAME IN (&#8216;90Day&#8217;)<br />
AND GROUP_TYPE_CODE = &#8216;T&#8217;<br />
) NINETYDAY_VALS,<br />
(SELECT PARAMETER_VALUE<br />
FROM    PPM_CIA_PREMIUM_VAL CIA_VAL<br />
WHERE   CIA_VAL.PRD_DEMO_CHRSTC_MEMBER = ART.DEMO_MEMBER<br />
AND CIA_NAME IN (&#8216;Baseline&#8217;)<br />
AND PRMA_MKT_MEMBER = ?<br />
AND INVOICE_TYPE_NAME IN (&#8216;Annual&#8217;)<br />
AND GROUP_TYPE_CODE = &#8216;T&#8217;<br />
)      ANNUAL_VALS,<br />
&#8216;T&#8217; AS GROUP_TYPE_CODE<br />
FROM<br />
(SELECT DISTINCT PRD_DEMO_CHRSTC_MEMBER DEMO_MEMBER<br />
FROM             PPM_CIA_PREMIUM_VAL<br />
WHERE            CIA_NAME IN (&#8216;Baseline&#8217;)<br />
AND PRMA_MKT_MEMBER = ?<br />
AND INVOICE_TYPE_NAME IN (&#8216;Weekly&#8217; ,<br />
&#8216;Monthly&#8217;,<br />
&#8216;Annual&#8217; ,<br />
&#8216;90Day&#8217;)<br />
AND GROUP_TYPE_CODE = &#8216;T&#8217;<br />
GROUP BY         PRD_DEMO_CHRSTC_MEMBER<br />
) ART<br />
ORDER BY GROUP_TYPE_CODE</p>
<p>Look like Greek?  That’s not a good SQL practice, to write convoluted SQL!  Let’s look at the same query, rewritten for clarity and faster performance.</p>
<p>The above convoluted query can be completely re-written.  This SQL runs faster and more efficiently.</p>
<p>Rewritten query:</p>
<p>The above convoluted query can be completely re-written.  This SQL runs faster and more efficiently.<br />
SELECT ART.PRD_DEMO_CHRSTC_MEMBER DEMO_MEMBER,<br />
SUM(DECODE(ART.INVOICE_TYPE_NAME,&#8217;Weekly&#8217;,ART.parameter_value))  WEEKLY_VALS,<br />
SUM(DECODE(ART.INVOICE_TYPE_NAME,&#8217;Monthly&#8217;,ART.parameter_value)) MONTHLY_VALS,<br />
SUM(DECODE(ART.INVOICE_TYPE_NAME,&#8217;90Day&#8217;,ART.parameter_value))   NINETYDAY_VALS,<br />
SUM(DECODE(ART.INVOICE_TYPE_NAME,&#8217;Annual&#8217;,ART.parameter_value))  ANNUAL_VALS,<br />
ART.GROUP_TYPE_CODE<br />
FROM   PPM_CIA_PREMIUM_VAL ART<br />
WHERE            CIA_NAME IN (&#8216;Baseline&#8217;)<br />
AND PRMA_MKT_MEMBER = ?<br />
AND INVOICE_TYPE_NAME IN (&#8216;Weekly&#8217; ,<br />
&#8216;Monthly&#8217;,<br />
&#8216;Annual&#8217; ,<br />
&#8216;90Day&#8217;)<br />
AND GROUP_TYPE_CODE IN (&#8216;C&#8217;,'T&#8217;)<br />
GROUP BY ART.PRD_DEMO_CHRSTC_MEMBER,ART.GROUP_TYPE_CODE<br />
ORDER BY ART.GROUP_TYPE_CODE, ART.PRD_DEMO_CHRSTC_MEMBER;</p>
<p>As we see, SQL is very flexible and an equivalent query can be written in many ways, all giving the same result, but with radically different readability and execution response time.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deepthinking99.wordpress.com/776/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deepthinking99.wordpress.com/776/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deepthinking99.wordpress.com/776/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deepthinking99.wordpress.com/776/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deepthinking99.wordpress.com/776/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deepthinking99.wordpress.com/776/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deepthinking99.wordpress.com/776/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deepthinking99.wordpress.com/776/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deepthinking99.wordpress.com/776/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deepthinking99.wordpress.com/776/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deepthinking99.wordpress.com&blog=4894307&post=776&subd=deepthinking99&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://deepthinking99.wordpress.com/2009/11/20/rewriting-sql-for-faster-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1f3b6fbee19bb2cca5ced85efa030302?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">deepthinking99</media:title>
		</media:content>
	</item>
		<item>
		<title>Oracle 11g R2 new parallel query management enhancements</title>
		<link>http://deepthinking99.wordpress.com/2009/11/20/oracle-11g-r2-new-parallel-query-management-enhancements/</link>
		<comments>http://deepthinking99.wordpress.com/2009/11/20/oracle-11g-r2-new-parallel-query-management-enhancements/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 07:10:56 +0000</pubDate>
		<dc:creator>Ida Bagus Enderajana</dc:creator>
				<category><![CDATA[Burleson Article]]></category>

		<guid isPermaLink="false">http://deepthinking99.wordpress.com/?p=773</guid>
		<description><![CDATA[The database industry is clearly in the midst of massive server consolidation, an economic imperative whereby the old-fashioned one database/one server approach of the client-server days has been rendered obsolete. Today, single servers with 32 and 64 CPU’s and hundreds of gigabytes of RAM can host dozens of large Oracle databases.
While the 2nd age of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deepthinking99.wordpress.com&blog=4894307&post=773&subd=deepthinking99&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The database industry is clearly in the midst of massive server consolidation, an economic imperative whereby the old-fashioned one database/one server approach of the client-server days has been rendered obsolete. Today, single servers with 32 and 64 CPU’s and hundreds of gigabytes of RAM can host dozens of large Oracle databases.</p>
<p>While the 2nd age of mainframe computing came about to facilitate easier DBA management, there remain the impressive benefits of having a back of dozens of CPU’s to perform full scans very quickly.</p>
<p>When invoking Oracle parallel query, there are many perils and pitfalls:</p>
<p>Setting parallelism on at the table or system level influences the optimizer, and sometimes makes full-scan operations appear cheaper than they really are.</p>
<p>Determining the optimal degree of parallelism is tricky. The real optimal degree of parallelism depends on the physical placement of the data blocks on disk as well as the number of processors on the server (cpu_count).</p>
<p>To relieve these issues with parallel query, in Oracle 11g Release 2, the following new parallel query parameters are included:</p>
<p>The parallel_degree_policy parameter</p>
<p>The parallel_min_time_threshold parameter</p>
<p>The parallel_degree_limit parameter</p>
<p>The parallel_force_local parameter</p>
<p>Let’s take a close look at these important enhancements to Oracle parallel query in 11g Release 2.<br />
The parallel_degree_policy parameter</p>
<p>The parallel_degree_policy parameter is related to the amount of table data residing in the data buffer cache.  Using parallel_degree_policy allows Oracle to bypass direct path reads when Oracle determines that lots of the table data blocks already reside in the data buffer cache.</p>
<p>In traditional 32-bit systems (limited by on ly a few gig of RAM for the SGA), direct path reads (which bypass the SGA were always faster than reading a large table through the data buffer.  However, with the advent of 64-bit servers with dozens of gigabytes for the db_cache_size, large tables are often be fully cached, negating the need to always perform direct path reads for parallel large-table full-table scans.</p>
<p>Guy Harrison conducted some benchmark tests of parallel_degree_policy and we see details on how parallel_degree_policy evaluates the caching of large tables:</p>
<p>“If PARALLEL_DEGREE_POLICY is set to AUTO then Oracle might perform buffered IO instead of direct path IO. . . The documentation says that the optimizer decides whether or not to use direct path depending on the size of the table and the buffer cache and the likelihood that some data might be in memory.”<br />
The parallel_min_time_threshold parameter</p>
<p>The parallel_min_time_threshold parameter only allows parallel query to be invoked against large tables or indexes, those where the num_rows suggests that it will take more than nn seconds to scan the table.  The default for parallel_min_time_threshold is 30 (seconds), but you can now adjust this threshold according to your optimal definition of what constitutes a “large table”.  This parameter appears to be related to the deprecated small_table_threshold parameter.<br />
The parallel_degree_limit parameter</p>
<p>The parallel_degree_limit parameter seta a limit on the maximum degree of parallelism.  The default is cpu_count*2.<br />
The parallel_force_local parameter</p>
<p>The parallel_force_local parameter prohibits “parallel parallelism”, a case where parallel queries on a RAC node are limited only to the local instance node.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deepthinking99.wordpress.com/773/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deepthinking99.wordpress.com/773/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deepthinking99.wordpress.com/773/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deepthinking99.wordpress.com/773/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deepthinking99.wordpress.com/773/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deepthinking99.wordpress.com/773/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deepthinking99.wordpress.com/773/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deepthinking99.wordpress.com/773/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deepthinking99.wordpress.com/773/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deepthinking99.wordpress.com/773/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deepthinking99.wordpress.com&blog=4894307&post=773&subd=deepthinking99&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://deepthinking99.wordpress.com/2009/11/20/oracle-11g-r2-new-parallel-query-management-enhancements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1f3b6fbee19bb2cca5ced85efa030302?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">deepthinking99</media:title>
		</media:content>
	</item>
	</channel>
</rss>