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

<channel>
	<title>ORATraining Blog &#187; Oracle</title>
	<atom:link href="http://www.oratraining.com/blog/tag/oracle/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.oratraining.com/blog</link>
	<description>Not just another Oracle Blog</description>
	<lastBuildDate>Wed, 01 Sep 2010 15:23:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Installing Oracle Applications (eBusiness Suite) Release 12 on Solaris</title>
		<link>http://www.oratraining.com/blog/2010/05/installing-oracle-applications-ebusiness-suite-r12-release-12-on-solaris/</link>
		<comments>http://www.oratraining.com/blog/2010/05/installing-oracle-applications-ebusiness-suite-r12-release-12-on-solaris/#comments</comments>
		<pubDate>Mon, 03 May 2010 10:05:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Installing Oracle Applications]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle Applications]]></category>
		<category><![CDATA[Oracle Applications DBA]]></category>
		<category><![CDATA[Oracle Applications issues]]></category>
		<category><![CDATA[Administration]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[installing]]></category>
		<category><![CDATA[oracle applications]]></category>
		<category><![CDATA[R12]]></category>
		<category><![CDATA[release 12]]></category>

		<guid isPermaLink="false">http://www.oratraining.com/blog/?p=307</guid>
		<description><![CDATA[Let us consider we are installing Oracle eBusiness Suite Release 12 (12.1.1) on Sun Solaris 10 on SPARC 64 bit platform. First of all following pre-requisites must be checked at the Operating System level. ﻿ Packages SUNWarc SUNWbtool SUNWcsl SUNWhea SUNWi15cs SUNWi1cs SUNWi1of SUNWlibC SUNWlibm SUNWlibms SUNWsprot SUNWtoo SUNWuiu8 SUNWulcf SUNWxwfnt Patches 125100-04 or higher [...]]]></description>
			<content:encoded><![CDATA[<p>Let us consider we are installing Oracle eBusiness Suite Release 12 (12.1.1) on Sun Solaris 10 on SPARC 64 bit platform.</p>
<p>First of all following pre-requisites must be checked at the Operating System level.</p>
<blockquote><p>﻿</p>
<p><strong>Packages</strong></p>
<p><strong> </strong></p>
<table border="0" cellspacing="0" cellpadding="0" width="83">
<tbody>
<tr>
<td width="83" valign="bottom">SUNWarc</td>
</tr>
<tr>
<td width="83" valign="bottom">SUNWbtool</td>
</tr>
<tr>
<td width="83" valign="bottom">SUNWcsl</td>
</tr>
<tr>
<td width="83" valign="bottom">SUNWhea</td>
</tr>
<tr>
<td width="83" valign="bottom">SUNWi15cs</td>
</tr>
<tr>
<td width="83" valign="bottom">SUNWi1cs</td>
</tr>
<tr>
<td width="83" valign="bottom">SUNWi1of</td>
</tr>
<tr>
<td width="83" valign="bottom">SUNWlibC</td>
</tr>
<tr>
<td width="83" valign="bottom">SUNWlibm</td>
</tr>
<tr>
<td width="83" valign="bottom">SUNWlibms</td>
</tr>
<tr>
<td width="83" valign="bottom">SUNWsprot</td>
</tr>
<tr>
<td width="83" valign="bottom">SUNWtoo</td>
</tr>
<tr>
<td width="83" valign="bottom">SUNWuiu8</td>
</tr>
<tr>
<td width="83" valign="bottom">SUNWulcf</td>
</tr>
<tr>
<td width="83" valign="bottom">SUNWxwfnt</td>
</tr>
</tbody>
</table>
<p><strong>Patches</strong></p>
<ul>
<li>125100-04 or higher</li>
<li>120473-05 or higher</li>
<li>127111-02 or higher</li>
<li>137111-04 or higher</li>
</ul>
<p><strong>Kernel parameters in </strong><strong>/etc/system</strong><strong> </strong></p>
<p>rlim_fd_max                                     65536</p>
<p>noexec_user_stack                        1</p>
<p>semsys:seminfo_semmni            100</p>
<p>semsys:seminfo_semmsl             256</p>
<p>shmsys:shminfo_shmmax           4294967295</p>
<p>shmsys:shminfo_shmmni            100</p>
<p><strong><br />
ulimit Value Settings</strong></p>
<p>Verify that the owner of the Oracle Application Server and Oracle Database server file systems have the following &#8216;ulimit&#8217; values:</p>
<ul>
<li>time (seconds) = unlimited</li>
<li>file (blocks) = unlimited</li>
<li>data (kbytes) = unlimited</li>
<li>stack (kbytes) = unlimited</li>
<li>memory (kbytes) = unlimited</li>
<li>coredump (blocks) = unlimited</li>
<li>nofiles (descriptors) = 65536</li>
</ul>
<p><strong>Java requirements<br />
</strong><br />
JDK 6 (bundled with R12, no need to manually install)</p>
<p><strong>Operating system utilities</strong></p>
<ul>
<li>ar</li>
<li>ld</li>
<li>make</li>
<li>X Display Server</li>
<li>ldd</li>
<li>gcc</li>
<li>g++</li>
</ul>
</blockquote>
<p>Next step is to create required users.</p>
<blockquote><p>groupadd dba</p>
<p>useradd -g dba oradev</p>
<p>useradd -g dba appldev</p>
<div id="_mcePaste">
<div id="_mcePaste">passwd oradev</div>
<div id="_mcePaste">New Password:</div>
<div id="_mcePaste">Re-enter new Password:</div>
<div id="_mcePaste">passwd: password successfully changed for oradev</div>
<div id="_mcePaste">passwd appldev</div>
<div id="_mcePaste">New Password:</div>
<div id="_mcePaste">Re-enter new Password:</div>
<div id="_mcePaste">passwd: password successfully changed for appldev</div>
</div>
</blockquote>
<p>Now let&#8217;s create required directories as root.</p>
<blockquote><p>mkdir /u01</p>
<p>mkdir /u01/oracle</p>
<p>mkdir /u01/oracle/ERPDEV</p>
<p>mkdir /u01/oracle/ERPDEV/db</p>
<p>mkdir /u01/oracle/ERPDEV/apps</p>
<p>chown oradev:dba /u01</p>
<p>chown oradev:dba /u01/oracle</p>
<p>chown oradev:dba /u01/oracle/ERPDEV</p>
<p>chown oradev:dba /u01/oracle/ERPDEV/db</p>
<p>chown appldev:dba /u01/oracle/ERPDEV/apps</p></blockquote>
<p>Create Staging area or else you can directly install from DVDs but you may need to switch DVDs during the installation.</p>
<p>Here we have created Staging directory as <strong>/u01/R12stage/</strong></p>
<p>There are multiple ways for creating staging areas. The simplest method is to copy all DVD contents to Staging directory in following subfolders.</p>
<p><strong>startCD,  oraDB, oraAppDB, oraApps, oraAS,  NLS-&lt;Language&gt; (if installing NLS)</strong></p>
<p>Or else you can use <strong>adautostg.pl</strong> to create a staging area automatically.</p>
<blockquote><p><span style="color: #ff0000;">ORATraining Tip: Execute the following to avoid unexpected errors during the installation since we are doing multiuser installation.<br />
<span style="color: #000000;">chmod 777 /tmp</span></span></p></blockquote>
<p><strong><span style="font-weight: normal;"><br />
</span></strong></p>
<blockquote><p><span style="color: #ff0000;">ORATraining tip: Sometimes it has been noticed on some Solaris based installation that installation will throw following error.</span></p>
<p>/u01/R12stage/startCD/Disk1/rapidwiz/rapidwiz: whoami: not found</p>
<p><span style="color: #ff0000;">Execute the following before starting the installation to avoid the issue.</span></p>
<p><span style="color: #000000;">export PATH=$PATH:/usr/ucb/</span></p></blockquote>
<p><span style="color: #000000;"><strong>Starting the installation:</strong></span></p>
<blockquote><p>cd /u01/R12stage/startCD/Disk1/rapidwiz</p>
<p>./rapidwiz</p></blockquote>
<blockquote><p><span style="color: #ff0000;">ORATraining tip: You can also execute directly with the path like &#8220;<span style="color: #000000;">/u01/R12stage/startCD/Disk1/rapidwiz/rapidwiz/rapidwiz</span>&#8221; to avoid selecting DVDs at the end of every component installation.</span></p></blockquote>
<blockquote><p><span style="color: #ff0000;">ORATraining Tip: Sometimes you may encounter following error after starting the installation.</span></p>
<p>/u01/R12stage/startCD/Disk1/rapidwiz/rapidwiz: /tmp/RapidInstall/bin/runWizard.sh: cannot execute</p>
<p><span style="color: #ff0000;">Execute the following to fix this if you encounter the same.</span></p>
<p><span style="color: #ff0000;"><span style="color: #ff0000;"><span style="color: #000000;">chmod 777 /u01/R12stage/startCD/Disk1/rapidwiz/bin</span></span></span></p></blockquote>
<p><strong>Welcome Screen:</strong></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-01.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-01.jpg" alt="" /></a></p>
<p>Do not change anything in this screen unless you are upgrading existing Oracle Applications release. Express release will go with many default parameters and skip certain steps but not recommended for an Apps DBA.</p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-02.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-02.jpg" alt="" /></a></p>
<p>Keep these blank if installing on test machine. This can always be filled later. You will need a valid CSI number and associated email id for this.</p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-03.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-03.jpg" alt="" /></a></p>
<p>No not change anything in this screen unless you are restarting a failed installation or installing on secondary nodes in case of multinode installation.</p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-04.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-04.jpg" alt="" /></a></p>
<p>Select a port pool here. All default ports will be added by a number selected in port pool and those ports will be assigned accordingly. For example with port pool 10, default ports will change as follows.</p>
<p>Web Server port will become 8010 (8000 + 10)</p>
<p>Forms port will become 9010 (9000 + 10)</p>
<p>Reports port will become 7010 (7000 + 10)</p>
<p>and so on..</p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-05.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-05.jpg" alt="" /></a></p>
<p><span id="more-307"></span><br />
<a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-06.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-06.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-07.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-07.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-08.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-08.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-09.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-09.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-10.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-10.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-11.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-11.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-12.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-12.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-13.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-13.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-15.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-15.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-16.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-16.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-17.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-17.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-19.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-19.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-20.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-20.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-22.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-22.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-23.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-23.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-24.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-24.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-26.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-26.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-27.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-27.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-28.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-28.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-29.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-29.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-32.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-32.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-35.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-35.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-36.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-36.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-37.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-37.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-38.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-38.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-39.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-39.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-40.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-40.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-41.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-41.jpg" alt="" /></a></p>
<p><a href="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-arabic-license.jpg" target="_new"><img src="http://www.oratraining.com/images/blog/installation/ebiz_1211_Sol_Sparc/R12-Solaris-arabic-license.jpg" alt="" /></a></p>
<left><a class="tt" href="http://twitter.com/home/?status=Installing+Oracle+Applications+%28eBusiness+Suite%29+Release+12+on+Solaris+http://bit.ly/bEE2Sd" title="Post to Twitter"><img class="nothumb" src="http://www.oratraining.com/blog/wp-content/plugins/tweet-this/icons/tt-twitter-big3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.oratraining.com/blog/2010/05/installing-oracle-applications-ebusiness-suite-r12-release-12-on-solaris/&amp;title=Installing+Oracle+Applications+%28eBusiness+Suite%29+Release+12+on+Solaris" title="Post to Digg"><img class="nothumb" src="http://www.oratraining.com/blog/wp-content/plugins/tweet-this/icons/tt-digg-big4.png" alt="Post to Digg" /></a></left><div class="fblike" style="height:25px; height:25px; overflow:hidden;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.oratraining.com%2Fblog%2F2010%2F05%2Finstalling-oracle-applications-ebusiness-suite-r12-release-12-on-solaris%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allow Transparency="true" style="border:none; overflow:hidden; width:450px;"></iframe></div><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.oratraining.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.oratraining.com/blog/2010/05/installing-oracle-applications-ebusiness-suite-r12-release-12-on-solaris/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Operating Systems Endian formats for migrating databases across platforms</title>
		<link>http://www.oratraining.com/blog/2010/04/operating-systems-endian-formats-for-migrating-databases-across-platforms/</link>
		<comments>http://www.oratraining.com/blog/2010/04/operating-systems-endian-formats-for-migrating-databases-across-platforms/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 05:22:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle DBA]]></category>
		<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Oracle Database cloning]]></category>
		<category><![CDATA[cross-platform transportable tablespace]]></category>
		<category><![CDATA[database migration]]></category>
		<category><![CDATA[endian formats]]></category>
		<category><![CDATA[transportable tablespace]]></category>

		<guid isPermaLink="false">http://www.oratraining.com/blog/?p=249</guid>
		<description><![CDATA[Nowadays DBAs face requirements for migrating databases across different platforms like from Windows to Linux or Solaris or vice versa. While doing this we would require to use transportable tablespaces or cross-platform transportable tablespaces. In order to decide whether the migration would be simple or will involve file conversion, following command is used to identify [...]]]></description>
			<content:encoded><![CDATA[<p>Nowadays DBAs face requirements for migrating databases across different platforms like from Windows to Linux or Solaris or vice versa. While doing this we would require to use transportable tablespaces or cross-platform transportable tablespaces. In order to decide whether the migration would be simple or will involve file conversion, following command is used to identify platform endian format. If the endian formats are same then the process pretty straightforward.</p>
<blockquote>
<div id="_mcePaste"><span style="font-size: small;"><span style="line-height: normal;"><span style="color: #993300;">SQL&gt; select * from v$transportable_platform order by platform_id;</span></p>
<p><span style="color: #993300;"> </span></p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="103" valign="top"><span style="color: #993300;"><strong>PLATFORM_ID</strong></span></td>
<td width="258" valign="top"><span style="color: #993300;"><strong>PLATFORM_NAME</strong></span></td>
<td width="132" valign="top"><span style="color: #993300;"><strong>ENDIAN_FORMAT</strong></span></td>
</tr>
<tr>
<td width="103" valign="top"><span style="color: #993300;">1</span></td>
<td width="258" valign="top"><span style="color: #993300;">Solaris[tm] OE (32-bit)</span></td>
<td width="132" valign="top"><span style="color: #993300;">Big</span></td>
</tr>
<tr>
<td width="103" valign="top"><span style="color: #993300;">2</span></td>
<td width="258" valign="top"><span style="color: #993300;">Solaris[tm] OE (64-bit)</span></td>
<td width="132" valign="top"><span style="color: #993300;">Big</span></td>
</tr>
<tr>
<td width="103" valign="top"><span style="color: #993300;">3</span></td>
<td width="258" valign="top"><span style="color: #993300;">HP-UX (64-bit)</span></td>
<td width="132" valign="top"><span style="color: #993300;">Big</span></td>
</tr>
<tr>
<td width="103" valign="top"><span style="color: #993300;">4</span></td>
<td width="258" valign="top"><span style="color: #993300;">HP-UX IA (64-bit)</span></td>
<td width="132" valign="top"><span style="color: #993300;">Big</span></td>
</tr>
<tr>
<td width="103" valign="top"><span style="color: #993300;">5</span></td>
<td width="258" valign="top"><span style="color: #993300;">HP Tru64 UNIX</span></td>
<td width="132" valign="top"><span style="color: #993300;">Little</span></td>
</tr>
<tr>
<td width="103" valign="top"><span style="color: #993300;">6</span></td>
<td width="258" valign="top"><span style="color: #993300;">AIX-Based Systems (64-bit)</span></td>
<td width="132" valign="top"><span style="color: #993300;">Big</span></td>
</tr>
<tr>
<td width="103" valign="top"><span style="color: #993300;">7</span></td>
<td width="258" valign="top"><span style="color: #993300;">Microsoft Windows IA (32-bit)</span></td>
<td width="132" valign="top"><span style="color: #993300;">Little</span></td>
</tr>
<tr>
<td width="103" valign="top"><span style="color: #993300;">8</span></td>
<td width="258" valign="top"><span style="color: #993300;">Microsoft Windows IA (64-bit)</span></td>
<td width="132" valign="top"><span style="color: #993300;">Little</span></td>
</tr>
<tr>
<td width="103" valign="top"><span style="color: #993300;">9</span></td>
<td width="258" valign="top"><span style="color: #993300;">IBM zSeries Based Linux</span></td>
<td width="132" valign="top"><span style="color: #993300;">Big</span></td>
</tr>
<tr>
<td width="103" valign="top"><span style="color: #993300;">10</span></td>
<td width="258" valign="top"><span style="color: #993300;">Linux IA (32-bit)</span></td>
<td width="132" valign="top"><span style="color: #993300;">Little</span></td>
</tr>
<tr>
<td width="103" valign="top"><span style="color: #993300;">11</span></td>
<td width="258" valign="top"><span style="color: #993300;">Linux IA (64-bit)</span></td>
<td width="132" valign="top"><span style="color: #993300;">Little</span></td>
</tr>
<tr>
<td width="103" valign="top"><span style="color: #993300;">12</span></td>
<td width="258" valign="top"><span style="color: #993300;">Microsoft Windows 64-bit for AMD</span></td>
<td width="132" valign="top"><span style="color: #993300;">Little</span></td>
</tr>
<tr>
<td width="103" valign="top"><span style="color: #993300;">13</span></td>
<td width="258" valign="top"><span style="color: #993300;">Linux 64-bit for AMD</span></td>
<td width="132" valign="top"><span style="color: #993300;">Little</span></td>
</tr>
<tr>
<td width="103" valign="top"><span style="color: #993300;">14</span></td>
<td width="258" valign="top"><span style="color: #993300;">HP Open VMS</span></td>
<td width="132" valign="top"><span style="color: #993300;">Little</span></td>
</tr>
<tr>
<td width="103" valign="top"><span style="color: #993300;">15</span></td>
<td width="258" valign="top"><span style="color: #993300;">Apple Mac OS</span></td>
<td width="132" valign="top"><span style="color: #993300;">Big</span></td>
</tr>
</tbody>
</table>
<p></span></span></div>
</blockquote>
<left><a class="tt" href="http://twitter.com/home/?status=Operating+Systems+Endian+formats+for+migrating+databases+across+platforms+http://bit.ly/daUp0Q" title="Post to Twitter"><img class="nothumb" src="http://www.oratraining.com/blog/wp-content/plugins/tweet-this/icons/tt-twitter-big3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.oratraining.com/blog/2010/04/operating-systems-endian-formats-for-migrating-databases-across-platforms/&amp;title=Operating+Systems+Endian+formats+for+migrating+databases+across+platforms" title="Post to Digg"><img class="nothumb" src="http://www.oratraining.com/blog/wp-content/plugins/tweet-this/icons/tt-digg-big4.png" alt="Post to Digg" /></a></left><div class="fblike" style="height:25px; height:25px; overflow:hidden;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.oratraining.com%2Fblog%2F2010%2F04%2Foperating-systems-endian-formats-for-migrating-databases-across-platforms%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allow Transparency="true" style="border:none; overflow:hidden; width:450px;"></iframe></div><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.oratraining.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.oratraining.com/blog/2010/04/operating-systems-endian-formats-for-migrating-databases-across-platforms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fix for &#8220;Internet explorer has closed this webpage to help protect your computer&#8221;</title>
		<link>http://www.oratraining.com/blog/2010/04/internet-explorer-has-closed-this-webpage-to-help-protect-your-computer/</link>
		<comments>http://www.oratraining.com/blog/2010/04/internet-explorer-has-closed-this-webpage-to-help-protect-your-computer/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 11:01:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Application server]]></category>
		<category><![CDATA[Browser issues]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle Applications]]></category>
		<category><![CDATA[Oracle Applications issues]]></category>
		<category><![CDATA[Oracle developers]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows Clients]]></category>
		<category><![CDATA[Windows issues]]></category>
		<category><![CDATA[crash]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[jvm.dll]]></category>
		<category><![CDATA[oracle applications]]></category>

		<guid isPermaLink="false">http://www.oratraining.com/blog/?p=227</guid>
		<description><![CDATA[Many users face issue running Oracle forms on Microsoft Internet Explorer 8 (IE8) which causes the page to redirect to following url res://ieframe.dll/acr_depnx_error.htm#&#60;domain&#62;,http://&#60;server&#62;:&#60;port&#62;/forms/frmservlet?config=&#60;config&#62; It displays following error. Internet explorer has closed this webpage to help protect your computer A malfunctioning or malicious add-on has caused Internet Explorer to close this webpage. Solution: Goto Internet Explorer [...]]]></description>
			<content:encoded><![CDATA[<p>Many users face issue running Oracle forms on Microsoft Internet Explorer 8 (IE8) which causes the page to redirect to following url</p>
<p>res://ieframe.dll/acr_depnx_error.htm#&lt;domain&gt;,http://&lt;server&gt;:&lt;port&gt;/forms/frmservlet?config=&lt;config&gt;</p>
<p>It displays following error.</p>
<p><strong>Internet explorer has closed this webpage to help protect your computer</strong></p>
<p><strong><span style="font-weight: normal; font-size: 15px;">A malfunctioning or malicious add-on has caused Internet  Explorer to close this webpage.</span></strong></p>
<p><strong><span style="font-weight: normal; font-size: 15px;"><a href="http://www.oratraining.com/blog/wp-content/uploads/2010/04/IE-error22.jpg"><img class="alignnone size-full wp-image-352" title="Internet explorer has closed this webpage to help protect your computer" src="http://www.oratraining.com/blog/wp-content/uploads/2010/04/IE-error22.jpg" alt="" width="539" height="343" /></a></span></strong></p>
<p><span style="font-weight: normal;"> </span></p>
<p><strong><span style="color: #ff0000;">Solution:</span></strong></p>
<p>Goto Internet Explorer -&gt; Tools -&gt; Internet Options -&gt; Advanced -&gt; Scroll down to Security -&gt; Uncheck &#8220;Enable memory protection to help mitigate online attacks*&#8221;</p>
<p>Close all browser windows and restart the browser. The issue should have been fixed <img src='http://www.oratraining.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><a href="http://www.oratraining.com/blog/wp-content/uploads/2010/04/IE-fix22.jpg"><img class="alignnone size-full wp-image-351" title="Uncheck Enable memory protection to help mitigate online attacks" src="http://www.oratraining.com/blog/wp-content/uploads/2010/04/IE-fix22.jpg" alt="" width="289" height="374" /></a></p>
<p><strong>Edit: </strong>Alternatively you can use either of following 2 alternate solutions.</p>
<p><strong><span style="color: #ff0000;">Alternate 2:</span></strong></p>
<p>Open registry using start-&gt;Run-&gt;regedit-&gt;ok</p>
<p>Go to <strong>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main</strong></p>
<p>On the right hand side you will see a DWORD key called <strong>DEPOff. </strong>IF this is set to value 0, just <strong>change it to 1</strong> and close registry editor.</p>
<p><a href="http://www.oratraining.com/blog/wp-content/uploads/2010/04/IE-DEP1.jpg"><img class="alignnone size-full wp-image-349" title="REGEDIT Turn Data Execution Prevention Off" src="http://www.oratraining.com/blog/wp-content/uploads/2010/04/IE-DEP1.jpg" alt="" width="683" height="349" /></a></p>
<p>Restart Internet Explorer and check if the problem has been fixed or not.</p>
<p><strong><span style="color: #ff0000;">Alternate 3:</span></strong></p>
<p>Right click on My Computer-&gt;Properties (or start-&gt;Run-&gt;<strong>sysdm.cpl</strong>-&gt;ok)</p>
<p>Click on &#8220;<strong>Advanced</strong>&#8221; Tab. Click on &#8220;<strong>Settings</strong>&#8221; button next to Performance.</p>
<p>Click on last tab &#8220;<strong>Data Execution Prevention</strong>&#8221;</p>
<p>Select Second option and then select &#8220;Internet Explorer&#8221; from the bottom pan.</p>
<p>(If &#8220;Internet Explorer&#8221; is not already present there then just click on &#8220;Add&#8221; and then select &#8220;c:\Program Files\Internet Explorer\iexplore.exe&#8221;)</p>
<p><a href="http://www.oratraining.com/blog/wp-content/uploads/2010/04/IE-DEP2.gif"><img class="alignnone size-full wp-image-353" title="Turn Data Execution Prevention Off for Internet Explorer" src="http://www.oratraining.com/blog/wp-content/uploads/2010/04/IE-DEP2.gif" alt="" width="547" height="372" /></a></p>
<p>Click OK and restart internet explorer. The problem should have been fixed.</p>
<left><a class="tt" href="http://twitter.com/home/?status=Fix+for+%E2%80%9CInternet+explorer+has+closed+this+webpage+to+help+protect+your+computer%E2%80%9D+http://bit.ly/cebqTE" title="Post to Twitter"><img class="nothumb" src="http://www.oratraining.com/blog/wp-content/plugins/tweet-this/icons/tt-twitter-big3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.oratraining.com/blog/2010/04/internet-explorer-has-closed-this-webpage-to-help-protect-your-computer/&amp;title=Fix+for+%E2%80%9CInternet+explorer+has+closed+this+webpage+to+help+protect+your+computer%E2%80%9D" title="Post to Digg"><img class="nothumb" src="http://www.oratraining.com/blog/wp-content/plugins/tweet-this/icons/tt-digg-big4.png" alt="Post to Digg" /></a></left><div class="fblike" style="height:25px; height:25px; overflow:hidden;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.oratraining.com%2Fblog%2F2010%2F04%2Finternet-explorer-has-closed-this-webpage-to-help-protect-your-computer%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allow Transparency="true" style="border:none; overflow:hidden; width:450px;"></iframe></div><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.oratraining.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.oratraining.com/blog/2010/04/internet-explorer-has-closed-this-webpage-to-help-protect-your-computer/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>Fix for IE crash on launching forms in Oracle Applications 11i (11.5.10)</title>
		<link>http://www.oratraining.com/blog/2009/12/fix-for-ie-crash-on-launching-forms-in-oracle-applications-11i-11-5-10/</link>
		<comments>http://www.oratraining.com/blog/2009/12/fix-for-ie-crash-on-launching-forms-in-oracle-applications-11i-11-5-10/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 08:03:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Browser issues]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle Applications]]></category>
		<category><![CDATA[Oracle Applications DBA]]></category>
		<category><![CDATA[Oracle Applications issues]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows Clients]]></category>
		<category><![CDATA[Windows issues]]></category>
		<category><![CDATA[7]]></category>
		<category><![CDATA[crash]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[jvm]]></category>
		<category><![CDATA[jvm.dll]]></category>
		<category><![CDATA[launch]]></category>
		<category><![CDATA[oracle applications]]></category>

		<guid isPermaLink="false">http://www.oratraining.com/blog/?p=203</guid>
		<description><![CDATA[Many of you would have noticed that while launching forms from Oracle Applications 11.5.10 using Internet Explorer (IE 7) then it might crash with following error. Though it may work perfectly fine in mozilla firefox. This is the working fix for the issue. Solution-1: 1) Take backup of jvm.dll located at c:\Program Files\Oracle\JInitiator 1.3.1.21\bin\hotspot directory. [...]]]></description>
			<content:encoded><![CDATA[<p style="margin-top: 0.5em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; line-height: 19px; padding: 0px;">Many of you would have noticed that while launching forms from Oracle Applications 11.5.10 using Internet Explorer (IE 7) then it might crash with following error. Though it may work perfectly fine in mozilla firefox.</p>
<p><img class="alignnone size-full wp-image-208" title="ie-crash1" src="http://www.oratraining.com/blog/wp-content/uploads/2009/12/ie-crash1.JPG" alt="ie-crash1" width="334" height="224" /></p>
<p style="margin-top: 0.5em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; line-height: 19px; padding: 0px;"><img class="alignnone size-full wp-image-209" title="jvm-error1" src="http://www.oratraining.com/blog/wp-content/uploads/2009/12/jvm-error1.JPG" alt="jvm-error1" width="422" height="273" /></p>
<p style="margin-top: 0.5em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; line-height: 19px; padding: 0px;">This is the working fix for the issue.</p>
<p style="margin-top: 0.5em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; line-height: 19px; padding: 0px;"><strong>Solution-1:</strong></p>
<p style="margin-top: 0.5em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; line-height: 19px; padding: 0px;">1) Take backup of jvm.dll located at <strong>c:\Program Files\Oracle\JInitiator 1.3.1.21\bin\hotspot</strong> directory.<br />
2) Copy <strong>jvm.dll</strong> from <strong>C:\Program Files\Java\jre1.6.0_07\bin\client</strong> (or whichever highest version of jre you have) to <strong>c:\Program Files\Oracle\JInitiator 1.3.1.21\bin\hotspot</strong><br />
3) Clear browser cache and also Oracle Jar cache (Remove all files from<strong> c:\documents and settings\&lt;username&gt;\Oralce Jar cache</strong>)<br />
4)	Close all the browsers and restart</p>
<p style="margin-top: 0.5em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; line-height: 19px; padding: 0px;">Enjoy !! The issue should have been resolved now !</p>
<p style="margin-top: 0.5em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; line-height: 19px; padding: 0px;"><strong>Solution-2:</strong></p>
<p style="margin-top: 0.5em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; line-height: 19px; padding: 0px;">In case if you are unable to find the jvm.dll in that location or if the above solution didn&#8217;t work for you, you can download the working jvm.dll from <a href="http://blog.oratraining.com/files/jvm.dll" target="_blank">this link</a>.</p>
<left><a class="tt" href="http://twitter.com/home/?status=Fix+for+IE+crash+on+launching+forms+in+Oracle+Applications+11i+%2811.5.10%29+http://bit.ly/bCMrGS" title="Post to Twitter"><img class="nothumb" src="http://www.oratraining.com/blog/wp-content/plugins/tweet-this/icons/tt-twitter-big3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.oratraining.com/blog/2009/12/fix-for-ie-crash-on-launching-forms-in-oracle-applications-11i-11-5-10/&amp;title=Fix+for+IE+crash+on+launching+forms+in+Oracle+Applications+11i+%2811.5.10%29" title="Post to Digg"><img class="nothumb" src="http://www.oratraining.com/blog/wp-content/plugins/tweet-this/icons/tt-digg-big4.png" alt="Post to Digg" /></a></left><div class="fblike" style="height:25px; height:25px; overflow:hidden;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.oratraining.com%2Fblog%2F2009%2F12%2Ffix-for-ie-crash-on-launching-forms-in-oracle-applications-11i-11-5-10%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allow Transparency="true" style="border:none; overflow:hidden; width:450px;"></iframe></div><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.oratraining.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.oratraining.com/blog/2009/12/fix-for-ie-crash-on-launching-forms-in-oracle-applications-11i-11-5-10/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>PL/SQL quick reference</title>
		<link>http://www.oratraining.com/blog/2009/06/plsql-quick-reference/</link>
		<comments>http://www.oratraining.com/blog/2009/06/plsql-quick-reference/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 05:48:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Database programming]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Oracle PL/SQL]]></category>
		<category><![CDATA[Oracle developers]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[pl/sql]]></category>
		<category><![CDATA[quick reference]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[sqlplus]]></category>
		<category><![CDATA[syntax]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.oratraining.com/blog/?p=185</guid>
		<description><![CDATA[Oracle PL/SQL Quick Reference   PL/SQL Block Structure DECLARE --Optional   --Variables, Cursors, User-defined exceptions BEGIN --Mandatory   --SQL statements   --PL/SQL statements EXCEPTION --Optional   --Actions to perform when errors occur END; --Mandatory   PL/SQL Block Type Anonymous               Procedure               Function [DECLARE]               PROCEDURE name          FUNCTION name                         [...]]]></description>
			<content:encoded><![CDATA[<pre>
<h2><strong>Oracle PL/SQL Quick Reference</strong></h2>

<strong> </strong>
<h3>PL/SQL Block Structure</h3>

DECLARE --Optional

  --Variables, Cursors, User-defined exceptions

BEGIN --Mandatory

  --SQL statements

  --PL/SQL statements

EXCEPTION --Optional

  --Actions to perform when errors occur

END; --Mandatory

<span id="more-185"></span> 

<strong>PL/SQL Block Type</strong>

<strong>Anonymous               Procedure               Function</strong>

[DECLARE]               PROCEDURE name          FUNCTION name

                        IS                      RETURN datatype                                                         IS

BEGIN                   BEGIN                   BEGIN

  --statements            --statements            --statements

                                                  RETURN value;

[EXCEPTION]             [EXCEPTION]             [EXCEPTION]

END ;                   END ;                   END ;

<strong> </strong>

<strong>Declaring PL/SQL Variables</strong>

identifier [CONSTANT] datatype [NOT NULL]

   [:=|DEFAULT expr];

<strong> </strong>

<strong>Assigning Values to Variables</strong>

identifier := expr;

<strong>Types of Variables</strong>

<strong>PL/SQL variables:</strong>
<ul type="disc">
<li>Scalar</li>
<li>Composite</li>
<li>Reference</li>
<li>LOB(<strong>L</strong>arge <strong>OB</strong>jects)</li>
</ul>

<strong>Non-PL/SQL variables:</strong> Bind or host variables
<ul type="disc">
<li>Used to pass run time values out of the PL/SQL block back to the Host environment</li>
</ul>

<strong> </strong>

<strong>Base Scalar Datatypes</strong>

VARCHAR2(maximum_length)      BOOLEAN           CHAR[(maximum_length)]

DATE                         LONG              LONG RAW    

BINARY_INTEGER                PLS_INTEGER       NUMBER(precision,scale)

TIMESTAMP

<strong>The %TYPE Attribute</strong>

Identifier Table_name.column_name%TYPE ;

Identifier Variable_name%TYPE ;

<strong> </strong>

<strong>Composite Datatypes</strong>

INDEX BY TABLE          RECORD      NESTED TABLE      VARRAY

<strong> </strong>

<strong>LOB Datatypes</strong>

CLOB        BLOB        BFILE             NCLOB

<strong> </strong>

<strong>Creating Bind Variables</strong>

VARIABLE variable_name dataype

<strong> </strong>

<strong>Displaying Bind Variables</strong>

PRINT [variable_name]

<em>NOTE: To reference a bind variable in PL/SQL, you must prefix it's name with colon (:)</em>

<strong>Commenting Code</strong>

--prefix single-line comments with two dashes

/* Place muti-line comment between the symbols */

<strong> </strong>

<strong>SELECT Statements in PL/SQL</strong>

SELECT {column_list|*}

INTO {variable_name[,variable_name]...

      |record_name}

FROM table

[WHERE condition];

<em>NOTE: The INTO clause is must and queries must return one and only one row. A CURSOR can be used to retrieve more than one row.</em>

<em> </em>

<strong>Implicit Cursor Attributes for DML statements</strong>

SQL%ROWCOUNT

SQL%FOUND

SQL%NOTFOUND

SQL%ISOPEN

<strong> </strong>

<strong>Control Structures</strong>

<strong>IF Statement                              Basic Loop</strong>

IF condition THEN                         LOOP

   statements;                               statements;

[ELSIF condition THEN                        ...

   statements;]                              EXIT [WHEN condition];

[ELSE                                     END LOOP;

   statements;]

END IF;

<strong> </strong>

<strong>FOR Loop                                  WHILE Loop</strong>

FOR counter IN [REVERSE]                  WHILE condition LOOP

   Lower_bound..upper_bound LOOP             statement1;

   statement1;                               statement2;

   statement2;                               ...

   ...                                    END LOOP;

END LOOP;

<strong> </strong>

<strong>CASE</strong>

CASE selector

   WHEN expression1 THEN result1

   WHEN expression2 THEN result2

   ...

   WHEN expressionN THEN resultN

   [ELSE resultN+1]

END;

<strong>Creating a PL/SQL Record</strong>

TYPE type_name IS RECORD

(field_declaration[,field_declaration]...) ;

identifier type_name ;

<strong> </strong>

<strong>Where field_declaration is:</strong>

field_name {field_type|variable%TYPE|

table.column%TYPE|table%ROWTYPE}

[[NOT NULL] {:=|DEFAULT} expr]

<strong> </strong>

<strong>Referencing Fields in the Record</strong>

record_name.field_name

<strong> </strong>

<strong>Declaring Records with the %ROWTYPE Attribute</strong>

DECLARE

record_name       reference%ROWTYPE

<strong> </strong>

<strong>Creating a PL/SQL Table (INDEX BY Table)</strong>

TYPE type_name IS TABLE OF

{column_type|variable%TYPE|table.column%TYPE

|variable%ROWTYPE} [NOT NULL]

[INDEX BY BINARY_INTEGER];

identifier type_name ;

<strong> </strong>

<strong>Referencing a PL/SQL table</strong>

pl_sql_table_name(primary_key_value)

<strong>Using PL/SQL Table Method</strong>

table_name.method_name[(parameters)]

<strong> </strong>

<strong>PL/SQL Table Methods</strong>

EXITS(n)    COUNT       FIRST       LAST        PRIOR(n)

NEXT(n)     EXTEND(n,i)             TRIM        DELETE

<strong>PL/SQL Table of Records</strong>

TYPE table_name_type IS TABLE OF table_name%ROWTYPE

INDEX BY BINARY_INTEGER ;

table_name table_name_type ;

<strong> </strong>

<strong>Referencing a Table of Records</strong>

table_name(index).field

<strong> </strong>

<strong>Cursor</strong>

<strong>Declaring the Cursor in Declaration Section</strong>

CURSOR cursor_name IS select_statement ;

record_name cursor_name%ROWTYPE ;

<strong> </strong>

<strong>Opening and Closing the Cursor</strong>

OPEN cursor_name ;

CLOSE cursor_name ;

<strong> </strong>

<strong>Fetching Data from the Cursor</strong>

FETCH cursor_name

INTO [variable1(,variable2,...)

    |record_name] ;

<strong> </strong>

<strong>Explicit Cusor Attributes</strong>

cursor_name%ISOPEN

cursor_name%NOTFOUND

cursor_name%FOUND

cursor_name%ROWCOUNT

<strong> </strong>

<strong>Cursor FOR Loops</strong>

FOR record_name IN cursor_name LOOP

   statement1;

   statement2;

   ...

END LOOP;

<strong> </strong>

<strong>Cursor FOR Loops Using Subqueries</strong>

FOR record_name IN (subqueries) LOOP

statement1

...

END LOOP ;

<strong> </strong>

<strong>Cursors with Parameters</strong>

CURSOR cursor_name [(cursor_parameter_name datatype

[,...])]

IS select_statement

[FOR UPDATE [OF column_reference][NOWAIT]];

<strong> </strong>

<strong>Parameter Name</strong>

cursor_parameter_name [IN] datatype [{:=|DEFAULT}expr]

<strong> </strong>

<strong>Openning with Parameters</strong>

OPEN cursor_name(cursor_parameter_name[,...]);

<strong> </strong>

<strong>Cursor FOR Loops with parameters</strong>

FOR record_name IN cursor_name(cursor_parameter_name

[,...]) LOOP

   statement1;

   statement2;

   ...

END LOOP;

<strong> </strong>

<strong>WHERE CURRENT OF clause</strong>

UPDATE|DELETE ... WHERE CURRENT OF cursor_name ;

<strong> </strong>

<strong>Predefined Exceptions</strong>

NO_DATA_FOUND

TOO_MANY_ROWS

INVALID_CURSOR

ZERO_DIVIDE

DUP_VAL_ON_INDEX

<strong> </strong>

<strong>Exception</strong>

<strong>Trapping Exceptions</strong>

EXCEPTION

   WHEN exception1 [OR exception2 ...] THEN

statement1 ;

statement2 ;

...

   [WHEN exception3 [OR exception4 ...] THEN

statement1 ;

statement2 ;

...]

   [WHEN OTHERS THEN

statement1 ;

statement2 ;

...]

<strong> </strong>

<strong>Declaring Non-Predefined Oracle Sever Exception</strong>

DECLARE

   exception EXCEPTION ;

   PRAGMA EXCEPTION_INIT(exception, error_number) ;

<strong> </strong>

<strong>Referencing the declared Non-predefined execption</strong>

BEGIN

   ...

EXCEPTION

   WHEN exception THEN

statement1 ;

...

END ;

<strong>Trapping User-Defined Exceptions</strong>

DECLARE

   exception EXCEPTION ;

BEGIN

   ...

   IF SQL%NOTFOUND THEN

RAISE exception ;

   END IF ;

   ...

EXCEPTION

   WHEN exception THEN

statement1 ;

...

END ;

<strong>Functions for Trapping Exceptions</strong>

SQLCODE           return error code

SQLERRM           return error message

<strong> </strong>

<strong>RAISE_APPLICATION_ERROR</strong><strong> procedure(Executable/Exception</strong>

<strong>Section)</strong>

RAISE_APPLICATION_ERROR ( error_number,

  message [, {TRUE|FALSE}]) ;

error_number      between -20000 to -20999

message           string up to 2,048 bytes long

TRUE              placed on the stack of previous errors.

FALSE             replaces all previous errors

<strong> </strong></pre>
<left><a class="tt" href="http://twitter.com/home/?status=PL%2FSQL+quick+reference+http://bit.ly/dtyonV" title="Post to Twitter"><img class="nothumb" src="http://www.oratraining.com/blog/wp-content/plugins/tweet-this/icons/tt-twitter-big3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.oratraining.com/blog/2009/06/plsql-quick-reference/&amp;title=PL%2FSQL+quick+reference" title="Post to Digg"><img class="nothumb" src="http://www.oratraining.com/blog/wp-content/plugins/tweet-this/icons/tt-digg-big4.png" alt="Post to Digg" /></a></left><div class="fblike" style="height:25px; height:25px; overflow:hidden;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.oratraining.com%2Fblog%2F2009%2F06%2Fplsql-quick-reference%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allow Transparency="true" style="border:none; overflow:hidden; width:450px;"></iframe></div><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.oratraining.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.oratraining.com/blog/2009/06/plsql-quick-reference/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Oracle SQL Quick reference</title>
		<link>http://www.oratraining.com/blog/2009/06/sq-quick-referenence/</link>
		<comments>http://www.oratraining.com/blog/2009/06/sq-quick-referenence/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 05:44:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle SQL]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[pl/sql]]></category>
		<category><![CDATA[quick reference]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[sqlplus]]></category>
		<category><![CDATA[syntax]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.oratraining.com/blog/?p=182</guid>
		<description><![CDATA[Oracle SQL Quick Reference SELECT Query Statement SELECT [DISTINCT] {*, column [alias],&#8230;} FROM table WHERE condition(s)] ORDER BY {column, exp, alias} [ASC&#124;DESC]] NOTE: Avoid using DISTINCT with large table as it first does sorting of all the rows and then eliminates duplicate rows, so need a full table scan and thus it&#8217;s very slow. ORDER [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Oracle SQL Quick Reference</strong><strong> </strong></p>
<p><strong>SELECT Query Statement</strong></p>
<p>SELECT [DISTINCT] {*, column [alias],&#8230;}</p>
<p>FROM table</p>
<p>WHERE condition(s)]</p>
<p>ORDER BY {column, exp, alias} [ASC|DESC]]</p>
<p><strong><em>NOTE:</em></strong><em> </em></p>
<p><em>Avoid using DISTINCT with large table as it first does sorting of all the rows and then eliminates duplicate rows, so need a full table scan and thus it&#8217;s very slow.</em></p>
<p><em> </em></p>
<p><em>ORDER BY is the last clause to get executed and thus could see all the column aliases; You can sort by a columns that is not in SELECT list; Default sorting order is Ascending (ASC)</em></p>
<p><span id="more-182"></span></p>
<p><strong>Joins</strong></p>
<p><strong>Oracle proprietary syntax for version 8i and earlier</strong></p>
<p><strong>Cartesian Product</strong></p>
<p>SELECT table1.*, table2.*,[...]</p>
<p>FROM table1,table2[,...]</p>
<p><strong> </strong></p>
<p><strong>Equijoin(Simple joins or inner join)</strong></p>
<p>SELECT table1.*,table2.*</p>
<p>FROM table1,table2</p>
<p>WHERE table1.column = table2.column</p>
<p><strong> </strong></p>
<p><strong>Non-Equijoin</strong></p>
<p>SELECT table1.*, table2.*</p>
<p>FROM table1, table2</p>
<p>WHERE table1.column</p>
<p>BETWEEN table2.column1 AND table2.column2</p>
<p><strong> </strong></p>
<p><strong>Outer join</strong></p>
<p>SELECT table1.*,table2.*</p>
<p>FROM table1,table2</p>
<p>WHERE table1.column(+) = table2.column</p>
<p>SELECT table1.*,table2.*</p>
<p>FROM table1,table2</p>
<p>WHERE table1.column = table2.column(+)</p>
<p><strong> </strong></p>
<p><strong>Self join</strong></p>
<p>SELECT alias1.*,alias2.*</p>
<p>FROM table1 alias1,table1 alias2</p>
<p>WHERE alias1.column = alias2.column</p>
<p><strong>SQL: 1999 compliant syntax for version 9i</strong></p>
<p>SELECT table1.column, table2.column</p>
<p>FROM table1</p>
<p>[<strong>CROSS JOIN</strong> table2] |</p>
<p>[<strong>NATURAL JOIN</strong> table2] |</p>
<p>[<strong>JOIN</strong> table2 <strong>USING</strong> (column_name)] |</p>
<p>[<strong>JOIN</strong> table2</p>
<p><strong>ON</strong> (table1.column_name=table2.column_name)] |</p>
<p>[<strong>LEFT</strong>|<strong>RIGHT</strong>|<strong>FULL</strong> <strong>OUTER</strong> <strong>JOIN</strong> table2</p>
<p><strong>ON</strong> (table1.column_name=table2.column_name)];</p>
<p><strong> </strong></p>
<p><strong>Aggregation Selecting</strong></p>
<p>SELECT [column,] group_function(column),&#8230;</p>
<p>FROM table</p>
<p>[WHERE condition]</p>
<p>[GROUP BY group_by_expression]</p>
<p>[HAVING group_condition]</p>
<p>[ORDER BY column];</p>
<p><strong> </strong></p>
<p><strong>Group function</strong></p>
<p>AVG([DISTINCT|ALL]n)</p>
<p>COUNT(*|[DISTINCT|ALL]expr)</p>
<p>MAX([DISTINCT|ALL]expr)</p>
<p>MIN([DISTINCT|ALL]expr)</p>
<p>STDDEV([DISTINCT|ALL]n)</p>
<p>SUM([DISTINCT|ALL]n)</p>
<p>VARIANCE([DISTINCT|ALL]n)</p>
<p><strong> </strong></p>
<p><strong>NOTE:</strong></p>
<p><em>All columns in the SELECT list that are not in group functions must be in the GROUP BY clause; but GROUP BY column does not have to be in the SELECT list.</em></p>
<p><em> </em></p>
<p><em>You can not use group functions in the WHERE clause;You use the HAVING clause to restrict groups.</em></p>
<p><em>All group functions except count(*) ignores null values. The NVL function forces group functions to include null values.</em></p>
<p><strong> </strong></p>
<p><strong>Subquery</strong></p>
<p>SELECT select_list</p>
<p>FROM table</p>
<p>WHERE expr operator(SELECT    select_list</p>
<p>FROM      table);</p>
<p><strong>NOTE:</strong></p>
<p><em>The subquery(inner query) executes once before the main query</em></p>
<p><em> </em></p>
<p><em>The result of the subquery is used by the main query(outer query)</em></p>
<p><em> </em></p>
<p><em>The ORDER BY clause in the subquery is not needed unless you are performing TOP-N analysis.</em></p>
<p><strong>single-row comparison operators: </strong>Return only one row</p>
<p>=        &gt;     &gt;=    &lt;     &lt;=    &lt;&gt;</p>
<p><strong>multiple-row comparison operators: </strong>Return more than one row</p>
<p>IN         ANY             ALL</p>
<p><strong> </strong></p>
<p><strong>Multiple-column Subqueries</strong></p>
<p>SELECT column, column, &#8230;</p>
<p>FROM table</p>
<p>WHERE (column, column, &#8230;) IN</p>
<p>(SELECT column, column, &#8230;</p>
<p>FROM table</p>
<p>WHERE condition);</p>
<p><strong>Data Manipulation Statements (DML)</strong></p>
<p><strong>INSERT Statement(one row)</strong></p>
<p>INSERT INTO table [ (column [,column...])]</p>
<p>VALUES (value [,value...]);</p>
<p><strong> </strong></p>
<p><strong>INSERT Statement with Subquery</strong></p>
<p>INSERT INTO table [ column(, column) ]</p>
<p>subquery;</p>
<p><strong> </strong></p>
<p><strong>UPDATE Statement</strong></p>
<p>UPDATE table</p>
<p>SET column = value [, column = value,...]</p>
<p>[WHERE condition];</p>
<p><strong> </strong></p>
<p><strong>Updating with Multiple-column Subquery</strong></p>
<p>UPDATE table</p>
<p>SET (column, column,&#8230;) =</p>
<p>(SELECT column, column,&#8230;</p>
<p>FROM table</p>
<p>WHERE condition)</p>
<p>WHERE condition;</p>
<p><strong> </strong></p>
<p><strong>Deleting Rows with DELETE Statement</strong></p>
<p>DELETE [FROM] table</p>
<p>[WHERE condition];</p>
<p><strong> </strong></p>
<p><strong>Deleting Rows Based on Another Table</strong></p>
<p>DELETE FROM table</p>
<p>WHERE column = (SELECT column</p>
<p>FROM table</p>
<p>WHERE condition);</p>
<p><strong>MERGE statement</strong></p>
<p>MERGE INTO table_name table_aliase</p>
<p>USING (table|view|sub_query) alias</p>
<p>ON (join condition)</p>
<p>WHEN MATCHED THEN</p>
<p>UPDATE SET</p>
<p>col1 = col1_val,</p>
<p>col2 = col2_val</p>
<p>WHEN NOT MATCHED THEN</p>
<p>INSERT (column_list)</p>
<p>VALUES (column_values);</p>
<p><strong>NOTE:</strong></p>
<p>MERGE provides ability to conditionally update or insert data into a database table. It is useful in data warehousing applications. It avoids separate updates; increase performance and ease of use</p>
<p><strong> </strong></p>
<p><strong>Transaction Control Statements (TCL)</strong></p>
<p>COMMIT;</p>
<p>SAVEPOINT name;</p>
<p>ROLLBACK [TO SAVEPOINT name];</p>
<p><strong> </strong></p>
<p><strong>Displaying table structure</strong></p>
<p>DESC[RIBE] tablename</p>
<p><strong>Data Definition Statemetns (DDL)</strong></p>
<p><strong>CREATE TABLE Statement</strong></p>
<p>CREATE TABLE [schema.]table</p>
<p>(column datatype [DEFAULT expr] [,...]);</p>
<p><strong> </strong></p>
<p><strong>CREATE TABLE Statement with Subquery</strong></p>
<p>CREATE TABLE [schema.]table</p>
<p>[(column, column...)]</p>
<p>AS subquery;</p>
<p><strong>NOTE: </strong></p>
<p><em>When a table is created using existing table except &#8220;NOT NULL&#8221; constraint, no other constraints are copied. If condition satisfied even rows are copied.</em></p>
<p><em> </em></p>
<p><strong> </strong></p>
<p><strong>Datatype</strong></p>
<p>VARCHAR2(size)    CHAR(size)        NUMBER(p,s)       DATE</p>
<p>LONG              CLOB              RAW               LONG RAW</p>
<p>BLOB              BFILE             ROWID</p>
<p><strong> </strong></p>
<p><strong>ALTER TABLE Statement </strong></p>
<p><strong>Adding columns</strong></p>
<p>ALTER TABLE table_name</p>
<p>ADD (column datatype [DEFAULT expr]</p>
<p>[, column datatype]&#8230;);</p>
<p><strong> </strong></p>
<p><strong>Changing a column&#8217;s type, size and default value of a Table</strong></p>
<p>ALTER TABLE table_name</p>
<p>MODIFY (column datatype [DEFAULT expr]</p>
<p>[, column datatype]&#8230;);</p>
<p><strong>RENAMING table column: </strong>Supported by 9.2 and higher version only<strong> </strong></p>
<p>ALTER TABLE table_name</p>
<p>RENAME column_name to new_column_name;</p>
<p><strong> </strong></p>
<p><strong>Dropping a column</strong></p>
<p>ALTER TABLE table_name</p>
<p>DROP (column);</p>
<p><strong> </strong></p>
<p><strong>Dropping a Table</strong></p>
<p>DROP TABLE table_name;</p>
<p><strong> </strong></p>
<p><strong>Changing the Name of an Object</strong></p>
<p>RENAME old_name TO new_name;</p>
<p><strong> </strong></p>
<p><strong>Trancating a Table</strong></p>
<p>TRUNCATE TABLE table_name;</p>
<p><strong> </strong></p>
<p><strong>Adding Comments to a Table</strong></p>
<p>COMMENT ON TABLE table_name | COLUMN table.column</p>
<p>IS &#8216;text&#8217;;</p>
<p><strong> </strong></p>
<p><strong>Dropping a comment from a table</strong></p>
<p>COMMENT ON TABLE table_name | COLUMN table.column IS &#8221; ;</p>
<p><strong> </strong></p>
<p><strong>Data Dictionary</strong></p>
<p>ALL_OBJECTS       USER_OBJECTS</p>
<p>ALL_TABLES        USER_TABLES</p>
<p>ALL_CATALOG       USER_CATALOG or CAT</p>
<p>ALL_COL_COMMENTS USER_COL_COMMENTS</p>
<p>ALL_TAB_COMMENTS USER_TAB_COMMENTS</p>
<p><strong> </strong></p>
<p><strong>Defining Constraints</strong></p>
<p>CREATE TABLE [schema.]table</p>
<p>column datatype [DEFAULT expr][NOT NULL]</p>
<p>[column_constraint],&#8230;</p>
<p>[table_constraint][,...]);</p>
<p><strong> </strong></p>
<p><strong>Column constraint level</strong></p>
<p>column [CONSTRAINT constraint_name] constraint_type,</p>
<p><strong> </strong></p>
<p><strong>Constraint_type</strong></p>
<p>PRIMARY KEY REFERENCES table(column) UNIQUE</p>
<p>CHECK (condition)</p>
<p><strong> </strong></p>
<p><strong>Table constraint level</strong>(except NOT NULL)</p>
<p>column,&#8230;,[CONSTRAINT constraint_name]</p>
<p>constraint_type (column,&#8230;),</p>
<p><strong> </strong></p>
<p><strong>NOT NULL Constraint (Only Column Level)</strong></p>
<p>CONSTRAINT table[_column...]_nn NOT NULL &#8230;</p>
<p><strong> </strong></p>
<p><strong>UNIQUE Key Constraint</strong></p>
<p>CONSTRAINT table[_column..]_uk UNIQUE (column[,...])</p>
<p><strong> </strong></p>
<p><strong>PRIMARY Key Constraint</strong></p>
<p>CONSTRAINT table[_column..]_pk PRIMARY (column[,...])</p>
<p><strong> </strong></p>
<p><strong>NOTE: </strong></p>
<p><em>PRIMARY Key defined on more than column called &#8216;Composite Primary Key&#8217; and to define composite primary key you need table level constraint as two columns are involved.</em></p>
<p><strong> </strong></p>
<p><strong>FOREIGN Key Constraint</strong></p>
<p>CONSTRAINT table[_column..]_fk</p>
<p>FOREIGN KEY (column[,...])</p>
<p>REFERENCES table (column[,...])[ON DELETE CASCADE]</p>
<p>[ON DELETE SET NULL];</p>
<p><strong> </strong></p>
<p><strong>CHECK constraint</strong></p>
<p>CONSTRAINT table[_column..]_ck CHECK (condition)</p>
<p><strong> </strong></p>
<p><strong>Adding a Constraint</strong>(except NOT NULL)</p>
<p>ALTER TABLE table_name</p>
<p>ADD [CONSTRAINT constraint_name ] type (column);</p>
<p><strong> </strong></p>
<p><strong>Adding a NOT NULL constraint</strong></p>
<p>ALTER TABLE table_name</p>
<p>MODIFY (column datatype [DEFAULT expr]</p>
<p>[CONSTRAINT constraint_name_nn] NOT NULL);</p>
<p><strong> </strong></p>
<p><strong>Dropping a Constraint</strong></p>
<p>ALTER TABLE table_name</p>
<p>DROP CONSTRAINT constraint_name;</p>
<p>ALTER TABLE table_name</p>
<p>DROP PRIMARY KEY | UNIQUE (column) |</p>
<p>CONSTRAINT constraint_name [CASCADE];</p>
<p><strong> </strong></p>
<p><strong>Disabling Constraints</strong></p>
<p>ALTER TABLE table_name</p>
<p>DISABLE CONSTRAINT constraint_name [CASCADE];</p>
<p><strong> </strong></p>
<p><strong>Enabling Constraints</strong></p>
<p>ALTER TABLE table_name</p>
<p>ENABLE CONSTRAINT constraint_name;</p>
<p><strong>NOTE:</strong></p>
<p><em>A UNIQUE or PRIMARY KEY index is automatically created if you enable a UNIQUE key or PRIMARY KEY constraint.</em></p>
<p><strong> </strong></p>
<p><strong>Data Dictionary</strong></p>
<p>ALL_CONSTRAINTS        USER_CONSTRAINTS</p>
<p>ALL_CONS_COLUMNS        USER_CONS_COLUMNS</p>
<p><strong> </strong></p>
<p><strong>View</strong></p>
<p><strong>Creating or Modifying a View</strong></p>
<p>CREATE [OR REPLACE] [FORCE|NOFORCE] VIEW view</p>
<p>[(alias[, alias]&#8230;)]</p>
<p>AS subquery</p>
<p>[WITH CHECK OPTION [CONSTRAINT constraint_name]]</p>
<p>[WITH READ ONLY [CONSTRAINT constraint_name]];</p>
<p><strong>Top-N Analysis</strong></p>
<p>SELECT [column_list], ROWNUM</p>
<p>FROM  (SELECT [column_list]</p>
<p>FROM table_name</p>
<p>ORDER BY Top-N_column)</p>
<p>WHERE ROWNUM &lt;= N;</p>
<p><em> </em></p>
<p><strong>Removing a View</strong></p>
<p>DROP VIEW view;</p>
<p><strong>SEQUENCE</strong></p>
<p><strong>CREATE SEQUENCE Statement</strong></p>
<p>CREATE SEQUENCE sequence</p>
<p>[INCREMENT BY n]</p>
<p>[START WITH n]</p>
<p>[{MAXVALUE n| NOMAXVALUE}]</p>
<p>[{MINVALUE n| NOMINVALUE}]</p>
<p>[{CYCLE | NOCYCLE}]</p>
<p>[{CACHE [n|20]| NOCACHE}];</p>
<p><strong> </strong></p>
<p><strong>Pseudocolumns</strong></p>
<p>sequence.NEXTVAL        sequence.CURRVAL</p>
<p><strong> </strong></p>
<p><strong>Modifying a Sequence (No START WITH option)</strong></p>
<p>ALTER SEQUENCE sequence</p>
<p>[INCREMENT BY n]</p>
<p>[{MAXVALUE n| NOMAXVALUE}]</p>
<p>[{MINVALUE n| NOMINVALUE}]</p>
<p>[{CYCLE | NOCYCLE}]</p>
<p>[{CACHE [n|20]| NOCACHE}];</p>
<p><strong> </strong></p>
<p><strong>Removing a Sequence</strong></p>
<p>DROP SEQUENCE sequence;</p>
<p><strong> </strong></p>
<p><strong>Index</strong></p>
<p><strong>Creating an Index</strong></p>
<p>CREATE INDEX index</p>
<p>ON TABLE (column[,column]&#8230;);</p>
<p><strong> </strong></p>
<p><strong>Removing an Index</strong></p>
<p>DROP INDEX index;</p>
<p><strong> </strong></p>
<p><strong>Synoym</strong></p>
<p>CREATE [PUBLIC] SYNONYM synonym</p>
<p>FOR object;</p>
<p><strong>Removing Synonyms</strong></p>
<p>DROP SYNONYM synonym;</p>
<p><strong> </strong></p>
<p><strong>Data Dictionary</strong></p>
<p>ALL_VIEWS                     USER_VIEWS</p>
<p>ALL_SEQUENCES                 USER_SEQUENCES</p>
<p>ALL_INDEXES                   USER_INDEXES</p>
<p>ALL_IND_COLUMNS               USER_IND_COLUMNS</p>
<p><strong> </strong></p>
<p><strong>System Privileges (DBA)       User System Privileges</strong></p>
<p>CREATE USER                   CREATE SESION</p>
<p>DROP USER                     CREATE TABLE</p>
<p>DROP ANY TABLE                CREATE SEQUENCE</p>
<p>BACKUP ANY TABLE              CREATE VIEW</p>
<p>CREATE PROCEDURE</p>
<p><strong>Creating Users</strong></p>
<p>CREATE USER user</p>
<p>IDENTIFIED BY password;</p>
<p><strong> </strong></p>
<p><strong>Creating Roles</strong></p>
<p>CREATE ROLE role;</p>
<p><strong>Granting System Privileges</strong></p>
<p>GRANT privelges[,...] TO user[,...];</p>
<p>GRANT privelges TO role;</p>
<p>GRANT role TO user[,...];</p>
<p><strong> </strong></p>
<p><strong>Changing Password</strong></p>
<p>ALTER USER user IDENTIFIED BY new_password;</p>
<p><strong> </strong></p>
<p><strong>Dropping Users</strong></p>
<p>DROP USER user [CASCADE];</p>
<p><strong> </strong></p>
<p><strong>Dropping Roles</strong></p>
<p>DROP ROLE role;</p>
<p><strong> </strong></p>
<p><strong>Object Privileges</strong></p>
<p>Object      Table       View        Sequence          Procedure</p>
<p>ALTER         X                        X</p>
<p>DELETE        X          X</p>
<p>EXECUTE                                                  X</p>
<p>INDEX         X</p>
<p>INSERT        X          X</p>
<p>REFERENCES   X</p>
<p>SELECT        X          X             X</p>
<p>UPDATE        X          X</p>
<p><strong> </strong></p>
<p><strong>Object Privileges</strong></p>
<p>GRAND object_priv [(column)]</p>
<p>ON object</p>
<p>TO {user|role|PUBLIC}</p>
<p>[WITH GRANT OPTION];</p>
<p><strong> </strong></p>
<p><strong>Revoking Object Privileges</strong></p>
<p>REVOKE {privilege [,privilege...] | ALL}</p>
<p>ON object</p>
<p>FROM {user[,user...]|role|PUBLIC}</p>
<p>[CASCADE CONSTRAINTS];</p>
<p><strong> </strong></p>
<p><strong>Data Dictionary</strong></p>
<p>ROLE_SYS_PRIVS</p>
<p>ROLE_TAB_PRIVS                USER_ROLE_PRIVS</p>
<p>USER_TAB_PRIVS_MADE           USER_TAB_PRIVS_RECD</p>
<p>USER_COL_PRIVS_MADE           USER_COL_PRIVS_RECD</p>
<p><strong> </strong></p>
<p><strong>Database Links</strong></p>
<p>CREATE [PUBLIC] DATABASE LINK link_name</p>
<p>[CONNECT TO user_name IDENTIFIED BY password]</p>
<p>USING connection_string;</p>
<p><strong> </strong></p>
<p><strong>Single-Row Functions</strong></p>
<p><strong>Character Functions</strong></p>
<p>LOWER(column|expression)</p>
<p>UPPER(column|expression)</p>
<p>INITCAP(column|expression)</p>
<p>INSTR(column|expression,m)</p>
<p>CONCAT(column1|expression1,column2|expression2}</p>
<p>SUBSTR(column|expression,m,[n])</p>
<p>LENGTH(column|expression)</p>
<p>LPAD(column|expression,n,&#8217;string&#8217;)</p>
<p>RPAD(column|expression,n,&#8217;string&#8217;)</p>
<p>TRIM(&#8216;character&#8217; FROM column|expression)</p>
<p>REPLACE(&#8216;string1&#8242;, &#8216;string_to_replace&#8217;,[replacement_string])</p>
<p><strong> </strong></p>
<p><strong>Number Functions</strong></p>
<p>MOD(m,n)</p>
<p>ROUND(column|expression,n)</p>
<p>TRUNC(column|expression,n)</p>
<p><strong> </strong></p>
<p><strong>Date Functions</strong></p>
<p>MONTHS_BETWEEN(date1,date2)</p>
<p>ADD_MONTHS(date,n)</p>
<p>NEXT_DAY(date,&#8217;char&#8217;)</p>
<p>LAST_DAY(date)</p>
<p>ROUND(date[,'fmt'])</p>
<p>TRUNC(date[,'fmt'])</p>
<p><em>Arithmetic with Dates</em></p>
<ul type="disc">
<li>Add or subtract a number to or from a date for a resultant date value</li>
<li>Subtract two dates to find the number of days between those dates</li>
<li>Add hours to a date by dividing the number of hours by 24</li>
</ul>
<p><strong> </strong></p>
<p><strong>Conversion Functions</strong></p>
<p>TO_CHAR(number|date[,'fmt'])</p>
<p>TO_NUMBER(char[,'fmt'])</p>
<p>TO_DATE(char[,'fmt'])</p>
<p>NVL(expr1,expr2)</p>
<p>NVL2(expr1,expr2,expr3)</p>
<p>NULLIF(expr1,expr2)</p>
<p>COALESCE(expr1,expr2,&#8230;,exprn)</p>
<p><strong>Conditional Expressions: </strong>Provide the use of IF-THEN-ELSE logic within a SQL statement.</p>
<p>DECODE(col|expr,search1,result1</p>
<p>[,search2,result2,...,]</p>
<p>[,default])</p>
<p>CASE expr WHEN comparision_expr1 THEN return_expr1</p>
<p>[WHEN comparision_expr2 THEN return_expr2</p>
<p>WHEN comparision_exprn THEN return_exprn</p>
<p>ELSE else_expr]</p>
<p>END</p>
<p><em>Nesting Functions</em></p>
<ul>
<li>Single-row functions can be nested to any level</li>
<li>Nested functions are evaluated from deepest level to the least deep level</li>
<li>In below example, functions F1, F2 and then F3 gets executed</li>
</ul>
<p>F3(F2(F1(col,arg1),arg2),arg3)</p>
<p><strong>Operators</strong></p>
<p>Arithmetic        *     /     +     -</p>
<p>Comparison        =     &gt;     &gt;=    &lt;     &lt;=    &lt;&gt; or ^= or ~= or !=</p>
<p>BETWEEN&#8230;AND&#8230;, IN(set), LIKE, IS NULL</p>
<p>Concatenation     ||</p>
<p>Logical           AND   OR    NOT</p>
<p><strong>Rules of Precedence</strong></p>
<p>Order Evaluated         Operator</p>
<ul>
<li>1 Arithmetic operators &#8211; multiplication and division(* /)</li>
<li>2 Arithmetic operators &#8211; Addition, subtraction and Concatenation operator ( + &#8211; || )</li>
<li>3 Comparison conditions</li>
<li>4 IS [NOT] NULL, LIKE, [NOT] IN</li>
<li>5 [NOT] BETWEEN</li>
<li>6 NOT logical condition; ** Exponentiation</li>
<li>7 AND logical condition</li>
<li>8 OR logical condition</li>
</ul>
<p><strong>Notes</strong></p>
<ul>
<li>1) Use <strong>ESCAPE</strong> identifier to search for the actual % and _ symbols (Here, % denotes zero or many characters and _ denotes one character in search condition )</li>
</ul>
<p>Example: Get employee list having underscore (_) in last_name string</p>
<p>SELECT last_name</p>
<p>FROM EMPLOYEE</p>
<p>WHERE last_name LIKE &#8216;%\_%&#8217; ESCAPE &#8216;\&#8217;;</p>
<ul>
<li>2) <strong>DUAL</strong> is a dummy table you can use to view results from functions and calculations</li>
<li>3) <strong>SYSDATE</strong> is a function that returns: Date and Time</li>
<li>4) Inline view is a subquery with an alias that you can use within a SQL statement. A named subquery in the FROM clause of the main query is an example of an inline view. It is not a schema object.</li>
</ul>
<left><a class="tt" href="http://twitter.com/home/?status=Oracle+SQL+Quick+reference+http://bit.ly/c3ekkW" title="Post to Twitter"><img class="nothumb" src="http://www.oratraining.com/blog/wp-content/plugins/tweet-this/icons/tt-twitter-big3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.oratraining.com/blog/2009/06/sq-quick-referenence/&amp;title=Oracle+SQL+Quick+reference" title="Post to Digg"><img class="nothumb" src="http://www.oratraining.com/blog/wp-content/plugins/tweet-this/icons/tt-digg-big4.png" alt="Post to Digg" /></a></left><div class="fblike" style="height:25px; height:25px; overflow:hidden;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.oratraining.com%2Fblog%2F2009%2F06%2Fsq-quick-referenence%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allow Transparency="true" style="border:none; overflow:hidden; width:450px;"></iframe></div><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.oratraining.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.oratraining.com/blog/2009/06/sq-quick-referenence/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Oracle SQL tuning tips</title>
		<link>http://www.oratraining.com/blog/2009/06/oracle-sql-tuning-tips/</link>
		<comments>http://www.oratraining.com/blog/2009/06/oracle-sql-tuning-tips/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 05:21:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Database Performance Tuning]]></category>
		<category><![CDATA[Database programming]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle DBA]]></category>
		<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Oracle PL/SQL]]></category>
		<category><![CDATA[Oracle developers]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[performance tuning]]></category>
		<category><![CDATA[pl/sql]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL tuning]]></category>
		<category><![CDATA[sqlplus]]></category>
		<category><![CDATA[syntax]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tuning]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.oratraining.com/blog/?p=176</guid>
		<description><![CDATA[Oracle SQL Tuning Tips consideration when writing an SQL statement is that it returns a correct result. The second is that it be the most efficient for a given situation.  You can use many different SQL statements to achieve the same result. It is often the case that only one statement will be the most [...]]]></description>
			<content:encoded><![CDATA[<h2>Oracle SQL Tuning Tips</h2>
<p>consideration when writing an SQL statement is that it returns a correct result. The second is that it be the most efficient for a given situation.  You can use many different SQL statements to achieve the same result. It is often the case that only one statement will be the most efficient choice in a given situation.</p>
<p>Remember that processing SQL is a sequence of Parse (syntax check and object resolution), Execution (required reads and writes), and Fetch (row results retrieved, listed, sorted, and returned). SQL &#8220;tuning&#8221; consists, quite simply, of reducing one or more of them.</p>
<p>Note: generally Parse is the greatest time and resource hog. Parse overhead can be minimized by the use of Procedures, Functions, Packages, Views, etc.</p>
<p>Inadequate performance can have a significant cost impact on your business. A poor performing system and application can result in customer dissatisfaction, reduced productivity, and high costs. It is absolutely critical that the system&#8217;s performance is operating at its peak levels.</p>
<p>Following are some general tips that often increase SQL statement efficiency. Being general they may not apply to a particular scenario.<span id="more-176"></span></p>
<ul>
<li>Tuning SQL should only be done after your code is working correctly. Be aware that there is an inevitable tug-of-war between writing efficient SQL and understandable SQL.</li>
<li>Ensure repeated SQL statements are written<em>absolutely identically</em>to facilitate efficient reuse: re-parsing can often be avoided for each subsequent use of an identical statement.<br />
Writing best practices: all SQL verbs in upper-case i.e. SELECT; separate all words with a single space; all SQL verbs begin on a new line; SQL verbs aligned right or left within the initial verb; set and maintain a table alias standard; use table aliases and when a query involves more than one table prefix all column names with their aliases. Whatever you do, be consistent.</li>
<li>o Use bind variables: The values of bind variables do not need to be the same for two statements to be considered identical. Bind variables are not substituted until a statement has been successfully parsed.</li>
<li>o Use standard approach to table aliases. If two identical SQL statements vary because an identical table has two different aliases, then the SQL is different and will not be re-use or shared.</li>
<li>o Use table aliases and prefix all column names by their aliases when more than one table is involved in a query. This reduces parse time and prevents future syntax errors if someone adds a column to one of the tables with same name as a column in another table. (ORA-00918: COLUMN AMBIGUOUSLY DEFINED)</li>
<li>Code the query as simply as possible i.e. no unnecessary columns are selected, no unnecessary GROUP BY or ORDER BY.<br />
It is the same or faster to SELECT by actual column name(s). The larger the table the more likely the savings.<br />
<em>Use:</em><br />
<em>SELECT customer_id, last_name, first_name, street, city FROM customer;<br />
Rather than, </em><em><br />
SELECT * FROM customer;</em></li>
<li>Beware of WHERE clauses which do not use indexes at all. Even if there is an index over a column that is referenced by a WHERE clause included in this section, Oracle will ignore the index. All these WHERE clause can be re-written to use an index while returning the same values. In other words, Do not perform operations on database objects referenced in the WHERE clause:<br />
<em>Use:<br />
</em><em>SELECT client, date, amount FROM sales WHERE amount <strong>&gt; 0;</strong></em><em><br />
Rather than:<br />
</em><em>SELECT client, date, amount FROM sales WHERE amount <strong>!= 0;<br />
</strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Use:<br />
SELECT account_name, trans_date, amount FROM transaction WHERE account_name <strong>LIKE &#8216;CAPITAL%&#8217;;</strong><br />
</em><em>Rather than:</em><em><br />
SELECT account_name, trans_date, amount FROM transaction WHERE <strong>SUBSTR(account_name,1,7)=</strong>&#8216;CAPITAL&#8217;;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Use:<br />
SELECT account_name, trans_date, amount FROM transaction WHERE amount <strong>&gt; 0;<br />
</strong></em><em>Rather than:<br />
</em><em>SELECT account_name, trans_date, amount FROM transaction WHERE amount <strong>NOT=0;<br />
</strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<strong><br />
</strong>Use:<br />
SELECT account_name, trans_date, amount FROM transaction WHERE<strong> amount &lt; 2000;<br />
</strong>Rather than:<br />
SELECT account_name, trans_date, amount FROM transaction WHERE <strong>amount + 3000 </strong>&lt; 5000;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Use:<br />
SELECT account_name, trans_date, amount FROM transaction WHERE <strong>account_name = &#8216;AMEX&#8217; AND account_type = &#8216;A&#8217;;<br />
</strong>Rather than:<br />
SELECT account_name, trans_date, amount FROM transaction WHERE <strong>account_name|| account_type=</strong>&#8216;AMEXA&#8217;; </em></li>
<li>Don&#8217;t forget to tune views. Views are SELECT statements and can be tuned in just the same way as any other type of SLECT statement can be. All tuning applicable to any SQL statement are equally applicable to views.</li>
<li>Avoid including a HAVING clause in SELECT statements. The HAVING clause filters selected rows only after all rows have been fetched. Using a WHERE clause helps reduce overheads in sorting, summing, etc. HAVING clauses should only be used when columns with summary operations applied to them are restricted by the clause.<br />
<em>Use:</em><br />
<em>SELECT city FROM country <strong>WHERE</strong> city!= &#8216;Vancouver&#8217; AND city!= &#8216;Toronto&#8217;; GROUP BY city;</em><em><br />
Rather than:<br />
</em><em>SELECT city FROM country GROUP BY city <strong>HAVING</strong> city!= &#8216;Vancouver&#8217; AND city!= &#8216;Toronto&#8217;;</em></li>
<li>Minimize the number of table lookups (subquery blocks) in queries, particularly if our statements include subquery SELECTs or multicolumn UPDATEs.<br />
<em>Use:<br />
SELECT emp_name FROM emp WHERE <strong>(emp_cat, sal_range</strong>) = (<strong>SELECT</strong> MAX(category), MAX(sal_range) FROM emp_categories) AND emp_dept = 0020;<br />
Rather than:<br />
SELECT emp_name FROM emp WHERE <strong>emp_cat</strong>=(<strong>SELECT</strong> MAX(category) FROM emp_categories) AND <strong>emp_range</strong> = (<strong>SELECT</strong> MAX(sal_range) FROM emp_categories) AND emp_dept = 0020;</em></li>
<li>When writing a sub-query (a SELECT statement within the WHERE or HAVING clause of another SQL statement):</li>
<li>o Use a correlated (refers to at least one value from the outer query) sub-query when the return is relatively small and/or other criteria are efficient i.e. if the tables within the sub-query have efficient indexes.</li>
<li>o Use a non-correlated (does not refer to the outer query) sub-query when dealing with large tables from which you expect a large return (many rows) and/or if the tables within the sub-query do not have efficient indexes.</li>
<li>o Ensure that multiple sub-queries are in the most efficient order.</li>
<li>o Remember that rewriting a sub-query as a join can sometimes increase efficiency.</li>
<li>When doing multiple table joins consider the benefits/costs for each of EXISTS, IN, and table joins. Depending on your data one or another may be faster.<br />
Note: IN is usually the slowest.<br />
Note: When most of the filter criteria are in the sub-query IN may be more efficient; when most of the filter criteria are in the parent-query EXISTS may be more efficient.<em><br />
The following queries return the employee names from each department in department category &#8216;A&#8217;:</em><br />
<em>SELECT emp_name FROM emp E WHERE <strong>EXISTS </strong>(SELECT &#8216;X&#8217; FROM dept WHERE dept_no = E.dept_no AND dept_cat = &#8216;A&#8217;);</em><br />
<em>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</em><em><br />
SELECT emp_name FROM emp E WHERE dept_no <strong>IN </strong>(SELECT dept_no FROM dept WHERE dept_no = E.dept_no AND dept_Cat = &#8216;A&#8217;);<br />
</em><em>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</em><em><br />
SELECT emp_name FROM dept D, emp E WHERE E.dept_no = D.dept_no AND D.dept_cat = &#8216;A&#8217;;</em></li>
<li>Where possible use EXISTS rather than DISTINCT, to avoid full table scan as DISTINCT operator causes Oracle to fetch all rows satisfying the table join and then sort and filter out duplicate values. EXISTS is a faster alternative, because the Oracle optimizer realizes when the subquery has been satisfied once, there is no need to proceed further and the next matching row can be fetched.<br />
<em>Use:<br />
SELECT S.id, S.description FROM small_table S WHERE <strong>EXISTS </strong>(SELECT NULL FROM big_table B WHERE B.id = S.id);<br />
Rather than:<br />
SELECT <strong>DISTINCT S.id, S.description</strong> FROM small_table S, big_table B<br />
WHERE S.id = B.id;</em></li>
<li>Where possible use a non-column expression (putting the column on one side of the operator and all the other values on the other). Non-column expressions are often processed earlier thereby speeding the query.<br />
<em>Use:<br />
</em><em>WHERE SALES &lt; 1000/(1 + n);</em><em><br />
Rather than:<br />
</em><em>WHERE SALES + (n * SALES) &lt; 1000;</em></li>
<li>Where possible use UNION ALL rather than using UNION. The UNION clause forces all rows retuned by each portion of the UNION to be sorted and merged and duplicates to be filtered out before the first row is returned. A UNION ALL simply returns all rows including duplicates and does not have to perform any sort, merge or filter. If your tables are mutually exclusive(include no duplicate records), or you don&#8217;t care if duplicates are returned, the UNION ALL is much more efficient.<br />
<em>USE:</em><br />
<em>SELECT acct_num, balance_amt FROM debit_transactions WHERE tran_date = &#8217;31-DEC-95&#8242;<br />
<strong>UNION ALL</strong><br />
SELECT acct_num, balance_amt FROM credit_transactions WHERE tran_date = &#8217;31-DE -95&#8242;;<br />
Rather than:<br />
SELECT acct_num, balance_amt FROM debit_transactions WHERE tran_date = &#8217;31-DEC-95&#8242;<br />
<strong>UNION</strong><br />
SELECT acct_num, balance_amt FROM credit_transactions WHERE tran_date = &#8217;31-DE -95&#8242;;</em></li>
<li>Consider using DECODE to avoid having to scan the same rows repetitively or join the same table repetitively. Note, DECODE is not necessarily faster as it depends on your data and the complexity of the resulting query. Also, using DECODE requires you t change your code when new values are allowed in the field.<br />
<em>USE:<br />
SELECT COUNT(<strong>DECODE</strong>(status,&#8217;Y',&#8217;X',NULL)) Y_count,<br />
COUNT(<strong>DECODE</strong>(status,&#8217;N',&#8217;X',NULL)) N_count<br />
FROM emp WHERE emp_name LIKE &#8216;SMITH%&#8217;;<br />
Raher than:<br />
SELECT COUNT(*) FROM emp WHERE status = &#8216;Y&#8217; AND emp_name LIKE &#8216;SMITH%&#8217;;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
SELECT COUNT(*) FROM emp WHERE status = &#8216;N&#8217; AND emp_name LIKE &#8216;SMITH%&#8217;;</em></li>
<li>Oracle automatically performs simple column type conversions(or casting) when it compares columns of different types. Depending on the type of conversion, indexes may not be used. Make sure you declare your program variables as the same type as your Oracle columns, if the type is supported in the programming language you are using.<br />
<em>Use:<br />
SELECT emp_no, emp_name, sal FROM emp WHERE emp_no = &#8217;123&#8242;;<br />
HERE if emp_no indexed numeric, then after implicit conversion query will be:<br />
SELECT emp_no, emp_name, sal FROM emp WHERE emp_no = <strong>TO_NUMBER</strong>(&#8217;123&#8242;); </em><br />
<em>Thus, index is used in this case.<br />
Don&#8217;t use:<br />
SELECT emp_no, emp_name, sal FROM emp WHERE emp_type = 123;<br />
HERE if emp_type is indexed varchar2, then after implicit conversion query will be:</em><br />
<em>SELECT emp_no, emp_name, sal FROM emp WHERE TO_NUMBER(emp_type) = 123;</em><br />
<em>Thus, index will not be used in this case.</em></li>
<li>The most efficient method for storing large binary objects, i.e. multimedia objects, is to place them in the file system and place a pointer in the DB.</li>
<li>B-Tree Indexes do not store entries for NULL, so IS NULL is not indexable, but IS NOT NULL is indexable and thus if a huge table contains very few not null values then you should go for B-Tree indexes. On the other hand bitmap indexes support IS NULL condition.<br />
<em>SELECT * FROM big WHERE status IS NOT NULL; (Use B-tree index in this case)</em></li>
<li>Avoid using functions on indexed columns unless a function-based index is created; as it leads to full table scan even though index exists on the column.</li>
</ul>
<p><strong>Avoid using the following:</strong></p>
<ul type="disc">
<li>Boolean operators &gt;, &lt;, &gt;=, &lt;=, IS NULL, IS NOT NULL</li>
<li>NOT IN, !=</li>
<li>Like &#8216;%pattern&#8217;, not exists</li>
<li>Calculations on unindexed columns or (use union instead)</li>
<li>Having (use a WHERE clause instead when appropriate)</li>
</ul>
<p><strong> </strong><strong>Do use the following:</strong></p>
<ul type="disc">
<li>Enable aliases to prefix all columns</li>
<li>Place indexed columns higher in the WHERE clause</li>
<li>Use SQL Joins instead of using sub-queries</li>
<li>Make the table with the least number of rows, the driving table, by making it first in the FROM clause</li>
</ul>
<p><strong>Other important points for SQL Tuning</strong></p>
<ul type="disc">
<li>Establish a tuning environment that reflects your production database</li>
<li>Establish performance expectations before you begin</li>
<li>Always Design and develop with performance in mind</li>
<li>Create Indexes to support selective WHERE clauses and join conditions</li>
<li>Use concatenated indexes where appropriate</li>
<li>Consider indexing more than you think you should, to avoid table lookups</li>
<li>Pick the best join method</li>
<li>Nested loops joins are best for indexed joins of subsets</li>
<li>Hash joins are usually the best choice for &#8220;big&#8221; joins</li>
<li>Pick the best join order</li>
<li>Pick the best &#8220;driving&#8221; table</li>
<li>Eliminate rows as early as possible in the join order</li>
<li>Use bind variables. Bind variables are key to application scalability</li>
<li>Use Oracle hints where appropriate</li>
<li>Compare performance between alternative syntax for your SQL statement</li>
<li>Consider utilizing PL/SQL to overcome difficult SQL tuning issues</li>
<li>Consider using third party tools to make the job of SQL tuning easier</li>
</ul>
<p>Performing these steps is easy and provides a tremendous benefit and performance boost. Follow these simple steps and you can increase your system performance.</p>
<left><a class="tt" href="http://twitter.com/home/?status=Oracle+SQL+tuning+tips+http://bit.ly/akjQLL" title="Post to Twitter"><img class="nothumb" src="http://www.oratraining.com/blog/wp-content/plugins/tweet-this/icons/tt-twitter-big3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.oratraining.com/blog/2009/06/oracle-sql-tuning-tips/&amp;title=Oracle+SQL+tuning+tips" title="Post to Digg"><img class="nothumb" src="http://www.oratraining.com/blog/wp-content/plugins/tweet-this/icons/tt-digg-big4.png" alt="Post to Digg" /></a></left><div class="fblike" style="height:25px; height:25px; overflow:hidden;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.oratraining.com%2Fblog%2F2009%2F06%2Foracle-sql-tuning-tips%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allow Transparency="true" style="border:none; overflow:hidden; width:450px;"></iframe></div><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.oratraining.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.oratraining.com/blog/2009/06/oracle-sql-tuning-tips/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SQL*Plus Basic commands</title>
		<link>http://www.oratraining.com/blog/2009/06/sqlplus-basic-commands/</link>
		<comments>http://www.oratraining.com/blog/2009/06/sqlplus-basic-commands/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 05:18:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Database programming]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle DBA]]></category>
		<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Oracle PL/SQL]]></category>
		<category><![CDATA[Oracle developers]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[pl/sql]]></category>
		<category><![CDATA[quick reference]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[sqlplus]]></category>
		<category><![CDATA[syntax]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.oratraining.com/blog/?p=174</guid>
		<description><![CDATA[Using SQL*Plus SQL*Plus is a command-line tool that provides access to the Oracle RDBMS. SQL*Plus enables you to: Enter SQL*Plus commands to configure the SQL*Plus environment Startup and shutdown an Oracle database Connect to an Oracle database Enter and execute SQL commands and PL/SQL blocks Format and print query results SQL*Plus is available on several [...]]]></description>
			<content:encoded><![CDATA[<h2>Using SQL*Plus</h2>
<p>SQL*Plus is a command-line tool that provides access to the Oracle RDBMS.</p>
<p>SQL*Plus enables you to:</p>
<ul type="disc">
<li>Enter SQL*Plus commands to configure the SQL*Plus environment</li>
<li>Startup and shutdown an Oracle database</li>
<li>Connect to an Oracle database</li>
<li>Enter and execute SQL commands and PL/SQL blocks</li>
<li>Format and print query results</li>
</ul>
<p>SQL*Plus is available on several platforms. In addition, it has a web-based user</p>
<p>interface, <em>i</em>SQL*Plus.</p>
<p>SQL*Plus is a client terminal software allowing users to interact with Oracle server to manipulate data and data structures. Users type in SQL statements in SQL*Plus that send statements to Oracle server. Oracle server then validates and executes the statements on its databases. The query results are returned to SQL*Plus and displayed to the user.  Besides sending SQL statements to the server, SQL*Plus also saves them into a local buffer and allow users to view and change the statements. The following figure illustrates the process.<span id="more-174"></span></p>
<p>After you login into SQL*Plus, at the SQL prompt, you can begin typing any SQL command. Upon hitting return (i.e., enter key) the SQL prompt will change to line number prompts. When you are finished typing a command, type / or RUN to execute the SQL command. Also, a semicolon at the end of the SQL command will execute the command immediately after hitting return. In addition to SQL commands, /, and RUN, you can also executes SQL*Plus file commands.</p>
<p><strong>SQL*PLUS Commands Quick Reference</strong></p>
<p>Below table shows, SQL*Plus commands available in the command-line interface. Not all commands or command parameters are shown.</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="175" valign="top"><strong>How to &#8230;</strong></td>
<td width="415" valign="top"><strong>SQL*Plus Command</strong></td>
</tr>
<tr>
<td width="175" valign="top">Log in to SQL*Plus</td>
<td width="415" valign="top">SQLPLUS [ { username[/passward][@connect_identifier] | / }  [ AS { SYSDBA | SYSOPER } ] | /NOLOG ]</td>
</tr>
<tr>
<td width="175" valign="top">List help topics available in SQL*Plus</td>
<td width="415" valign="top">HELP [ INDEX | topic ]</td>
</tr>
<tr>
<td width="175" valign="top">Execute host commands</td>
<td width="415" valign="top">HOST [ command ]</td>
</tr>
<tr>
<td width="175" valign="top">Show SQL*Plus system variables or environment settings</td>
<td width="415" valign="top">SHOW { ALL | ERRORS | USER | system_variable | &#8230; }</td>
</tr>
<tr>
<td width="175" valign="top">Alter SQL*Plus system variables or environment settings</td>
<td width="415" valign="top">SET system_variable value</td>
</tr>
<tr>
<td width="175" valign="top">Start up a database</td>
<td width="415" valign="top">STARTUP PFILE = filename  [ MOUNT [ dbname ] | NOMOUNT | &#8230; ]</td>
</tr>
<tr>
<td width="175" valign="top">Connect to a database</td>
<td width="415" valign="top">CONNECT [ [ username [ /password ] [ @connect_identifier ]          [ / AS { SYSOPER | SYSDBA } ]</p>
<p>]</td>
</tr>
<tr>
<td width="175" valign="top">List column definitions for a table, view, or synonym, or specifications for afunction or procedure</td>
<td width="415" valign="top">DESCRIBE [ schema. ] object</td>
</tr>
<tr>
<td width="175" valign="top">Edit contents of the SQL buffer or a file</td>
<td width="415" valign="top">EDIT [ filename [ .ext ] ]</td>
</tr>
<tr>
<td width="175" valign="top">Get a file and load its contents into the SQLBuffer</td>
<td width="415" valign="top">GET filename [ .ext ] [ LIST | NOLLIST ]</td>
</tr>
<tr>
<td width="175" valign="top">Save contents of the SQL buffer to a file</td>
<td width="415" valign="top">SAVE filename [ .ext ] [ CREATE | REPLACE | APPEND ]</td>
</tr>
<tr>
<td width="175" valign="top">List contents of the SQL Buffer</td>
<td width="415" valign="top">LIST [ n | nm | n LAST | ... ]</td>
</tr>
<tr>
<td width="175" valign="top">Delete contents of the SQL Buffer</td>
<td width="415" valign="top">DEL [ n | nm | n LAST | ... ]</td>
</tr>
<tr>
<td width="175" valign="top">Add new lines following current line in the SQL buffer</td>
<td width="415" valign="top">INPUT [ text ]</td>
</tr>
<tr>
<td width="175" valign="top">Append text to end ofcurrent line in the SQL</p>
<p>buffer</td>
<td width="415" valign="top">APPEND text</td>
</tr>
<tr>
<td width="175" valign="top">Find and replace first occurrence of a text string in current line of the SQL buffer</td>
<td width="415" valign="top">CHANGE sepchar old [ sepchar [ new [ sepchar ] ] ]sepchar can be any non-alphanumeric character such as &#8220;/&#8221; or &#8220;!&#8221;</td>
</tr>
<tr>
<td width="175" valign="top">Capture query results in a file and, optionally, send contents of file to default printer</td>
<td width="415" valign="top">SPOOL [ filename [ .ext ]  [ CREATE | REPLACE | APPEND | OFF | OUT ]</td>
</tr>
<tr>
<td width="175" valign="top">Run SQL*Plus statements stored in a file</td>
<td width="415" valign="top">@ { url | filename [ .ext ] } [ arg... ]START filename [ .ext ] [ arg... ]</p>
<p>.ext can be omitted if the filename extension is .sql</td>
</tr>
<tr>
<td width="175" valign="top">Execute commands stored in the SQL buffer</td>
<td width="415" valign="top">/</td>
</tr>
<tr>
<td width="175" valign="top">List and execute commands stored in the SQL buffer</td>
<td width="415" valign="top">RUN</td>
</tr>
<tr>
<td width="175" valign="top">Execute a single PL/SQL statement or run a stored procedure</td>
<td width="415" valign="top">EXECUTE statement</td>
</tr>
<tr>
<td width="175" valign="top">Disconnect from a database</td>
<td width="415" valign="top">DISCONNECT</td>
</tr>
<tr>
<td width="175" valign="top">Shut down a database</td>
<td width="415" valign="top">SHUTDOWN [ ABORT | IMMEDIATE | NORMAL | ... ]</td>
</tr>
<tr>
<td width="175" valign="top">Log out of SQL*Plus</td>
<td width="415" valign="top">{ EXIT | QUIT }  [ SUCCESS | FAILURE | WARNING | ... ]</p>
<p>[ COMMIT | ROLLBACK ]</td>
</tr>
</tbody>
</table>
<p><a name="SQL*Plus_file_commands"></a></p>
<p>SQL*Plus file command allow you to execute commands (or programs) stored in an external file, input or output data from/to a file, and save SQL commands typed during current session.</p>
<p>Some SQL*Plus file commands are:</p>
<ul type="disc">
<li>SAVE filename. This allows you to save buffer contents into a file.</li>
<li>START filename. This allows you to execute a batch of SQL statements stored in a file.</li>
<li>SPOOL filename. This allows you save SQL statements together with their outputs to a file.</li>
<li> GET filename. This retrieve a file and places it into the buffer.</li>
<li>@ filename. This allows you to execute a PL/SQL procedure(s) stored in a file.</li>
</ul>
<h2><a name="SQL*Plus_edit_commands"></a></h2>
<p>Recall that the previously executed commands (in current SQL*Plus session) are stored in the local buffer. One way to change an SQL statement in the buffer is by using the<em> <strong>line editor</strong></em>. The following are a list of line edit commands.</p>
<ul type="disc">
<li>LIST or L&#8211;Lists the contents of the buffer</li>
<li>LIST n or L n&#8211;Lists the contents of line number n in the buffer and makes the line current</li>
<li>LIST * or L *&#8211;Lists the current line</li>
<li>LIST m n&#8211;Lists the range from m to n line</li>
<li>Append text or A text&#8211;Adds to the end of the current line (e.g., &#8220;A ,&#8221; adds a comma to the end of line</li>
<li>INPUT or I&#8211;Adds one or more lines after the current line so you can begin adding the text.</li>
<li>CHANGE /text&#8211;Deletes text from the current line</li>
<li>CHANGE /oldtext/newtext&#8211;Replaces oldtext with newtext in the current line</li>
<li>DEL &#8212; Deletes the current line</li>
</ul>
<p>Besides line editor, you can also use the <em>vi editor</em> if you are a fan of Unix editor!.</p>
<p>To invoke the vi editor, type Edit at the SQL Prompt.   Multiple SQL commands can be typed in vi editor. End each SQL command (except the last one) with a semicolon. After exiting notepad, type Start to run all of the commands.</p>
<h2><a name="run_batch_sql"></a>Run SQL statements in a batch</h2>
<p>To run SQL commands in a batch, you can put all your SQL commands into a text file and execute these commands in this file in SQL*PLUS.</p>
<ul type="disc">
<li>Use your favorite editor to type in your SQL queries into a text file.</li>
</ul>
<p>For Example,</p>
<p>$ more table.sql<br />
DROP TABLE employee<br />
/</p>
<p>commit<br />
/</p>
<p>CREATE TABLE employee (<br />
empno INTEGER NOT NULL,<br />
name VARCHAR2(50) NOT NULL,<br />
sal REAL NOT NULL,<br />
primary key (empno));<br />
/</p>
<p>INSERT INTO employee VALUES (1, &#8216;Jack&#8217;, 6000);<br />
INSERT INTO employee VALUES (2, &#8216;Tom&#8217;,  6000);<br />
INSERT INTO employee VALUES (3, &#8216;John&#8217;, 6000);<br />
INSERT INTO employee VALUES (4, &#8216;Jane&#8217;, 6000);<br />
/</p>
<p>UPDATE employee SET sal=500 WHERE name=&#8217;Jack&#8217;<br />
/</p>
<p>CREATE INDEX test_index on employee(sal)<br />
/<br />
$</p>
<ul type="disc">
<li>Connect into SQL*Plus, and run the batch of commands. For example, assume that you name the SQL file as <em>table.sql</em>.</li>
</ul>
<p><tt>SQL&gt; START table.sql</tt>;</p>
<h2><a name="output_to_file"></a>Output results <a name="Output"></a></h2>
<ul type="disc">
<li>You can record your SQL command outputs to a file for output or editing purpose.</li>
</ul>
<p>SQL&gt; <tt>SPOOL </tt>&lt;your file name&gt;</p>
<p>For example,</p>
<p><tt>SQL&gt; SPOOL myoutput.out</tt></p>
<p>All SQL commands and their outputs after this command are written into the file <tt>myoutput.out </tt>that by default is stored in the current working directory where you invoked SQL*Plus.</p>
<ul type="disc">
<li>To end recording, use the following command: <tt> </tt></li>
</ul>
<p><tt>SQL&gt; SPOOL OFF</tt></p>
<h2><a name="dual"></a>DUAL and select the current time</h2>
<p>DUAL is the dummy table, mostly used to view the results from functions and calculations. The built-in function <tt>SYSDATE</tt> returns a <tt>DATE</tt> value containing the current date and time on your system. (Note Oracle is a client-server architecture and SQL*Plus is the client. SYSDATE gives you the time of the Unix system which you telnet in. It may NOT be the time of Oracle server unless you telnet into the machine running Oracle server.)</p>
<p>For example,</p>
<pre>SQL&gt; SELECT TO_CHAR(<tt>SYSDATE</tt> , 'Dy DD-Mon-YYYY HH24:MI:SS') as "Current Date/Time" FROM DUAL;;</pre>
<p>Result:</p>
<pre>Current Time</pre>
<pre>------------------------------------------------------------------------</pre>
<pre>Mon 15-July-2002 10:01:29</pre>
<ul type="disc">
<li>TO_CHAR is a function to format a value.</li>
<li><tt>DUAL</tt> is built-in relation in Oracle which serves as a dummy relation to put in the <tt>FROM</tt> clause when nothing else is appropriate. For example, try &#8220;SELECT 2+2 FROM DUAL;&#8221;</li>
<li>To format a number attribute to a dollar format, use the <em>column &lt;attribute&gt; format &lt;format&gt;</em>:</li>
</ul>
<pre>       SQL&gt; COLUMN salary FORMAT $999,999</pre>
<ul type="disc">
<li>To indicate the displayed width of a character string attribute, use the <em>column &lt;attribute&gt; format &lt;A&#8217;format&gt;</em>. For example, set the width of the name attribute to 8 characters.</li>
</ul>
<pre>       SQL&gt; COLUMN name FORMAT A8</pre>
<p>If a name is longer than 8 characters, the remaining is displayed at the second line (or several lines)</p>
<ul type="disc">
<li>The <em>set</em> command can be used to change the default number of lines per page (14) and the number of characters per line (80).</li>
</ul>
<p>For example, to set the number of lines per page to 60, use the following command:</p>
<pre>   SQL&gt; SET PAGESIZE 60</pre>
<ul type="disc">
<li>All formatting remain active until they are cleared or reset or after you exit from SQL*Plus.</li>
</ul>
<pre>   SQL&gt; CLEAR COLUMN</pre>
<ul type="disc">
<li>If you forget a specific SQL command you could enter</li>
</ul>
<p><tt> SQL&gt; HELP &lt;the SQL command&gt;;</tt></p>
<p>You could also find out all commands by entering:</p>
<p><tt> SQL&gt; HELP menu;</tt></p>
<ul type="disc">
<li>Sometimes when you get something fuzzy, you  can try the following</li>
</ul>
<p>SQL&gt; SET SERVEROUTPUT ON<br />
SQL&gt; SET ARRAYSIZE 1</p>
<left><a class="tt" href="http://twitter.com/home/?status=SQL%2APlus+Basic+commands+http://bit.ly/cwPssQ" title="Post to Twitter"><img class="nothumb" src="http://www.oratraining.com/blog/wp-content/plugins/tweet-this/icons/tt-twitter-big3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.oratraining.com/blog/2009/06/sqlplus-basic-commands/&amp;title=SQL%2APlus+Basic+commands" title="Post to Digg"><img class="nothumb" src="http://www.oratraining.com/blog/wp-content/plugins/tweet-this/icons/tt-digg-big4.png" alt="Post to Digg" /></a></left><div class="fblike" style="height:25px; height:25px; overflow:hidden;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.oratraining.com%2Fblog%2F2009%2F06%2Fsqlplus-basic-commands%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allow Transparency="true" style="border:none; overflow:hidden; width:450px;"></iframe></div><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.oratraining.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.oratraining.com/blog/2009/06/sqlplus-basic-commands/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Oracle Export and Import utility tutorial</title>
		<link>http://www.oratraining.com/blog/2009/06/oracle-export-import-utility-exp-imp-tutorial/</link>
		<comments>http://www.oratraining.com/blog/2009/06/oracle-export-import-utility-exp-imp-tutorial/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 12:57:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Database Performance Tuning]]></category>
		<category><![CDATA[Database programming]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle DBA]]></category>
		<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Oracle developers]]></category>
		<category><![CDATA[exp]]></category>
		<category><![CDATA[export]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[imp]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[syntax]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://www.oratraining.com/blog/?p=169</guid>
		<description><![CDATA[Oracle Data Export and Import utility The Import and Export utilities work together; Export sends database definitions and actual data to an export file and Import can read the file to perform many different tasks. You can use Export and Import for many important database tasks, such as restoring a table, generating CREATE scripts, copying [...]]]></description>
			<content:encoded><![CDATA[<h2>Oracle Data Export and Import utility</h2>
<p>The Import and Export utilities work together; Export sends database definitions and actual data to an export file and Import can read the file to perform many different tasks. You can use Export and Import for many important database tasks, such as restoring a table, generating CREATE scripts, copying data among Oracle databases, migrating among Oracle versions, and moving tables from one schema to another.</p>
<p>Oracle&#8217;s export (exp) and import (imp) utilities are used to perform logical database backup and recovery. When exporting, database objects are dumped to a binary file which can then be imported into another Oracle database.</p>
<p>These utilities can be used to move data between different machines, databases or schema. However, as they use a proprietary binary file format, they can only be used between Oracle databases. One cannot export data and expect to import it into a non-Oracle database.</p>
<p>Various parameters are available to control what objects are exported or imported. To get a list of available parameters, run the <em>exp</em> or <em>imp</em> utilities with the <em>help=yes</em> parameter i.e. &#8220;<em>exp help=yes</em>&#8221; or &#8220;<em>imp help=yes</em>&#8220;.</p>
<p>The export/import utilities are commonly used to perform the following tasks:<span id="more-169"></span></p>
<ul>
<li><strong><em>Back up and recover objects</em></strong><strong>.</strong> Perhaps the most widely used Export and Import feature is the capability to serve as a useful backup solution. Most Oracle installations use full online or hot backups to back up the entire database in the event of a CPU, network, or disk failure. This works well because all data can be restored to the very millisecond that the database crashed. However, Export and Import provide for extra safety. If just one table in the entire database needs to be recovered during a full backup, the entire database would have to be recovered on another machine, and the one table would be copied back over into the original database. This incredibly time- and resource-consuming task could become a real headache in distributed databases. Export and Import can save you this trouble by exporting the entire database and importing just the tables that need to be recovered. Now that point-in-time recovery is an option for <em>tablespaces </em>in Oracle8, Export and Import can also serve as a backup and recovery mechanism for the entire database.</li>
<li><strong><em>Copy objects among schemas</em></strong><strong>.</strong> You can use Export and Import to copy all object types such as tables, indexes, grants, procedures, and views from one schema to another. You can specify which objects you want to move, and provide the FROM and TO schemas. Oracle does the rest automatically.</li>
<li><strong><em>Copy objects among Oracle databases</em></strong><strong>.</strong> You can export a table in one Oracle database and import that table into another. Many businesses export key tables and send the export files to a remote office location, which can then use Import to load the data into its local database. This is a form of one-way data replication to remote locations.</li>
<li><strong><em>Generate </em></strong><strong><em>CREATE</em></strong><strong><em> scripts</em></strong>. Export and Import contain powerful options that allow you to generate CREATE scripts for tables, partitions, indexes, object-type definitions, views, grants, constraints, rollback segments, tablespaces, and all other objects in the database. This safeguards the structure of your objects, in case one gets corrupted or deleted.</li>
<li><strong><em>Migrate databases from one Oracle version to another</em></strong>. You can upgrade (or downgrade) the version of Oracle by using the Export and Import utilities. For example, you can export an Oracle7 database, copy the export file to an Oracle8 database server, and then import into the Oracle8 server. This process, called <em>migration</em>, makes the data and application function in an Oracle8 environment. Of course, we always recommend complete testing before relying on the results of a migration.</li>
<li><strong><em>Defragment a tablespace</em></strong>. Fragmentation occurs when tables and indexes are created, dropped, enlarged, and reduced in size over time. Fragmentation also occurs when an object&#8217;s <em>storage parameters </em>are sized improperly. To defragment a tablespace, you can export a tablespace, coalesce the free space (or drop and recreate the tablespace), and import the objects again.</li>
</ul>
<p>Because of the special binary format, files which had been created by the EXPORT utility can only be read by IMPORT. Both tools are only used to maintain ORACLE database objects.</p>
<p>SQL*Loader is similar to Import in that it can load data; the main difference is that Import can read only Oracle export files. SQL*Loader can read text files generated by non-Oracle databases.To load data from other systems into the database you have to use SQL*LOADER or other programs. To store data from database into readable operating system files you may use e.g. REPORTS, SQLPLUS.</p>
<p>While still supported on 10g the original import (<em>imp</em>) and export (<em>exp</em>) utilities were replaced in 10g with the faster and more advanced Data Pump-based import-export, <em>impdp</em> and <em>expdp</em>.</p>
<p>NOTE: It is generally advised not to use exports as the only means of backing-up a database. Physical backup methods (for example, when you use RMAN) are normally much quicker and supports point in time based recovery (apply archivelogs after recovering a database). Also, exp/imp is not practical for large database environments.</p>
<p>On 11g just imp will be still available, so if you using 10g, now is the time to starting using data pump.</p>
<h2>Prerequisites/Requirements</h2>
<p>exp and imp are utilities present in the <strong><em>$ORACLE_HOME/bin</em></strong> directory and are installed when Oracle is installed. Their prime purpose is to move logical objects out of and into the database respectively &#8211; for example dumping all of the tables owned by a user to a single file is achieved using the exp utility. It is important to distinguish between dumping data in this manner and backing up the database which is normally achieved using the <em>rman</em> utility.</p>
<p><strong><em>$ORACLE_HOME, $ORACLE_SID</em></strong> and <strong><em>$PATH</em></strong> environment variables need to be set appropriately in a unix environment and the <strong><em>%ORACLE_SID%</em></strong> environment variable needs to be set in a windows environment, before executing these commands. If you login as the owner of the oracle software (usually the oracle user on unix) these are likely to have been set in the users profile. The Oracle Database instance needs to be up in order to export/import data. Type <em>&#8216;imp help=y&#8217;</em> or <em>&#8216;exp help=y&#8217;</em> for a detailed explanation of the available options for these utilities.</p>
<p>It is a prerequisite that <strong><em>oraenv</em></strong> or <strong><em>coraenv</em></strong> (if you are working in a c-shell) was executed before you export-import data. Consider, if you stored data in the database by using an national language support (NLS) other than AMERICAN you have to change your environment before import-export.<br />
Example for a german environment:<br />
<strong><em>NLS_LANG=GERMAN_GERMANY.WE8ISO8859P1</em></strong><strong><em><br />
</em></strong><strong><em>export NLS_LANG</em></strong></p>
<p>In order to use exp and imp, the <strong><em>catexp.sql</em></strong> script must be run. <em>catexp.sql</em> basically creates the <strong><em>exp_full_database</em></strong> and <strong><em>imp_full_database</em></strong> roles. It is found under <strong><em>$ORACLE_HOME/rdbms/admin</em></strong>:</p>
<p>SQL&gt; @?/rdbms/admin/catexp</p>
<p><em>catexp</em> is called by <em>catalog.sql</em>. Note: SQL*Plus provides a shortcut to refer to the ORACLE_HOME directory: the question mark (<strong>?</strong>).</p>
<p>One must have the create session privilege for being able to use exp. If objects of another user&#8217;s schema need to be exported, the <strong><em>EXP_FULL_DATABASE</em></strong> role is required.</p>
<p>Before one imports rows into already populated tables, one needs to truncate or drop these tables to get rid of the old data. If not, the new data will be appended to the existing tables or it&#8217;ll get rejected. Either way, use the same syntax when you are ready to import the data. One must always DROP existing Sequences before re-importing. If the sequences are not dropped, they will generate numbers inconsistent with the rest of the database.</p>
<p>Note: It is also advisable to drop indexes before importing to speed up the import process. Indexes can easily be recreated after the data was successfully imported.</p>
<p><strong>Control and Configure Export-Import</strong><strong><br />
</strong>FULL, OWNER, and TABLE are the three types of exports. A FULL export exports all objects, structures, and data within the database for all schemas. OWNER exports only those objects owned by the specified user accounts. TABLE exports only the specified tables and partitions for specific user accounts.</p>
<p>Because dozens of object types can be exported, it&#8217;s important to distinguish what gets exported with each export category:</p>
<ul>
<li>With <strong>TABLE</strong>, the specified table (or cluster or partition) is exported with its indexes, referential integrity constraints, synonyms, and triggers.</li>
<li>With <strong>OWNER</strong> specified, all the specified schema&#8217;s objects are exported. This includes database links, sequences, packages/procedures/functions, object-type definitions, clusters/tables/partitions, postable actions, synonyms, views, triggers, snapshots/snapshot logs, job queues, and refresh groups.</li>
<li>With the <strong>FULL</strong> option, all objects described in OWNER are exported for every user account, in addition to tablespace definitions, profiles, user definitions (and encrypted passwords), roles, resource costs, rollback segment definitions, directory aliases, user history table, and auditing options.</li>
</ul>
<p>You can use the Export and Import utilities in <strong><em>interactive</em></strong> or <strong><em>non-interactive</em></strong> mode. In interactive mode, Oracle steps you through the process, prompting for basic Import/Export session information. This method, however, limits you to the simple prompts that Oracle provides. You have more flexibility in non-interactive mode because you can supply up to 23 parameters for the Export utility and 24 parameters for the Import utility. The parameters may be supplied at the command line or by specifying a command file that contains all parameters and values. You can automate Export and Import sessions by using a command file, or repeat them over and over again manually.</p>
<p>The syntax of running Export and Import is as follows:<br />
<em>EXP KEYWORD=value or keyword=(value1,value2,&#8230;,valueN)<br />
IMP KEYWORD=value or keyword=(value1,value2,&#8230;,valueN)</em><br />
Replace KEYWORD with the parameter, and value with what should be the parameter&#8217;s value. For example, use the following to export the entire database:<br />
<em>EXP USERID=SYSTEM/MANAGER FULL=Y</em></p>
<p>Use the following to import the EMP and DEPT tables owned by the SCOTT user account: <em>IMP USERID=SYSTEM/MANAGER FROMUSER=SCOTT TABLES=(EMP,DEPT)</em>The following examples demonstrate how the imp/exp utilities can be used:<br />
<em>exp scott/tiger file=emp.dmp log=emp.log tables=emp rows=yes indexes=no<br />
exp scott/tiger file=emp.dmp tables=(emp,dept)<br />
imp scott/tiger file=emp.dmp full=yes<br />
imp scott/tiger file=emp.dmp fromuser=scott touser=scott tables=dept</em><em> </em></p>
<p>Using a parameter file:<br />
<em>exp userid=scott/tiger@orcl parfile=export.txt</em><br />
&#8230; where export.txt contains:<br />
BUFFER=100000<br />
FILE=account.dmp<br />
FULL=n<br />
OWNER=scott<br />
GRANTS=y<br />
COMPRESS=y<br />
NOTE: If you do not like command line utilities, you can import and export data with the &#8220;Schema Manager&#8221; GUI that ships with Oracle Enterprise Manager (OEM).<br />
&#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;&#8212;&#8212;&#8211;<br />
<em>The EXPORT utility may be used in three ways: </em></p>
<ul>
<li>Interactive dialogue<br />
Simply type <strong>exp</strong>. You will be prompted for your ORACLE userid, password. All other prompts answer by pressing the return key. This is the easiest way to export all data you stored in the ORACLE database. You may assign other values than the defaults to the parameters but in most cases it is unnecessary.</li>
<li>Controlled through bypassed parameters<br />
You may bypass parameters when you export data from the database. Type:<br />
<strong><em>exp</em></strong><em> &lt;userid<strong>/</strong>password&gt; &lt;parameter&gt;<strong>=</strong>&lt;value&gt;,&lt;parameter&gt;<strong>=</strong>&lt;value&gt;,&#8230;</em><br />
Example of exporting scott&#8217;s tables EMP and DEPT to file empdept.expdat and storing all messages to file empdept.log:<br />
<em>exp scott/tiger file=empdept.expdat tables=(EMP,DEPT) log=empdept.log</em></li>
<li>Parameterfile controlled<br />
Instead of typing the parameters on the commandline you may use a parameter file where the parameters are stored. The syntax for this method is: <em>exp &lt;userid/password&gt; parfile=&lt;filename&gt;</em></li>
</ul>
<p>Do not ignore warnings and messages. Look at your logfile and repeat EXPORT until you get messages like:</p>
<pre><em>About to export specified tables ...
. exporting table                            EMP       14 rows exported
. exporting table                           DEPT        4 rows exported
Export terminated successfully without warnings.</em>
--------------------------------------------------------------------------------------
Like Export the <em>Import utility</em> is controlled by parameters. To get familiar with these parameters type: <em>imp help=y</em>
You will get a short description of usage and default settings of parameters.
To start IMPORT simply type <strong>imp</strong>. You will be prompted for your ORACLE userid, password. The next prompts depend on what you answer. In most cases you may answer the prompts by pressing the return key. But the following prompts you have to answer carefully.
<em>Import file: expdat.dmp &gt;
</em>If your data was exported to file expdat.dmp press return, otherwise enter the filename where the exported data resides.
<em>Ignore create error due to object existence (yes/no): yes &gt;
</em>This is a flag to indicate how object creation errors should be handeld. If you import into an existing table and you set <strong><em>IGNORE=Y</em></strong>, rows could be duplicated if they where already present in the table.
<em>Import entire export file (yes/no): yes &gt; no
Username:
</em>If your exportfile consists of more objects than you want to import, enter no. In this case you will be prompted for the Username (this is normally your ORACLE account). <em>Enter table names. Null list means all tables for user
Enter table name or . if done:
</em>After entering the username you will be prompted for table names until you press the return key without entering a table name. Than IMPORT will be started.

Instead of the dialogue method you may use parameters. This is analogous to the methods described for EXPORT.
Examples:
<em>imp &lt;userid/password&gt; tables=(table1,table2)</em><em>
</em>Tables table1, table2 will be imported from the default file export.dmp into the database.
<em>imp &lt;userid/password&gt; parfile=&lt;filename&gt;</em>
Import will be controlled by the named parameterfile.
After importing you should get messages like:</pre>
<pre><em>importing SCOTT's objects into SCOTT
. importing table "DEPT"                                     4 rows imported
. importing table "EMP"                                     14 rows imported
Import terminated successfully without warnings.</em>
-----------------------------------------------------------------------------------</pre>
<p><strong>Parameters for the Export utility</strong></p>
<p>Table below lists all parameters that can be used with the Export utility, along with their default values (if any).</p>
<table border="1" cellpadding="0">
<tbody>
<tr>
<td width="144" valign="top"><strong>Parameter</strong></td>
<td width="96" valign="top"><strong>Default Value</strong></td>
<td width="336" valign="top"><strong>Description</strong></td>
</tr>
<tr>
<td width="144" valign="top">BUFFER</td>
<td width="96" valign="top">OS-dependent</td>
<td width="336" valign="top">The size of BUFFER (in bytes) determines the memory buffer through which rows are exported. This should be larger than the size of the largest record multiplied by the number of rows that you want to fit within the buffer.</td>
</tr>
<tr>
<td width="144" valign="top">COMPRESS</td>
<td width="96" valign="top">Y</td>
<td width="336" valign="top">If COMPRESS=Y, the INITIAL storage parameter is set to the total size of all extents allocated for the object. The change takes effect only when the object is imported.</td>
</tr>
<tr>
<td width="144" valign="top">CONSISTENT</td>
<td width="96" valign="top">N</td>
<td width="336" valign="top">Setting CONSISTENT=Y exports all tables and references in a consistent state. This slows the export, as rollback space is used. If CONSISTENT=N and a record is modified during the export, the data will become inconsistent.</td>
</tr>
<tr>
<td width="144" valign="top">CONSTRAINTS</td>
<td width="96" valign="top">N</td>
<td width="336" valign="top">Specifies whether table constraints are exported.</td>
</tr>
<tr>
<td width="144" valign="top">DIRECT</td>
<td width="96" valign="top">N</td>
<td width="336" valign="top">If DIRECT=Y, Oracle bypasses the SQL command-processing layer, improving the speed of the export. Unfortunately, the new object types endemic to Oracle8, such as LOBs, don&#8217;t get exported.</td>
</tr>
<tr>
<td width="144" valign="top">FEEDBACK</td>
<td width="96" valign="top">0</td>
<td width="336" valign="top">Oracle displays a period for each group of records inserted. FEEDBACK defines the size of the group. For example, if FEEDBACK=1000, a period will be displayed for every 1,000 records imported. This parameter is useful for tracking the progress of large imports.</td>
</tr>
<tr>
<td width="144" valign="top">FILE</td>
<td width="96" valign="top">expdat.dmp</td>
<td width="336" valign="top">By default, expdat.dmp (stands for EXPort DATa.DuMP) is the filename. For a more meaningful name, change the FILE parameter.</td>
</tr>
<tr>
<td width="144" valign="top">FULL</td>
<td width="96" valign="top">N</td>
<td width="336" valign="top">The entire database will be exported if FULL=Y, including tablespace definitions.</td>
</tr>
<tr>
<td width="144" valign="top">GRANTS</td>
<td width="96" valign="top">Y</td>
<td width="336" valign="top">Specifies whether all grant definitions are exported for the objects being exported.</td>
</tr>
<tr>
<td width="144" valign="top">HELP</td>
<td width="96" valign="top">N</td>
<td width="336" valign="top">No other parameters are needed if you specify HELP=Y. A basic help screen will appear.</td>
</tr>
<tr>
<td width="144" valign="top">INCTYPE</td>
<td width="96" valign="top"></td>
<td width="336" valign="top">The valid options for this parameter are COMPLETE, CUMULATIVE, and INCREMENTAL. A COMPLETE export lays down a full export for which the other two options rely on for restores of the database. CUMULATIVE exports all tables and other objects that have changed since the last CUMULATIVE or COMPLETE export was taken; if one record in a table is altered, the entire table is exported. INCREMENTAL exports all tables and objects that have changed since the last INCREMENTAL, CUMULATIVE, or COMPLETE export.</td>
</tr>
</tbody>
</table>
<table border="1" cellpadding="0">
<tbody>
<tr>
<td width="600" valign="top"><strong>How can you easily see the Export/Import parameters and syntax?</strong></td>
</tr>
<tr>
<td width="600" valign="top">If you don&#8217;t have this book handy when necessary and haven&#8217;t memorized the dozens of parameters, the Export and Import utilities have a handy reference built in. Typing EXP HELP=Y or IMP HELP=Y at a command prompt brings up a nice one-page reference manual.</td>
</tr>
</tbody>
</table>
<table border="1" cellpadding="0">
<tbody>
<tr>
<td width="185" valign="top"><strong>Parameter</strong></td>
<td width="88" valign="top"><strong>Default Value</strong></td>
<td width="303" valign="top"><strong>Description</strong></td>
</tr>
<tr>
<td width="185" valign="top">INDEXES</td>
<td width="88" valign="top">Y</td>
<td width="303" valign="top">Specifies whether user-defined indexes are exported. System indexes created with constraints (primary key, unique key) and OID indexes are automatically exported, regardless of this parameter&#8217;s value.</td>
</tr>
<tr>
<td width="185" valign="top">LOG</td>
<td width="88" valign="top"></td>
<td width="303" valign="top">Specifies the name of the file to spool the feedback from the export session. Unless otherwise specified, Oracle appends a .LOG extension to the file.</td>
</tr>
<tr>
<td width="185" valign="top">PARFILE</td>
<td width="88" valign="top"></td>
<td width="303" valign="top">Rather than enter all parameters on the command line, some or all can be kept in a parameter file. This parameter specifies which file to use, if desired. This parameter is especially useful for non-interactive import sessions.</td>
</tr>
<tr>
<td width="185" valign="top">POINT_IN_TIME_RECOVER</td>
<td width="88" valign="top">N</td>
<td width="303" valign="top">Exports information for a point-in-time recovery for the tablespace listed with the TABLESPACES parameter.</td>
</tr>
<tr>
<td width="185" valign="top">RECORD</td>
<td width="88" valign="top">Y</td>
<td width="303" valign="top">If you use the INCTYPE parameter with RECORD=Y, the SYS data dictionary tables INCEXP, INCFIL, and INCVID are populated with export data such as owner, type of export, and the time of export.</td>
</tr>
<tr>
<td width="185" valign="top">RECORDLENGTH</td>
<td width="88" valign="top">OS-dependent</td>
<td width="303" valign="top">The RECORDLENGTH parameter is used only when you&#8217;ll import on a machine with a different byte count of the file than on the machine where the export occurs. The default should be used in most import sessions.</td>
</tr>
<tr>
<td width="185" valign="top">RECOVERY_TABLESPACES</td>
<td width="88" valign="top"></td>
<td width="303" valign="top">Used with POINT_IN_TIME_RECOVER;specifies which tablespaces can be recovered by using point-in-time recovery. This is important because imports otherwise can&#8217;t recover transactions past the time of export.</td>
</tr>
<tr>
<td width="185" valign="top">ROWS</td>
<td width="88" valign="top">Y</td>
<td width="303" valign="top">Specifies whether table and object data will be exported. If ROWS=N, only object definitions are exported.</td>
</tr>
<tr>
<td width="185" valign="top">STATISTICS</td>
<td width="88" valign="top">ESTIMATE</td>
<td width="303" valign="top">Specifies whether table and index statistics are to be analyzed with COMPUTE or ESTIMATE when imported. Only those objects that already have statistics on them will be analyzed during import. Specify NONE if no objects should be analyzed.</td>
</tr>
<tr>
<td width="185" valign="top">TABLES</td>
<td width="88" valign="top"></td>
<td width="303" valign="top">Specifies a comma-separated list of all tables to be exported. This parameter could be used with the OWNER parameter to specify which owner to associate the tables with. Tables can also be specified with the owner.table_name format. In a non-UNIX environment such as Windows NT, you must enclose the table list within parentheses.</td>
</tr>
<tr>
<td width="185" valign="top">TABLESPACES</td>
<td width="88" valign="top"></td>
<td width="303" valign="top">List of tablespaces to be exported with the POINT_IN_TIME_RECOVER parameter.</td>
</tr>
<tr>
<td width="185" valign="top">USERID</td>
<td width="88" valign="top"></td>
<td width="303" valign="top">Specifies the username and password for the user conducting the import. The format for the command is username/password. You can also use Net8&#8242;s @connect_string format if you want.</td>
</tr>
</tbody>
</table>
<p><strong>Parameters for the Import utility</strong><strong><br />
</strong>You can use 24 parameters during an import session. They may be specified in the command line or any specified parameter file. Table below lists all the import parameters.</p>
<table border="1" cellpadding="0">
<tbody>
<tr>
<td width="144" valign="top"><strong>Parameter</strong></td>
<td width="96" valign="top"><strong>Default Value</strong></td>
<td width="336" valign="top"><strong>Description</strong></td>
</tr>
<tr>
<td width="144" valign="top">ANALYZE</td>
<td width="96" valign="top">Y</td>
<td width="336" valign="top">Imported tables have their statistics analyzed if ANALYZE is set to Y. Only those tables that already had statistics on them during the export are computed. The tables will be ESTIMATED by default, unless the export was performed with the STATISTICS=COMPUTE parameter configuration.</td>
</tr>
<tr>
<td width="144" valign="top">BUFFER</td>
<td width="96" valign="top">OS-dependent</td>
<td width="336" valign="top">The BUFFER size (in bytes) determines the memory buffer through which rows are imported. This should be larger than the size of the largest record multiplied by the number of rows that you want to fit within the buffer.</td>
</tr>
<tr>
<td width="144" valign="top">CHARSET</td>
<td width="96" valign="top"></td>
<td width="336" valign="top">An obsolete Oracle6 parameter, indicating whether the export was done in ASCII or EBCDIC. This information is processed automatically in Oracle7 and Oracle8.</td>
</tr>
<tr>
<td width="144" valign="top">COMMIT</td>
<td width="96" valign="top">N</td>
<td width="336" valign="top">By default, a COMMIT occurs after each table, nested table, and partition. If you&#8217;re importing a large table, the rollback segments may grow large. To improve performance while loading large tables, you should set COMMIT=Y.</td>
</tr>
<tr>
<td width="144" valign="top">DESTROY</td>
<td width="96" valign="top">N</td>
<td width="336" valign="top">If you set DESTROY=Y and do a full import, Oracle will overwrite any data files that exist. If you use raw devices for your data files, they will be overwritten during a full import, as DESTROY=N won&#8217;t prevent the overwriting of datafiles! Don&#8217;t use this option unless you know what you&#8217;re doing.</td>
</tr>
<tr>
<td width="144" valign="top">FEEDBACK</td>
<td width="96" valign="top">0</td>
<td width="336" valign="top">Oracle displays a period for each group of records inserted. FEEDBACK defines the size of the group. For example, if FEEDBACK=1000, a period is displayed for every 1,000 records imported. This parameter is useful for tracking the progress of large imports.</td>
</tr>
</tbody>
</table>
<table border="1" cellpadding="0">
<tbody>
<tr>
<td width="600" valign="top"><strong>Export/Import and non-Oracle databases</strong></td>
</tr>
<tr>
<td width="600" valign="top">The export file (expdat.dmp by default) is a binary file that only Oracle databases can read. Many databases and PC software can export data into delimited text files, but the Export utility can&#8217;t. To transfer data from Oracle to a non-Oracle database, you must make a delimited file manually by spooling from within PL/SQL or SQL*Plus and running a custom-made script.</td>
</tr>
</tbody>
</table>
<table border="1" cellpadding="0">
<tbody>
<tr>
<td width="144" valign="top"><strong>Parameter</strong></td>
<td width="96" valign="top"><strong>Default Value</strong></td>
<td width="336" valign="top"><strong>Description</strong></td>
</tr>
<tr>
<td width="144" valign="top">FILE</td>
<td width="96" valign="top">expdat.dmp</td>
<td width="336" valign="top">By default, expdat.dmp (stands for EXPort DATa.DuMP) is the name of the file that Import will import from. If the file is something other than expdat.dmp, specify it with this parameter.</td>
</tr>
<tr>
<td width="144" valign="top">FROMUSER</td>
<td width="96" valign="top"></td>
<td width="336" valign="top">Specifying this parameter imports only those objects owned by the FROMUSER user account.</td>
</tr>
<tr>
<td width="144" valign="top">FULL</td>
<td width="96" valign="top">N</td>
<td width="336" valign="top">The entire database will be imported if FULL=Y.</td>
</tr>
<tr>
<td width="144" valign="top">GRANTS</td>
<td width="96" valign="top">Y</td>
<td width="336" valign="top">Specifies whether all grants will be created for the exported objects.</td>
</tr>
<tr>
<td width="144" valign="top">HELP</td>
<td width="96" valign="top">N</td>
<td width="336" valign="top">No other parameters are needed if you specify HELP=Y. A basic help screen will appear.</td>
</tr>
<tr>
<td width="144" valign="top">IGNORE</td>
<td width="96" valign="top">N</td>
<td width="336" valign="top">If IGNORE=Y, object creation errors are ignored, and records are inserted into the table. Duplicate records can result, if no unique constraints exist for the table. Non-object creation errors are still reported, such as operating system problems.</td>
</tr>
<tr>
<td width="144" valign="top">INCTYPE</td>
<td width="96" valign="top"></td>
<td width="336" valign="top">If you&#8217;re importing an incremental export, tables are dropped and recreated. You must first restore from the last SYSTEM export (specify INCTYPE=SYSTEM). Then import every incremental export (specify INCTYPE=RESTORE) until the desired changes are applied to the database.</td>
</tr>
<tr>
<td width="144" valign="top">INDEXES</td>
<td width="96" valign="top">Y</td>
<td width="336" valign="top">Specifies whether user-defined indexes are imported. System indexes created with constraints (primary key, unique key) and OID indexes are automatically imported, regardless of this parameter&#8217;s value.</td>
</tr>
<tr>
<td width="144" valign="top">INDEXFILE</td>
<td width="96" valign="top"></td>
<td width="336" valign="top">Specifies the name of the file to generate CREATE INDEX statements. Unless otherwise specified, Oracle appends an .SQL extension to the file. (This parameter is explained in more detail later in this chapter.)</td>
</tr>
</tbody>
</table>
<table border="1" cellpadding="0">
<tbody>
<tr>
<td width="600" valign="top"><strong>Using the </strong><strong>LOG </strong><strong>parameter</strong></td>
</tr>
<tr>
<td width="600" valign="top">You can specify a <em>log file </em>for the Export and Import sessions with the LOG parameter. The file, which mimics what&#8217;s output to the screen, reports all successful and unsuccessful messages to be examined at a later point. Some Oracle experts use this file during an automated load process and then checks the file for errors. A database administrator is paged if any appear.</td>
</tr>
</tbody>
</table>
<table border="1" cellpadding="0">
<tbody>
<tr>
<td width="187" valign="top"><strong>Parameter</strong></td>
<td width="92" valign="top"><strong>Default Value</strong></td>
<td width="298" valign="top"><strong>Description</strong></td>
</tr>
<tr>
<td width="187" valign="top">LOG</td>
<td width="92" valign="top"></td>
<td width="298" valign="top">Specifies the name of the file to spool the feedback from the import session. Unless otherwise specified, Oracle appends an .LOG extension to the file.</td>
</tr>
<tr>
<td width="187" valign="top">PARFILE</td>
<td width="92" valign="top"></td>
<td width="298" valign="top">Rather than enter all parameters on the command line, some or all may be kept in a parameter file. The PARFILE parameter specifies which file to use, if desired. This parameter is especially useful for non-interactive import sessions.</td>
</tr>
<tr>
<td width="187" valign="top">POINT_IN_TIME_RECOVER</td>
<td width="92" valign="top">N</td>
<td width="298" valign="top">Performs a point-in-time recovery for the tablespace exported with the TABLESPACES parameter.</td>
</tr>
<tr>
<td width="187" valign="top">RECORDLENGTH</td>
<td width="92" valign="top">OS-dependent</td>
<td width="298" valign="top">Used only when importing on a machine with a different byte count of the file than on the machine where the export occurred. The default should be used in most Import sessions.</td>
</tr>
<tr>
<td width="187" valign="top">SHOW</td>
<td width="92" valign="top">N</td>
<td width="298" valign="top">Displays each SQL statement and doesn&#8217;t apply them to the database. The SQL statements can be viewed and modified when used with the FILE parameter. (The SHOW parameter is explained in more detail later in this chapter.)</td>
</tr>
<tr>
<td width="187" valign="top">SKIP_UNUSABLE_INDEXES</td>
<td width="92" valign="top">N</td>
<td width="298" valign="top">Allows the postponement of index creation until the record data is imported. The indexes affected are only those set to an unusable state, and all other indexes are created if INDEXES=Y (the default value) is set.</td>
</tr>
<tr>
<td width="187" valign="top">TABLES</td>
<td width="92" valign="top"></td>
<td width="298" valign="top">Specifies a comma-separated list of all tables to be imported. You should use this parameter with the FROMUSER parameter. In a non-UNIX environment, such as Windows NT, enclose the table list within parentheses.</td>
</tr>
<tr>
<td width="187" valign="top">TOUSER</td>
<td width="92" valign="top"></td>
<td width="298" valign="top">Specifies the user account into which tables should be imported, if you want it to be different from the original owner of the tables. This parameter needs to be used with the FROMUSER parameter.</td>
</tr>
<tr>
<td width="187" valign="top">USERID</td>
<td width="92" valign="top"></td>
<td width="298" valign="top">Specifies the username and password for the user conducting the import. The format for the command is username/password. You may also use Net8&#8242;s @connect_string format if desired.</td>
</tr>
</tbody>
</table>
<h2>&#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;&#8212;&#8212;&#8212;&#8211;Using imp/exp across different Oracle version</h2>
<p>If exp and imp are used to export data from an Oracle database with a different version than the database in which is imported, then the following rules apply:</p>
<ul>
<li>1. exp must be of the lower version</li>
<li>2. imp must match the target version</li>
</ul>
<p>&#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;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<strong>Common Export/Import Errors</strong></p>
<ul>
<li><strong>ORA-00001: Unique constraint (&#8230;) violated</strong><br />
You are importing duplicate rows. Use IGNORE=YES to skip tables that already exist (imp will give an error if the object is re-created) OR Perform the following actions:</li>
<li>1. Back up the target table.</li>
<li>2. Try deleting the target table.</li>
<li>3. Run the import for this table again in overwrite mode.</li>
<li><strong>ORA-01555: Snapshot too old</strong><br />
Ask your users to STOP working while you are exporting or try using parameter CONSISTENT=NO</li>
<li><strong>ORA-01562: Failed to extend rollback segment</strong><br />
Create bigger rollback segments or set parameter COMMIT=Y while importing</li>
<li><strong>IMP-00015: Statement failed &#8230; object already exists&#8230;</strong><br />
Use the IGNORE=Y import parameter to ignore these errors, but be careful as you might end up with duplicate rows.</li>
</ul>
<p><a name="BACDAACC"></a><a name="i1008356"></a><a name="BACFJHAI"></a><a name="i1008361"></a><a name="BACGIDJI"></a><a name="i1008366"></a><a name="BACHBHDD"></a><a name="i1008371"></a><a name="BACHJCCC"></a>&#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;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
<strong>To Improve performance<em> </em></strong></p>
<p><strong>Export</strong></p>
<ul>
<li>Set the BUFFER parameter to a high value (e.g. 2Mb &#8212; entered as an integer &#8220;2000000&#8243;)</li>
<li>Set the RECORDLENGTH parameter to a high value (e.g. 64Kb &#8212; entered as an integer &#8220;64000&#8243;)</li>
<li>Use DIRECT=yes (direct mode export)</li>
<li>Stop unnecessary applications to free-up resources for your job.</li>
<li>If you run multiple export sessions, ensure they write to different physical disks.</li>
<li>DO NOT export to an NFS mounted filesystem. It will take forever.</li>
</ul>
<p><strong>Import</strong><strong><em> </em></strong></p>
<ul>
<li>Create an indexfile so that you can create indexes AFTER you have imported data. Do this by setting INDEXFILE to a filename and then import. No data will be imported but a file containing index definitions will be created. You must edit this file afterwards and supply the passwords for the schemas on all CONNECT statements. <strong><em> </em></strong></li>
<li>Place the file to be imported on a separate physical disk from the oracle data files<strong><em> </em></strong></li>
<li>Increase DB_CACHE_SIZE (DB_BLOCK_BUFFERS prior to 9i) considerably in the init$SID.ora file <strong><em> </em></strong></li>
<li>Set the LOG_BUFFER to a big value and restart oracle. <strong><em> </em></strong></li>
<li>Stop redo log archiving if it is running (ALTER DATABASE NOARCHIVELOG;)<strong><em> </em></strong></li>
<li>Create a BIG tablespace with a BIG rollback segment inside. Set all other rollback segments offline (except the SYSTEM rollback segment of course). The rollback segment must be as big as your biggest table (I think?) <strong><em> </em></strong></li>
<li>Use COMMIT=N in the import parameter file if you can afford it <strong><em> </em></strong></li>
<li>Use STATISTICS=NONE in the import parameter file to avoid time consuming to import the statistics <strong><em> </em></strong></li>
<li>Remember to run the indexfile previously created <strong><em> </em></strong></li>
</ul>
<p>&#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;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
<strong>Good practices</strong></p>
<ul>
<li>Always take care about CHARSETS when you do export and import. Using the wrong ones can convert your data in a lossy manner. The best situation is when your source and destination database have the same character sets, so you can avoid completely any character conversion. You control this behavior by setting NLS_LANG environment variable appropriately. When not set properly you may see &#8216;Exporting questionable statistics&#8217; messages.</li>
<li>After doing an export, it is better to check your dump by doing an import with the parameter SHOW=Y. This checks the validity of your dump file.</li>
</ul>
<p>&#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;&#8212;&#8212;&#8212;&#8212;&#8212;<strong>Other considerations</strong></p>
<ul>
<li>You may need to patch your Oracle client (where you are running exp/imp) to the same level as the Oracle server to prevent errors</li>
<li>When importing large amounts of data consider dropping indexes prior to the import to speed up the process and re-creating them once the import is completed</li>
<li>The amount of archive logs that may be created on a large import may fill up your disk</li>
<li>On INSERT triggers will fire, consider whether these need to be disabled</li>
<li>Increasing the RECORDLENGTH (max 65535) parameter can improve the length of time to perform an import/export as well as DIRECT=y for export</li>
</ul>
<p>&#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;&#8212;-<br />
Tablespace fragmentation occurs when objects are created, dropped, enlarged, and shrunk. The more often this occurs, the more fragmented the tablespace becomes. This causes free space to be broken into many separated island-like chunks of space. In addition, if an object has multiple extents, they could be spread out over different parts of the tablespace; this causes performance and maintenance problems. With many small blocks of free space instead of fewer large free spaces, you may be unable to create some objects that you otherwise could have. By defragmenting the tablespace, the data is reorganized so that all free space is put into one contiguous area, and each object&#8217;s extents are grouped next to each other.</p>
<ul>
<li>The Export and Import utilities can fix fragmentation in two ways:<br />
They can take a table with multiple extents and resize it into a table with one larger extent. This larger single extent will encompass the total size of all previous table extents.</li>
<li>They can make all objects within the tablespace adjacent to each other with no island-like characteristics, while at the same time merging all the free space into one larger free space.</li>
</ul>
<p>The easiest and most dramatic method fixes both fragmentation problems for the entire database. The database is shut down during the process. This forces all sessions against the database to stop (which is why it&#8217;s the most dramatic method).</p>
<p>Fixing a table&#8217;s storage parameter is fairly easy compared to the entire tablespace, as only one table is affected. To fix an entire tablespace, you&#8217;ll have to drop and recreate it, along with all the tables within it.</p>
<p><strong>Fix both fragmentation problems quickly</strong></p>
<ul type="disc">
<li>Export the entire database, specifying <tt>FULL=Y</tt> and <tt>COMPRESS=Y</tt>. <tt>FULL=Y</tt> exports the entire database; <tt>COMPRESS=Y</tt> changes the <tt>INITIAL</tt> storage parameter of each table in the database (if necessary) to fit within one extent each. For example, if a table has five 10M extents, the <tt>COMPRESS=Y</tt> specification changes the table to one 50M extent when imported.</li>
<li>Drop and recreate the entire database.</li>
<li>Import the entire database with the <tt>FULL=Y</tt> parameter.</li>
</ul>
<p><strong>Defragment just one tablespace (a less dramatic method)</strong></p>
<ul type="disc">
<li>Determine which tables exist in the tablespace and export just those tables.</li>
<li>Drop all the tables in the tablespace.</li>
<li>Issue the <tt>ALTER TABLESPACE COALESCE</tt> command (or drop and recreate the tablespace). This will coalesce all the free space within the tablespace into one contiguous area.</li>
<li>Import the tables. Oracle will create the tables adjacent to each other within the tablespace, and all free space will still be contiguous in one chunk of space. <strong> </strong></li>
</ul>
<p>&#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;&#8212;-</p>
<p><strong>Some more examples</strong></p>
<p><strong>EXP</strong><br />
To dump a single schema to disk (we use the scott example schema here)</p>
<p>- Login to server which has an Oracle client</p>
<p><em>exp &lt;user&gt;/&lt;password&gt; FILE=scott.dmp OWNER=scott</em><br />
To export specific tables to disk: Login to server which has an Oracle client</p>
<p><em>exp SYSTEM/password FIlE=expdat.dmp TABLES=(scott.emp,hr.countries) </em></p>
<p>The above command uses two users : scott and hr</p>
<p><em> </em></p>
<p><em>exp &lt;user&gt;/&lt;password&gt; FILE=scott.dmp TABLES=(emp,dept) </em></p>
<p>the above is only for one user : scott</p>
<p><strong>IMP<br />
</strong>To import the full database exported in the example above.<br />
<em>imp SYSTEM/password FULL=y FIlE=dba.dmp </em></p>
<p>To import just the dept and emp tables from the scott schema<br />
<em>imp SYSTEM/password FIlE=dba.dmp FROMUSER=scott TABLES=(dept,emp) </em></p>
<p>To import tables and change the owner</p>
<p><em>imp SYSTEM/password FROMUSER=blake TOUSER=scott FILE=blake.dmp TABLES=(unit,manager)</em><br />
To import just the scott schema exported in the example above:<br />
<em>imp &lt;user&gt;/&lt;password&gt; FIlE=scott.dmp</em></p>
<p>If you do not supply any parameters then you enter an interactive session as illustrated below. (Responses to prompts are shown in blue<strong>. </strong>from the prompt type imp and press enter</p>
<p>$&gt;imp<br />
Import: Release 9.2.0.6.0 &#8211; Production on Thu Mar 29 15:07:43 2007<br />
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.<br />
Username: SYSTEM<br />
Password: password<br />
Connected to: Oracle9i Enterprise Edition Release 9.2.0.6.0 &#8211; Production<br />
With the Partitioning, OLAP and Oracle Data Mining options<br />
JServer Release 9.2.0.6.0 &#8211; Production<br />
Import file: expdat.dmp &gt; /mention/path/of/dumpFile/includingFileName.dmp<br />
Enter insert buffer size (minimum is 8192) 30720&gt;<strong> </strong>(press enter to accept default)<br />
Export file created by EXPORT:V09.02.00 via conventional path<br />
import done in US7ASCII character set and AL16UTF16 NCHAR character set<br />
import server uses AL32UTF8 character set (possible charset conversion)<br />
List contents of import file only (yes/no): no &gt; press enter<br />
Ignore create error due to object existence (yes/no): no &gt; press enter<br />
Import grants (yes/no): yes &gt; press enter<br />
Import table data (yes/no): yes &gt; press enter<br />
Import entire export file (yes/no): no &gt; press enter or type no<br />
Username: give the userName for which you want the data to be imported<br />
Enter table(T) or partition(T:P) names. Null list means all tables for user<br />
Enter table(T) or partition(T:P) name or . if done: press enter<br />
. importing TST_001_V2&#8242;s objects into TST_001_V2</p>
<left><a class="tt" href="http://twitter.com/home/?status=Oracle+Export+and+Import+utility+tutorial+http://bit.ly/cd5pDV" title="Post to Twitter"><img class="nothumb" src="http://www.oratraining.com/blog/wp-content/plugins/tweet-this/icons/tt-twitter-big3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.oratraining.com/blog/2009/06/oracle-export-import-utility-exp-imp-tutorial/&amp;title=Oracle+Export+and+Import+utility+tutorial" title="Post to Digg"><img class="nothumb" src="http://www.oratraining.com/blog/wp-content/plugins/tweet-this/icons/tt-digg-big4.png" alt="Post to Digg" /></a></left><div class="fblike" style="height:25px; height:25px; overflow:hidden;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.oratraining.com%2Fblog%2F2009%2F06%2Foracle-export-import-utility-exp-imp-tutorial%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allow Transparency="true" style="border:none; overflow:hidden; width:450px;"></iframe></div><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.oratraining.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.oratraining.com/blog/2009/06/oracle-export-import-utility-exp-imp-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cmclean.sql script to cleanup concurrent manager tables</title>
		<link>http://www.oratraining.com/blog/2009/04/cmclean-sql-script-to-cleanup-concurrent-manager-tables/</link>
		<comments>http://www.oratraining.com/blog/2009/04/cmclean-sql-script-to-cleanup-concurrent-manager-tables/#comments</comments>
		<pubDate>Sat, 04 Apr 2009 12:42:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Concurrent manager]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle Applications]]></category>
		<category><![CDATA[Oracle Applications DBA]]></category>
		<category><![CDATA[oracle applications]]></category>

		<guid isPermaLink="false">http://www.oratraining.com/blog/?p=127</guid>
		<description><![CDATA[Click here to download cmclean.sql REM REM FILENAME REM   cmclean.sql REM DESCRIPTION REM   Clean out the concurrent manager tables REM NOTES REM   Usage: sqlplus &#60;apps_user/apps_passwd&#62; @cmclean REM REM REM   $Id: cmclean.sql,v 1.4 2001/04/07 15:55:07 pferguso Exp $ REM REM REM +==============================+ set verify off; set head off; set timing off set pagesize 1000 column manager format [...]]]></description>
			<content:encoded><![CDATA[<h4 style="font-size: 1em;">Click here to download <a href="http://www.oratraining.com/docs/oracle/scripts/cmclean.sql" target="_blank">cmclean.sql</a></h4>
<p>REM<br />
REM FILENAME<br />
REM   cmclean.sql<br />
REM DESCRIPTION<br />
REM   Clean out the concurrent manager tables<br />
REM NOTES<br />
REM   Usage: sqlplus &lt;apps_user/apps_passwd&gt; @cmclean<br />
REM<br />
REM<br />
REM   $Id: cmclean.sql,v 1.4 2001/04/07 15:55:07 pferguso Exp $<br />
REM<br />
REM<br />
REM +==============================+<br />
set verify off;<br />
set head off;<br />
set timing off<br />
set pagesize 1000<br />
column manager format a20 heading &#8216;Manager short name&#8217;<br />
column pid heading &#8216;Process id&#8217;<br />
column pscode format a12 heading &#8216;Status code&#8217;<br />
column ccode format a12 heading &#8216;Control code&#8217;<br />
column request heading &#8216;Request ID&#8217;<br />
column pcode format a6 heading &#8216;Phase&#8217;<br />
column scode format a6 heading &#8216;Status&#8217;<br />
WHENEVER SQLERROR EXIT ROLLBACK;<span id="more-127"></span><br />
DOCUMENT<br />
WARNING : Do not run this script without explicit instructions<br />
from Oracle Support<br />
*** Make sure that the managers are shut down     ***<br />
*** before running this script                    ***<br />
*** If the concurrent managers are NOT shut down, ***<br />
*** exit this script now !!                       ***<br />
#<br />
accept answer prompt &#8216;If you wish to continue type the word &#8221;dual&#8221;: &#8216;<br />
set feed off<br />
select null from &amp;answer;<br />
set feed on<br />
REM     Update process status codes to TERMINATED<br />
prompt<br />
prompt  &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
prompt  &#8212; Updating invalid process status codes in FND_CONCURRENT_PROCESSES<br />
set feedback off<br />
set head on<br />
break on manager<br />
SELECT  concurrent_queue_name manager,<br />
concurrent_process_id pid,<br />
process_status_code pscode<br />
FROM    fnd_concurrent_queues fcq, fnd_concurrent_processes fcp<br />
WHERE   process_status_code not in (&#8216;K&#8217;, &#8216;S&#8217;)<br />
AND     fcq.concurrent_queue_id = fcp.concurrent_queue_id<br />
AND     fcq.application_id = fcp.queue_application_id;<br />
set head off<br />
set feedback on<br />
UPDATE  fnd_concurrent_processes<br />
SET     process_status_code = &#8216;K&#8217;<br />
WHERE   process_status_code not in (&#8216;K&#8217;, &#8216;S&#8217;);<br />
REM     Set all managers to 0 processes<br />
prompt<br />
prompt  &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
prompt  &#8212; Updating running processes in FND_CONCURRENT_QUEUES<br />
prompt  &#8212; Setting running_processes = 0 and max_processes = 0 for all managers<br />
UPDATE  fnd_concurrent_queues<br />
SET     running_processes = 0, max_processes = 0;<br />
REM     Reset control codes<br />
prompt<br />
prompt  &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
prompt  &#8212; Updating invalid control_codes in FND_CONCURRENT_QUEUES<br />
set feedback off<br />
set head on<br />
SELECT  concurrent_queue_name manager,<br />
control_code ccode<br />
FROM    fnd_concurrent_queues<br />
WHERE   control_code not in (&#8216;E&#8217;, &#8216;R&#8217;, &#8216;X&#8217;)<br />
AND     control_code IS NOT NULL;<br />
set feedback on<br />
set head off<br />
UPDATE  fnd_concurrent_queues<br />
SET     control_code = NULL<br />
WHERE   control_code not in (&#8216;E&#8217;, &#8216;R&#8217;, &#8216;X&#8217;)<br />
AND     control_code IS NOT NULL;<br />
REM     Also null out target_node for all managers<br />
UPDATE  fnd_concurrent_queues<br />
SET     target_node = null;<br />
REM     Set all &#8216;Terminating&#8217; requests to Completed/Error<br />
REM     Also set Running requests to completed, since the managers are down<br />
prompt<br />
prompt  &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
prompt  &#8212; Updating any Running or Terminating requests to Completed/Error<br />
set feedback off<br />
set head on<br />
SELECT  request_id request,<br />
phase_code pcode,<br />
status_code scode<br />
FROM    fnd_concurrent_requests<br />
WHERE   status_code = &#8216;T&#8217; OR phase_code = &#8216;R&#8217;<br />
ORDER BY request_id;<br />
set feedback on<br />
set head off<br />
UPDATE  fnd_concurrent_requests<br />
SET     phase_code = &#8216;C&#8217;, status_code = &#8216;E&#8217;<br />
WHERE   status_code =&#8217;T&#8217; OR phase_code = &#8216;R&#8217;;<br />
REM     Set all Runalone flags to &#8216;N&#8217;<br />
REM     This has to be done differently for Release 10<br />
prompt<br />
prompt  &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
prompt  &#8212; Updating any Runalone flags to &#8216;N&#8217;<br />
prompt<br />
set serveroutput on<br />
set feedback off<br />
declare<br />
c         pls_integer := dbms_sql.open_cursor;<br />
upd_rows  pls_integer;<br />
vers      varchar2(50);<br />
tbl       varchar2(50);<br />
col       varchar2(50);<br />
statement varchar2(255);<br />
begin<br />
select substr(release_name, 1, 2)<br />
into   vers<br />
from fnd_product_groups;<br />
if vers &gt;= 11 then<br />
tbl := &#8216;fnd_conflicts_domain&#8217;;<br />
col := &#8216;runalone_flag&#8217;;<br />
else<br />
tbl := &#8216;fnd_concurrent_conflict_sets&#8217;;<br />
col := &#8216;run_alone_flag&#8217;;<br />
end if;<br />
statement := &#8216;update &#8216; || tbl || &#8216; set &#8216; || col || &#8216;=&#8221;N&#8221; where &#8216; || col || &#8216; = &#8221;Y&#8221;&#8217;;<br />
dbms_sql.parse(c, statement, dbms_sql.native);<br />
upd_rows := dbms_sql.execute(c);<br />
dbms_sql.close_cursor(c);<br />
dbms_output.put_line(&#8216;Updated &#8216; || upd_rows || &#8216; rows of &#8216; || col || &#8216; in &#8216; || tbl || &#8216; to &#8221;N&#8221;&#8217;);<br />
end;<br />
/</p>
<p>prompt</p>
<p>prompt  &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>prompt  Updates complete.<br />
prompt  Type commit now to commit these updates, or rollback to cancel.<br />
prompt  &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>prompt</p>
<p>set feedback on</p>
<p>REM  &lt;= Last REM statment &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<left><a class="tt" href="http://twitter.com/home/?status=cmclean.sql+script+to+cleanup+concurrent+manager+tables+http://bit.ly/bR8sTN" title="Post to Twitter"><img class="nothumb" src="http://www.oratraining.com/blog/wp-content/plugins/tweet-this/icons/tt-twitter-big3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.oratraining.com/blog/2009/04/cmclean-sql-script-to-cleanup-concurrent-manager-tables/&amp;title=cmclean.sql+script+to+cleanup+concurrent+manager+tables" title="Post to Digg"><img class="nothumb" src="http://www.oratraining.com/blog/wp-content/plugins/tweet-this/icons/tt-digg-big4.png" alt="Post to Digg" /></a></left><div class="fblike" style="height:25px; height:25px; overflow:hidden;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.oratraining.com%2Fblog%2F2009%2F04%2Fcmclean-sql-script-to-cleanup-concurrent-manager-tables%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allow Transparency="true" style="border:none; overflow:hidden; width:450px;"></iframe></div><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.oratraining.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.oratraining.com/blog/2009/04/cmclean-sql-script-to-cleanup-concurrent-manager-tables/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
