<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;DEYHRng6fSp7ImA9WhRaEkg.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471</id><updated>2012-02-14T22:48:57.615+01:00</updated><category term="Admin" /><category term="Developer" /><category term="OS" /><title>Oracle DBA Tips</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://dbatips4u.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>28</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/dbatip4u" /><feedburner:info uri="dbatip4u" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;AkUHQn07cCp7ImA9Wx5SE0k.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-6902768361678038869</id><published>2010-08-09T12:03:00.000+02:00</published><updated>2010-08-09T12:03:53.308+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-08-09T12:03:53.308+02:00</app:edited><title>Tip#28 Thin (JDBC) Vs Thick (OCI) Driver</title><content type="html">JDBC Thin Vs OCI (Thick)&lt;br /&gt;
&lt;br /&gt;
Loads of info available on what it means and which one to use etc etc. I just put two of the links which says it all,&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Horse's Mouth&lt;/b&gt; : &lt;a href="http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.html#02_05"&gt;Oracle Document Link&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Generally the Thin driver is the best choice. In most cases it is as fast or faster than the OCI driver (from 10.1.0), has almost exactly the same set of features, and is easier to administer. &lt;br /&gt;
&lt;br /&gt;
In a few cases the OCI driver has slightly better performance. The OCI driver supports a few Oracle features better than the Thin driver. &lt;br /&gt;
The Thin driver is easier to administer since it does not require installation of the OCI C libraries. &lt;br /&gt;
The Thin driver will work on any machine that has a suitable Java VM, whereas with the OCI driver you must install the proper OCI C libraries for each machine. &lt;br /&gt;
&lt;br /&gt;
We recommend using the Thin driver unless you must have one or more of the OCI only features, or until it is clear that the small performance gain provided by the OCI driver is worth the extra effort.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Thin Vs Thick Performance Test&lt;/b&gt; :  &lt;a href="http://onjava.com/pub/a/onjava/excerpt/oraclejdbc_19/index.html?page=3"&gt;Test Link&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Final Word :&lt;br /&gt;
&lt;br /&gt;
"The Thin driver clearly outperforms the OCI driver for every type of operation except executions of CallableStatement objects. On a Unix platform, my experience has been that the CallableStatement numbers are tilted even more in favor of the OCI driver. Nonetheless, you can feel completely comfortable using the Thin driver in almost any setting. The Thin driver has been well-tuned by Oracle's JDBC development team to perform better than its OCI counterpart."&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-6902768361678038869?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/eKVn9SnARIWILztj4EI1ucttGIw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/eKVn9SnARIWILztj4EI1ucttGIw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/eKVn9SnARIWILztj4EI1ucttGIw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/eKVn9SnARIWILztj4EI1ucttGIw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/RMnw90sYHSw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/6902768361678038869/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=6902768361678038869" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/6902768361678038869?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/6902768361678038869?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/RMnw90sYHSw/tip28-thin-jdbc-vs-thick-oci-driver.html" title="Tip#28 Thin (JDBC) Vs Thick (OCI) Driver" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2010/08/tip28-thin-jdbc-vs-thick-oci-driver.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkEERX0zfip7ImA9Wx5TGU8.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-4016049038451397769</id><published>2010-08-04T14:20:00.001+02:00</published><updated>2010-08-04T14:23:24.386+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-08-04T14:23:24.386+02:00</app:edited><title>Tip#27 Listener Log File Too Big</title><content type="html">Over a period it is quite often you will see that listener.log in&amp;nbsp; ORACLE_HOME/network/log has grown to X GB in size.So how do we manage it ?&lt;br /&gt;
&lt;br /&gt;
Do not have to stop the listener in order to delete the log files, just do the following &lt;br /&gt;
&lt;br /&gt;
&lt;i class=""&gt;$&amp;gt; lsnrctl&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;LSNRCTL&amp;gt; set current_listener listener_name &lt;listener_name&gt;
LSNRCTL&amp;gt; show log_file
LSNRCTL&amp;gt; set log_file xxx.log&lt;new file="" log="" name=""&gt;
LSNRCTL&amp;gt; show log_file
LSNRCTL&amp;gt; exit&amp;nbsp;&lt;/new&gt;&lt;/listener_name&gt;&lt;/pre&gt;&lt;pre&gt;&lt;listener_name&gt;&lt;new file="" log="" name=""&gt;&amp;nbsp;&lt;/new&gt;&lt;/listener_name&gt;&lt;/pre&gt;&lt;i class=""&gt;$&amp;gt; remove or backup the old listener.log&lt;/i&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-4016049038451397769?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/CJO7xOj3916lwwPuLwHvFfUKVuo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/CJO7xOj3916lwwPuLwHvFfUKVuo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/CJO7xOj3916lwwPuLwHvFfUKVuo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/CJO7xOj3916lwwPuLwHvFfUKVuo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/xzV-ksjzGdc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/4016049038451397769/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=4016049038451397769" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/4016049038451397769?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/4016049038451397769?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/xzV-ksjzGdc/tip27-listener-log-file-too-big.html" title="Tip#27 Listener Log File Too Big" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2010/08/tip27-listener-log-file-too-big.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUYBSX8-eip7ImA9WxNXE0Q.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-7633762950018951497</id><published>2009-10-01T13:22:00.004+02:00</published><updated>2009-10-01T13:39:18.152+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-10-01T13:39:18.152+02:00</app:edited><title>Tip#26 OMS generates lot of core.xxx files</title><content type="html">Recently we had  disk full issue on our Grid Control OMS server, firstly we thought it must be just few backup copies which are lying around. After cleaning up the disk of unwanted backups got some breathing space (atleat thats what we thought!) but soon found out it is full again in like an hour.&lt;br /&gt;&lt;br /&gt;So digging further found out that OMS was generating HUGE amount of logs (like core.xxx) and at very brisk speed too.  Metalink Doc ID 419999.1 says it is due to "the access_log for the http server of the OMS is over 2Gb in size and this is causing the http server to core dump." and to fix it we need to stop all OMS process, remove the log file and startup the OMS process.  So basically,&lt;br /&gt;&lt;br /&gt;&lt;oms_home&gt;/opmn/bin/opmnctl stopall&lt;br /&gt;&lt;br /&gt;rm &lt;oms_home&gt;/Apache/Apache/logs/access_log&lt;br /&gt;&lt;br /&gt;&lt;oms_home&gt;/opmn/bin/opmnctl startall&lt;br /&gt;&lt;br /&gt;After doing that all seems to be back to normal. To avoid the same in future, as suggested in the metalink, Consider rotating the Apache logs on a regular basis as part of the routine maintenance of the system.  This can be done while the OMS is down during monthly maintenance tasks.&lt;br /&gt;&lt;span style="font-family:helvetica;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/oms_home&gt;&lt;/oms_home&gt;&lt;/oms_home&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-7633762950018951497?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/eerge3f-wyJhA2E432zyT68VD5s/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/eerge3f-wyJhA2E432zyT68VD5s/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/eerge3f-wyJhA2E432zyT68VD5s/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/eerge3f-wyJhA2E432zyT68VD5s/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/CaZGmTvfM5M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/7633762950018951497/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=7633762950018951497" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/7633762950018951497?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/7633762950018951497?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/CaZGmTvfM5M/tip-26-oms-generates-lot-of-corexxx.html" title="Tip#26 OMS generates lot of core.xxx files" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2009/10/tip-26-oms-generates-lot-of-corexxx.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUcBSH0zeCp7ImA9WxJUFko.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-1160697161619830272</id><published>2009-07-15T17:34:00.003+02:00</published><updated>2009-07-15T17:50:59.380+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-15T17:50:59.380+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Admin" /><title>Tip#25 Fix for ORA-38029 : object statistics are locked</title><content type="html">Recently while analyzing tables in one of our test database, we got &lt;span style="font-weight: bold;"&gt;ORA-38029: object statistics are locked&lt;/span&gt;. It turns out that in 10gR2, when you import (imp or impdp) table without data i.e. structure only, oracle will lock the table statistics. (ref : metalink doc id 433240.1)&lt;br /&gt;&lt;br /&gt;You can see list of all locked tables in a schema by running following query:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;select table_name, stattype_locked from dba_tab_statistics where owner = 'MBS' and stattype_locked is not null;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To generate unlock statement for all tables in the schema you can use following,&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;select 'exec DBMS_STATS.UNLOCK_TABLE_STATS ('''|| owner ||''','''|| table_name ||''');' from dba_tab_statistics where owner = 'MBS' and stattype_locked is not null;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;OR for each table individually the following,&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;exec DBMS_STATS.UNLOCK_TABLE_STATS('owner','table name');&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-1160697161619830272?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/8d3WS29phLnWpvlRFBPEu-YFdtk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8d3WS29phLnWpvlRFBPEu-YFdtk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/8d3WS29phLnWpvlRFBPEu-YFdtk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8d3WS29phLnWpvlRFBPEu-YFdtk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/uv3fvpZCzXc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/1160697161619830272/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=1160697161619830272" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/1160697161619830272?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/1160697161619830272?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/uv3fvpZCzXc/tip-25-fix-for-ora-38029-object.html" title="Tip#25 Fix for ORA-38029 : object statistics are locked" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>2</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2009/07/tip-25-fix-for-ora-38029-object.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUcBSH0zeCp7ImA9WxJUFko.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-5084744223721924945</id><published>2009-06-17T12:23:00.002+02:00</published><updated>2009-07-15T17:50:59.380+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-15T17:50:59.380+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Admin" /><title>Tip#24 Fix for ORA-12545 on RAC</title><content type="html">We had a case recently with a 10gR2 RAC, Some clients getting ORA-12545 errors i.e. ORA-12545 Connect failed because target host or object does not exist. TNS and Listener entries were all fine and TNSPING was also working so it had to be something else.&lt;br /&gt;&lt;br /&gt;On digging further and googling a bit it turned out that root cause was that the client was being redirected to the server hostname instead of virtual addresses.  Due to that the client had to resolve the server hostname and in some cases it could not ( e.g. no entry in their DNS &amp;amp; client Host file), hence the error.  Here is the link where it is nicely explained &lt;a href="http://tardate.blogspot.com/2007/06/check-locallistener-if-you-run-rac.html"&gt;Link&lt;/a&gt; .&lt;br /&gt;&lt;br /&gt;Hence two thing needed to be fixed,&lt;br /&gt;&lt;br /&gt;1) Client should have been pointed(redirected) to Virtual address and not real host names&lt;br /&gt;2) Client should be able to resolve virtual address&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Point 1&lt;/span&gt; can be fixed by setting up LOCAL_LISTENER parameter on all RAC nodes. Here is how,&lt;br /&gt;&lt;br /&gt;Add entry in TNSnames.ora on each node e.g. on Node 1&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;LISTENER_NODE1 = &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt; (ADDRESS_LIST = &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;  (ADDRESS = (PROTOCOL = TCP)(HOST = &lt;node1-vip.domain.com&gt;)(PORT =1521)) &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt; ) &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;set local listner for each node,&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;Alter system set LOCAL_LISTENER= 'LISTENER_NODE1' scope=both sid='SID1';&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Repeat above steps on each node with respective host &amp;amp; tns name.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Point 2&lt;/span&gt; can be fixed by either add DNS entry for the host names or if not possible, add entry in Client's host file e.g. on Linux add entry in /etc/hosts or on Windows add entry in windows\system32\drivers\etc\hosts.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-5084744223721924945?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/au0V1TNPWEKEn_JQPZlq-DVlcus/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/au0V1TNPWEKEn_JQPZlq-DVlcus/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/au0V1TNPWEKEn_JQPZlq-DVlcus/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/au0V1TNPWEKEn_JQPZlq-DVlcus/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/LLu9kwhpXEI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/5084744223721924945/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=5084744223721924945" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/5084744223721924945?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/5084744223721924945?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/LLu9kwhpXEI/tip24-fix-for-ora-12545-on-rac.html" title="Tip#24 Fix for ORA-12545 on RAC" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>2</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2009/06/tip24-fix-for-ora-12545-on-rac.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0QNQX47cSp7ImA9WxJXEEk.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-4861428198009328943</id><published>2009-06-03T16:52:00.004+02:00</published><updated>2009-06-03T18:09:50.009+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-03T18:09:50.009+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="OS" /><title>Tip#23   2&gt;&amp;1  and Argument list too long</title><content type="html">What does 2&gt;&amp;amp;1 mean?&lt;br /&gt;&lt;br /&gt;Sometimes I call my SQL script via shell script which generally have this kind of statement in it,&lt;br /&gt;&lt;br /&gt;$SCRIPTDIR/run_me.sh 2&gt;&amp;amp;1 &gt; $LOGDIR/log_me.log&lt;br /&gt;&lt;br /&gt;What above statement does for me is, it runs run_me.sh script from my script folder and logs the detail in files called log_me.log in my log folder.  Over here what I am interested in is what is  2&gt;&amp;amp;1. Well firstly let me define three data streams in linux i.e.  STDIN, STDOUT, and STDERR,&lt;br /&gt;&lt;br /&gt;STDIN : Standard input usually comes from the keyboard or from another program&lt;br /&gt;&lt;br /&gt;STDOUT : The program usually prints to standard output&lt;br /&gt;&lt;br /&gt;STDERR : The program sometimes prints to standard error&lt;br /&gt;&lt;br /&gt;In Linux/Unix,  The built-in numberings for them are 0, 1, and 2, in that order.&lt;br /&gt;&lt;br /&gt;The command above is  redirecting standard error into standard output (you have to put an &amp;amp; in front of the destination when you do this) and redirecting standard output into my log file, which is a place I want to  dump anything my scripts writes out.&lt;br /&gt;&lt;br /&gt;So effectively, all output from this command should be logged into my log file.  So in case of any issue I can always look at the log to find out the trouble area.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;--------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Sometimes there will be cases where a directory is filled with lots of files e.g. dump directory with lots of trace file. In such case when I tried following,&lt;br /&gt;&lt;br /&gt;/bin/rm *.trc&lt;br /&gt;&lt;br /&gt;I got following error message:&lt;br /&gt;&lt;br /&gt;bash: /bin/rm: Argument list too long&lt;br /&gt;&lt;br /&gt;Solution:&lt;br /&gt;&lt;br /&gt;find . -name "*.trc"|  xargs /bin/rm.&lt;br /&gt;&lt;br /&gt;Depending on the number of files, after a while all files will be erased.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-4861428198009328943?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ovZlGA8uiEb1bIj-jxwMcNQhZ-c/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ovZlGA8uiEb1bIj-jxwMcNQhZ-c/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ovZlGA8uiEb1bIj-jxwMcNQhZ-c/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ovZlGA8uiEb1bIj-jxwMcNQhZ-c/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/BoJ06wCPHJE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/4861428198009328943/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=4861428198009328943" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/4861428198009328943?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/4861428198009328943?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/BoJ06wCPHJE/tip23-2-and-argument-list-too-long.html" title="Tip#23   2&gt;&amp;1  and Argument list too long" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2009/06/tip23-2-and-argument-list-too-long.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0MGQX04fCp7ImA9WxJXEEk.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-2364358597520259169</id><published>2009-06-03T12:44:00.001+02:00</published><updated>2009-06-03T18:10:20.334+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-03T18:10:20.334+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Admin" /><title>Tip#22 Fix for ORA-01882</title><content type="html">ORA-01882: timezone region %s not found&lt;br /&gt;&lt;br /&gt;Recently we got this error while running via TOAD&lt;br /&gt;&lt;br /&gt;select * from dba_scheduler_jobs;&lt;br /&gt;&lt;br /&gt;The error message itself turns out not very informative.&lt;br /&gt;&lt;br /&gt;01882, 00000, "timezone region %s not found"&lt;br /&gt;// *Cause: The specified region name was not found.&lt;br /&gt;// *Action: Please contact Oracle Customer Support.&lt;br /&gt;&lt;br /&gt;In short, the error is because there are 7 timezone region IDs changed from version 3 and above. If you have old Timezone data from Version 2 that using one of these IDs the error raises.&lt;br /&gt;&lt;br /&gt;In our case, server had time zone files were already upgraded so running same query on the DB server was working fine. So to fix it we had fix it on the client side,&lt;br /&gt;&lt;br /&gt;1) Download patch 5731535 for a 10.2.0.X client ( 10.2.0.1 to 10.2.0.3)&lt;br /&gt;&lt;br /&gt;2)  Copy the 2 .dat files located at Client_patch\5731535\files\oracore\zoneinfo and the readme.txt file into the %ORACLE_HOME%\oracore\zoneinfo directory on your oracle client.&lt;br /&gt;&lt;br /&gt;3) restart the TOAD&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Ref : Metalink Doc ID:     414590.1 and 417893.1&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-2364358597520259169?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ytlZtzcppXL7Cq4IHVxMuBRG9mg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ytlZtzcppXL7Cq4IHVxMuBRG9mg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ytlZtzcppXL7Cq4IHVxMuBRG9mg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ytlZtzcppXL7Cq4IHVxMuBRG9mg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/aAO5a6FWYBk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/2364358597520259169/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=2364358597520259169" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/2364358597520259169?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/2364358597520259169?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/aAO5a6FWYBk/tip22-fix-for-ora-01882.html" title="Tip#22 Fix for ORA-01882" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2009/06/tip22-fix-for-ora-01882.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0MGQX04fCp7ImA9WxJXEEk.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-859417707706046143</id><published>2009-04-03T18:47:00.002+02:00</published><updated>2009-06-03T18:10:20.334+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-03T18:10:20.334+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Admin" /><title>Tip#21 DB Link Name Suffix</title><content type="html">Recently came across installations where all DB link were having suffix US.ORACLE.COM or REGRESS.RDBMS.DEV.US.ORACLE.COM and was bit annoying for users so here is how we went forward to fix it.&lt;br /&gt;&lt;br /&gt;As per documentation , whenever we create DB link, the db_domain is automatically appended to it. So following SQL should help determines naming of all DB links,&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;select name,value from v_$parameter where name IN ('db_name', 'db_domain');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;db_name = MYDB&lt;br /&gt;db_domain = NULL&lt;br /&gt;&lt;br /&gt;So in our case db_domain was NULL then where does US.ORACLE.COM or REGRESS.RDBMS.DEV.US.ORACLE.COM come form, lets check the global name, in case you dont know, GLOBAL_NAME = db_name.db_domain&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;select global_name from global_name;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;global_name = MYDB.US.ORACLE.COM&lt;br /&gt;&lt;br /&gt;hmm so global name does show me domain name now, how do I fix it?&lt;br /&gt;&lt;br /&gt;Option 1 :&lt;br /&gt;&lt;br /&gt;Rename global name with desired domain name e.g. MYWORLD&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;alter database rename global_name to MYDB.MYWORLD;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Please note with above alter statement, you MUST specify db_domain else it wont work.&lt;br /&gt;&lt;br /&gt;Option 2 :&lt;br /&gt;&lt;br /&gt;In case you dont wont any domain, Update global name to db_name without db_domain&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;UPDATE GLOBAL_NAME  SET GLOBAL_NAME = 'MYDB';&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;commit;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now cross check the changes,&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;select global_name from global_name ;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;global_name = MYDB&lt;br /&gt;&lt;br /&gt;Now you can go and create DB link as any user and it will be as expected i.e. with desired suffix or without.&lt;br /&gt;&lt;br /&gt;While we are on DB link topic, please note global_name &lt;&gt; global_names i.e.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Global Name&lt;/span&gt; is global name of the DB determined by db_name.db_domain&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Global Names&lt;/span&gt; is a parameter which determines whether DB link should always be named AFTER the global name of the database it connects to. You can set parameter value to be TRUE or FALSE (default) . If you have a replication environment then it is in general a good thing to set it to true.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-859417707706046143?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/QHErR5imQo89Ep_-Xq-ypGVnIi4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/QHErR5imQo89Ep_-Xq-ypGVnIi4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/QHErR5imQo89Ep_-Xq-ypGVnIi4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/QHErR5imQo89Ep_-Xq-ypGVnIi4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/A-FVyIuXuSo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/859417707706046143/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=859417707706046143" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/859417707706046143?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/859417707706046143?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/A-FVyIuXuSo/tip21-db-link-name-suffix.html" title="Tip#21 DB Link Name Suffix" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>3</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2009/04/tip21-db-link-name-suffix.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0MGQX04fSp7ImA9WxJXEEk.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-740049767438066782</id><published>2009-03-23T12:55:00.002+01:00</published><updated>2009-06-03T18:10:20.335+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-03T18:10:20.335+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Admin" /><title>Tip#20 Session Marked for Kill Forever</title><content type="html">I had a situation recently where our junior DBA accidentally killed an MV refresh job session and session killed was 'marked for kill' forever i.e. it wont release the resource (in this case lock) hence any subsequent refresh were also failing.&lt;br /&gt;&lt;br /&gt;Lock holding session can be determined by,&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;select SID from v$lock where ID1 = (select object_id from dba_objects where object_name = *Object name* and OWNER =  *Owner*)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Also any subsequent try to kill/disconnect session using alter session will result in ORA-00031: session marked for kill. So only way to release resources is to kill the process at OS level and let the PMON do the cleanup.&lt;br /&gt;&lt;br /&gt;Now since sessoin is already killed and we are not yet using 11g (which gives you OS PID after killing as well), I tried getting OS PID using following SQL (Also suggest to read Metalink Doc ID 1020720.102) i.e.&lt;br /&gt;&lt;br /&gt;SQL&gt;&lt;span style="color: rgb(153, 51, 153);"&gt; SELECT spid FROM v$process &lt;/span&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;WHERE NOT EXISTS ( SELECT 1 FROM v$session  WHERE paddr = addr)&lt;/span&gt;  &lt;span style="color: rgb(153, 51, 153);"&gt;AND spid IS NOT NULL;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;unfortunately this didnt help as PID returned was not JOB process, you can check on Linux using,&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;% ps -ef | grep spid&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The process I was expecting to be something like ora_j00x_sid but didnt found any so search for OS PID was still on.&lt;br /&gt;&lt;br /&gt;Since we still have an entry in v$session with 'KILLED' status, we decided to get a 'Logon time' and see if we can match that with OS PID for same time and  with command format 'ora_j00x_sid'. And fortunately we had hit the bulls eye we had only one OS PID with same time and expected command so we could just easily nailed it. So we killed the process at OS level&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;% kill  spid&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;and after few moments we could see the lock was released!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-740049767438066782?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/VqgvcSXdqy0wNOlBCgKDKe2Qivw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/VqgvcSXdqy0wNOlBCgKDKe2Qivw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/VqgvcSXdqy0wNOlBCgKDKe2Qivw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/VqgvcSXdqy0wNOlBCgKDKe2Qivw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/hojUdXnVfiw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/740049767438066782/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=740049767438066782" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/740049767438066782?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/740049767438066782?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/hojUdXnVfiw/tip20-session-marked-for-kill-forever.html" title="Tip#20 Session Marked for Kill Forever" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2009/03/tip20-session-marked-for-kill-forever.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUcMQHk7eSp7ImA9WxJUFko.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-6416812507074336065</id><published>2009-03-11T13:02:00.003+01:00</published><updated>2009-07-15T17:51:21.701+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-15T17:51:21.701+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Admin" /><category scheme="http://www.blogger.com/atom/ns#" term="Developer" /><title>Tip#19 Oracle Date Insight</title><content type="html">Note : Partial text from Metalink Note:69028.1&lt;br /&gt;&lt;br /&gt;Oracle DATE values are always stored in 7 bytes, excluding the length byte, within a datafile. These bytes store the century, year, month, day, hour, minute, and second details respectively. The following is the definition of Oracle's internal DATE storage structure:&lt;br /&gt;&lt;br /&gt;BYTE Meaning&lt;br /&gt;---- -------&lt;br /&gt;1 Century -- stored in excess-100 notation&lt;br /&gt;2 Year    --       "                "&lt;br /&gt;3 Month   -- stored in 0 base notation&lt;br /&gt;4 Day     --    "                   "&lt;br /&gt;5 Hour    -- stored in excess-1 notation&lt;br /&gt;6 Minute  --    "                   "&lt;br /&gt;7 Second  --    "                   "&lt;br /&gt;&lt;br /&gt;Note that the century and year components are stored in 'excess 100 format', which means that 100 must be deducted from the byte's value. If a negative number results, then we've got a BC date at which point we take the absolute number. Also, to avoid ever having a zero byte, 1 is added to the hour, minute and second bytes. Therefore, 1 must be detected to get the correct value.&lt;br /&gt;&lt;br /&gt;For example, take the following date:&lt;br /&gt;11-MAR-2009 13:08:00&lt;br /&gt;&lt;br /&gt;we would expect this date to be stored internally as follows:&lt;br /&gt;120,109,3,11,14,9,1&lt;br /&gt;&lt;br /&gt;Let's confirm this,&lt;br /&gt;&lt;br /&gt;SQL&gt;  create table test1 as select sysdate sd from dual;&lt;br /&gt;&lt;br /&gt;SQL&gt;  select to_char(sd, 'DD-MON-YYYY HH24:MI:SS'), dump(sd) from test1;&lt;br /&gt;&lt;br /&gt;Result:&lt;br /&gt;&lt;br /&gt;TO_CHAR(SD,'DD-MON-YYYYHH24:MI:SS')   : 11-MAR-2009 13:08:00&lt;br /&gt;&lt;br /&gt;DUMP(SD)  :   Typ=12 Len=7: 120,109,3,11,14,9,1&lt;br /&gt;&lt;br /&gt;Let's try using the DUMP() function to do the same thing with TO_DATE now. Issue the following statement:&lt;br /&gt;&lt;br /&gt;SQL&gt; SELECT dump(to_date('11-MAR-2009 13:08:00', 'DD-MON-YYYY HH24:MI:SS'))&lt;br /&gt;FROM dual;&lt;br /&gt;&lt;br /&gt;Result: Typ=13 Len=8: 217,7,3,11,13,8,0,0&lt;br /&gt;&lt;br /&gt;Note the different  "Typ=" values to understand why we are seeing these results. The datatype returned is 13 and not 12, the external DATE datatype. This occurs because we rely on the TO_DATE function! External datatype 13 is an internal c-structure whose length varies depending on how the c-compiler represents the structure. Note that the "Len=" value is 8 and not 7. Type 13 is not a part of the published 3GL interfaces for Oracle and is used for date calculations mainly within PL/SQL operations.&lt;br /&gt;&lt;br /&gt;Note that the same result can be seen when DUMPing the value SYSDATE.&lt;br /&gt;&lt;br /&gt;Using deductive logic, we can derive the following storage format for type 13 data:&lt;br /&gt;&lt;br /&gt;Byte 1 - Base 256 year modifier&lt;br /&gt;2      - Base 256 year&lt;br /&gt;3      - Month&lt;br /&gt;4      - Day&lt;br /&gt;5      - Hours&lt;br /&gt;6      - Minutes&lt;br /&gt;7      - Seconds&lt;br /&gt;8      - Unused&lt;br /&gt;&lt;br /&gt;For AD dates, the year and base 256 modifier are stored in base 0 notation and we must add the modifier to the year to obtain the true year. For BC dates, the year and base 256 modifier are stored in excess-255 notation. We must subtract the modifier from the year to obtain the true year.&lt;br /&gt;&lt;br /&gt;For our year 2009, we could read this to be, Byte 1 + Byte 2 * 256. In other words, 217 + 7 * 256 = 2009.&lt;br /&gt;&lt;br /&gt;Oracle is capable of handling dates from 01-JAN-4712 BC 00:00:00 TO 31-DEC-9999 AD 23:59:59 AD  OR  in terms of Julian Day: 1  through  Julian Day: 5373484&lt;br /&gt;&lt;br /&gt;The Julian Day number is a count of days elapsed since Greenwich mean noon on 1 January 4712 B.C. in the Julian proleptic calendar. The Julian Date is the Julian Day number followed by the fraction of the day elapsed since the preceding noon.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-6416812507074336065?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/xeBfwYlaei5NeRjWivtoIejbQ5U/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/xeBfwYlaei5NeRjWivtoIejbQ5U/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/xeBfwYlaei5NeRjWivtoIejbQ5U/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/xeBfwYlaei5NeRjWivtoIejbQ5U/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/V-j6t8FI600" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/6416812507074336065/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=6416812507074336065" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/6416812507074336065?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/6416812507074336065?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/V-j6t8FI600/tip19-oracle-date-insight.html" title="Tip#19 Oracle Date Insight" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2009/03/tip19-oracle-date-insight.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE8ERHY7fSp7ImA9WxBVGU4.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-4651630987888479957</id><published>2009-02-16T15:52:00.005+01:00</published><updated>2010-02-23T14:46:45.805+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-02-23T14:46:45.805+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Admin" /><title>Tip#18 Rebuilding A Table</title><content type="html">The DBA may have to rebuild a table after maintenance e.g. after a huge delete would like to lower the High Water Mark (HWM). There are several options to do it,&lt;br /&gt;&lt;br /&gt;Option 1: Export and Import the table&lt;br /&gt;Option 2: CTAS - Create table as Select&lt;br /&gt;Option 3: Alter table MOVE (&gt; 8.1.6)&lt;br /&gt;Optoin 4: Alter table SHRINK (&gt; 10g )&lt;br /&gt;&lt;br /&gt;First two option are fairly straight forward so I wont go in the details here.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;ALTER TABLE MOVE&lt;/span&gt; :&lt;br /&gt;&lt;br /&gt;This one is my preferred option compare to the first two (if not already on 10g or above) and would like to point out few facts.&lt;br /&gt;&lt;br /&gt;The ALTER TABLE MOVE command was implemented in 8.1.6. The command will allow tables to be moved from one tablespace to another, reorganise a table, provide the ability to modify of the INITIAL parameter. Also note that we don't lose grants (unlike CTAS), above all it is easy and fast.&lt;br /&gt;&lt;br /&gt;Although it has a drawback, please note that when you use it, all the indices on the table become invalid, have to do an ALTER INDEX REBUILD.&lt;br /&gt;&lt;br /&gt;e.g. I have a large table MBS with 50 million rows and now due to some process change I need to delete 25 million rows. After such huge delete obviously I would like to lower the HWM to avoid scanning those empty blocks below HWM.&lt;br /&gt;&lt;br /&gt;Since I dont want to change the tablespace or initial parametere I would simply execute this,&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;Alter table MBS move;&lt;/span&gt; --tablespace test_tbs pctfree 20 pctused 40;&lt;br /&gt;&lt;br /&gt;Since indices on the table will become invalid, I will also need to do this,&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;SELECT   index_name  FROM   user_indexes  WHERE   table_name = 'MBS';&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Once you know the indices used by the table just rebuild each of them as shown below,&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;Alter index pk_mbs rebuild;&lt;/span&gt; -- unrecoverable; --to avoid generating redo&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;ALTER TABLE SHRINK&lt;/span&gt; :&lt;br /&gt;&lt;br /&gt;If you are on 10g or above, both of the above mentioned steps (table move and index rebuild) are done using single statement using SHRINK option.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;alter table MBS enable row movement;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;alter table MBS shrink space cascade;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;alter table MBS disable row movement;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Just for comparison of Alter table options,&lt;br /&gt;&lt;br /&gt;1.) &lt;span style="font-weight: bold;"&gt;deallocate unused&lt;/span&gt; : claims back unused space above HWM and doesnt lowers the HWM.&lt;br /&gt;2.) &lt;span style="font-weight: bold;"&gt;move&lt;/span&gt; : claims back unused space below HWM and lowers the HWM&lt;br /&gt;3.) &lt;span style="font-weight: bold;"&gt;shrink &lt;/span&gt;: claims back unused space below and above HWM and lowers the HWM&lt;br /&gt;&lt;br /&gt;This blog was intended to just give you an overview, for more details on both the command please refer to the documentation.   Also as usual always do backup before and after the changes.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-4651630987888479957?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/hs67C_ncYbe9Byiyq490DdRMCXk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hs67C_ncYbe9Byiyq490DdRMCXk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/hs67C_ncYbe9Byiyq490DdRMCXk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hs67C_ncYbe9Byiyq490DdRMCXk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/5hr01_KMNsg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/4651630987888479957/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=4651630987888479957" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/4651630987888479957?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/4651630987888479957?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/5hr01_KMNsg/tip18-rebuilding-table.html" title="Tip#18 Rebuilding A Table" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2009/02/tip18-rebuilding-table.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUcNQX05cCp7ImA9WxJUFko.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-4552717645143452320</id><published>2008-07-30T15:22:00.005+02:00</published><updated>2009-07-15T17:51:30.328+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-15T17:51:30.328+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="OS" /><category scheme="http://www.blogger.com/atom/ns#" term="Admin" /><title>Tip#17 How to find out 32/64 Bit</title><content type="html">&lt;span style="font-weight: bold;"&gt;Find out whether OS is 32 bit or 64 bit&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Linux&lt;/span&gt;   : getconf LONG_BIT&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Solaris&lt;/span&gt; : /usr/bin/isainfo -kv&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;AIX&lt;/span&gt;     : getconf -a | grep KERN&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;HPUX&lt;/span&gt;    : /usr/bin/getconf KERNEL_BITS&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Windows&lt;/span&gt; : Start&gt;All Programs&gt;accessories&gt; System Tools&gt;System Information&gt;   System summary&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Find out whether Oracle Software is 32 bit or 64 bit.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Method # 1&lt;/span&gt;&lt;br /&gt;cd $ORACLE_HOME/bin/&lt;br /&gt;file oracle&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Method # 2&lt;/span&gt;&lt;br /&gt;sqlplus / as sysdba (Look for "Connected to:")&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Method # 3&lt;/span&gt;&lt;br /&gt;If the two directories $ORACLE_HOME/lib32 and $ORACLE_HOME/lib are existing then it is 64 bit else 32 bit&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-4552717645143452320?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/DIO8juyI9VMGHkEGEJqDpU8_wPo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/DIO8juyI9VMGHkEGEJqDpU8_wPo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/DIO8juyI9VMGHkEGEJqDpU8_wPo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/DIO8juyI9VMGHkEGEJqDpU8_wPo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/Q_ynp8WW6c0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/4552717645143452320/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=4552717645143452320" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/4552717645143452320?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/4552717645143452320?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/Q_ynp8WW6c0/tip17-how-to-find-out-3264-bit.html" title="Tip#17 How to find out 32/64 Bit" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2008/07/tip17-how-to-find-out-3264-bit.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0MGQX04fSp7ImA9WxJXEEk.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-5213972475607162003</id><published>2008-07-07T15:24:00.005+02:00</published><updated>2009-06-03T18:10:20.335+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-03T18:10:20.335+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Admin" /><title>Tip#16 Fix Migrated/Chained rows</title><content type="html">&lt;span style="font-weight: bold;"&gt;What do they mean?&lt;br /&gt;&lt;br /&gt;Row chaining&lt;/span&gt; is what happens when a row cannot fit into a single Oracle block ever, because it is just too big. Oracle therefore has to break it up into several smaller row pieces, store each piece in a separate block, and link (or “chain”) from one block to another so that the entire set of pieces can be retrieved when you query the table for the row.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Row migration&lt;/span&gt; is what happens when a row grows in size and can no longer fit into its original Oracle block: Oracle will move it (or ‘migrate’ it) into a completely new block into which it can fit.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;How to Find them?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Assuming you have latest stats for the tables, run following SQL to find out if you have any tables with high percentage of chained or migrated rows in a table.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;SELECT owner, table_name, num_rows, chain_cnt, &lt;/span&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;&lt;br /&gt;                 round((chain_cnt * 100 / num_rows),2) pct, &lt;/span&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;pct_free, pct_used&lt;/span&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;&lt;br /&gt;   FROM dba_tables&lt;/span&gt;&lt;span style="color: rgb(102, 0, 204);"&gt; WHERE chain_cnt &gt; 0&lt;/span&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;&lt;br /&gt;     AND owner NOT IN ('SYS', 'SYSTEM')&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt; ORDER BY 5 desc   ;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you have any tables with large number of chained/migrated rows then follow the below steps to fix it,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;How do I fix them?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1. connect to the database as the owner of the table having chained rows run utlchain.sql script which is in your ORACLE_HOME/rdbms/admin. It should create a table called 'chained_rows'.&lt;br /&gt;&lt;br /&gt;2. Analyze the table suppose that the table having the issue is called: MBS&lt;br /&gt;&lt;br /&gt;SQL&gt;analyze table MBS list chained rows into chained_rows;&lt;br /&gt;&lt;br /&gt;3.  The above statement will load the chained row information into the table created in step 1&lt;br /&gt;&lt;br /&gt;SQL&gt;select * from chained_rows;&lt;br /&gt;&lt;br /&gt;4. To fix the rows, put them in a temp table and remove it from original table and copy them from temp table to original table&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;create table my_tmp AS&lt;/span&gt; &lt;span style="color: rgb(102, 0, 204);"&gt;select * from mbs where&lt;/span&gt; &lt;span style="color: rgb(102, 0, 204);"&gt;rowid IN (select head_rowid from chained_rows where table_name = 'MBS');&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;DELETE FROM MBS&lt;/span&gt; &lt;span style="color: rgb(102, 0, 204);"&gt;WHERE rowid IN (select head_rowid from chained_rows where table_name = 'MBS');&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;INSERT INTO MBS SELECT * FROM my_tmp;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;COMMIT;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Any Suggestion to avoid it?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Increase PCTFREE to avoid the future problem for those tables.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-5213972475607162003?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/uE44xyZxkFzZYWS22DF0VV92CNE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/uE44xyZxkFzZYWS22DF0VV92CNE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/uE44xyZxkFzZYWS22DF0VV92CNE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/uE44xyZxkFzZYWS22DF0VV92CNE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/iN1WRBh1qxY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/5213972475607162003/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=5213972475607162003" title="9 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/5213972475607162003?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/5213972475607162003?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/iN1WRBh1qxY/tip16-fix-migratedchained-rows.html" title="Tip#16 Fix Migrated/Chained rows" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>9</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2008/07/tip16-fix-migratedchained-rows.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0MGQX04fSp7ImA9WxJXEEk.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-5253095403356557306</id><published>2008-07-03T14:16:00.002+02:00</published><updated>2009-06-03T18:10:20.335+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-03T18:10:20.335+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Admin" /><title>Tip#15 DBFile Sequential and Scattered Reads</title><content type="html">Both "db file sequential read" and "db file scattered read" events signify time waited for I/O read requests to complete.  Most people confuse these events with each other as they think of how data is read from disk. Instead they should think of how data is read into the SGA buffer cache.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;db file sequential read:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A sequential read operation reads data into contiguous memory (usually a single-block read with p3=1, but can be multiple blocks). Single block I/Os are usually the result of using indexes. This event is also used for rebuilding the controlfile and reading datafile headers (P2=1). In general, this event is indicative of disk contention on index reads.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;db file scattered read:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Similar to db file sequential reads, except that the session is reading multiple data blocks and scatters them into different discontinuous buffers in the SGA. This statistic is NORMALLY indicating disk contention on full table scans. Rarely, data from full table scans could be fitted into a contiguous buffer area, these waits would then show up as sequential reads instead of scattered reads.&lt;br /&gt;&lt;br /&gt;The following query shows average wait time for sequential versus scattered reads:&lt;br /&gt;&lt;br /&gt; &lt;span style="color: rgb(102, 0, 204);"&gt;select a.average_wait "SEQ READ", b.average_wait "SCAT READ"&lt;/span&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;&lt;br /&gt;from   sys.v_$system_event a, sys.v_$system_event b&lt;/span&gt; &lt;span style="color: rgb(102, 0, 204);"&gt;&lt;br /&gt;where  a.event = 'db file sequential read'&lt;/span&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;&lt;br /&gt;and    b.event = 'db file scattered read';&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-5253095403356557306?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ZbT4OBEmbc5g8JB2hrk0HACrLgE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ZbT4OBEmbc5g8JB2hrk0HACrLgE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ZbT4OBEmbc5g8JB2hrk0HACrLgE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ZbT4OBEmbc5g8JB2hrk0HACrLgE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/DODQrq4-TnQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/5253095403356557306/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=5253095403356557306" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/5253095403356557306?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/5253095403356557306?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/DODQrq4-TnQ/dbfile-sequential-and-scattered-reads.html" title="Tip#15 DBFile Sequential and Scattered Reads" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2008/07/dbfile-sequential-and-scattered-reads.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0MGQX04fSp7ImA9WxJXEEk.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-9135368479321813698</id><published>2008-06-30T16:56:00.002+02:00</published><updated>2009-06-03T18:10:20.335+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-03T18:10:20.335+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Admin" /><title>Tip#14 Resumable Space Allocation</title><content type="html">In the event of space allocation failures, rather than returning the error to the user and stopping the operation, the transaction can be temporarily suspended and corrective action taken. After the error condition is corrected, the suspended operation automatically resumes. This feature is called resumable space allocation. The affected statements are called resumable statements.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;When the execution of a resumable statement is suspended, the system issues a Resumable Session Suspended alert. A suspended operation is automatically aborted if the error condition is not fixed within the time-out period. By default, the time-out period is two hours. you can enable resumable space allocation either at the system level, by setting the RESUMABLE_TIMEOUT initialization parameter to a nonzero value, or at the session level, by issuing the ALTER SESSION ENABLE RESUMABLE statement. A resumable statement can be suspended and resumed multiple times during execution.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Which statements are resumable?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;• DML statements, including INSERT INTO ... SELECT from external tables, are resumable. &lt;br /&gt;• DDL statements, including CREATE TABLE ... AS SELECT, are resumable. &lt;br /&gt;• SELECT statements that run out of temporary space are also candidates for resumable execution.&lt;br /&gt;&lt;br /&gt;A resumable statement can be suspended under any of these conditions: &lt;br /&gt;&lt;br /&gt;• Space quota exceeded (e.g. The user has exceeded his or her assigned space quota in the tablespace), &lt;br /&gt;• Maximum extents reached (e.g. The number of extents in a table or index equals the number of maximum extents defined on the object.) &lt;br /&gt;• Out of space (e.g. The operation cannot acquire any more extents for an index in a tablespace.)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-9135368479321813698?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/u8PE5CsGlTr4BWYdUNuyNBpqSYQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/u8PE5CsGlTr4BWYdUNuyNBpqSYQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/u8PE5CsGlTr4BWYdUNuyNBpqSYQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/u8PE5CsGlTr4BWYdUNuyNBpqSYQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/8rAQENfmSg8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/9135368479321813698/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=9135368479321813698" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/9135368479321813698?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/9135368479321813698?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/8rAQENfmSg8/tip14-resumable-space-allocation.html" title="Tip#14 Resumable Space Allocation" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2008/06/tip14-resumable-space-allocation.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0MGQX04fSp7ImA9WxJXEEk.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-1725511373761871322</id><published>2008-05-28T16:49:00.009+02:00</published><updated>2009-06-03T18:10:20.335+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-03T18:10:20.335+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Admin" /><title>Tip#13   Big Vs Little Endian</title><content type="html">&lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size:11;"&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size:11;"&gt;&lt;b style=""&gt;Little Endian &lt;/b&gt;means that the low-order byte of the number is stored in memory at the lowest address, and the high-order byte at the highest address. (The little end comes first.) For example, a 4 byte LongInt&lt;br /&gt;&lt;br /&gt;Byte3 Byte2 Byte1 Byte0&lt;br /&gt;&lt;br /&gt;will be arranged in memory as follows:&lt;br /&gt;Base Address+0   Byte0&lt;br /&gt;Base Address+1   Byte1&lt;br /&gt;Base Address+2   Byte2&lt;br /&gt;Base Address+3   Byte3&lt;br /&gt;&lt;br /&gt;Linux, Windows use "Little Endian" byte order. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size:11;"&gt;&lt;b style=""&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:11;"&gt;&lt;b style=""&gt;Big Endian&lt;/b&gt; means that the high-order byte of the number is stored in memory at the lowest address, and the low-order byte at the highest address. (The big end comes first.) Our LongInt, would then be stored as:&lt;br /&gt;&lt;br /&gt;Base Address+0   Byte3&lt;br /&gt;Base Address+1   Byte2&lt;br /&gt;Base Address+2   Byte1&lt;br /&gt;Base Address+3   Byte0&lt;br /&gt;&lt;br /&gt;Solaris, HPUX, Apple Mac &lt;span style=""&gt; &lt;/span&gt;use "Big Endian" byte order.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;span style="font-size:11;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:11;"&gt;In Oracle 10g, &lt;span style=""&gt; &lt;/span&gt;following SQL should tell you &lt;span class="bodycopy"&gt;which operating systems follow which byte order,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;pre&gt;&lt;span style=""&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;select * from v$transportable_platform order by platform_id;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;    &lt;p class="MsoNormal"&gt;&lt;span style="font-size:11;"&gt;To transport tablespaces between OS with same byte orders (endianness), we don’t need conversion in other cases we do which can be done using RMAN. E.g. I need to transport a Tablespace from Linux (Little Endian) to Solaris (Big Endian)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;pre&gt;&lt;span style=""&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;RMAN&gt; convert tablespace XXX to&lt;/span&gt;&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;platform ‘Solaris[tm] OE (64-bit)' &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style=""&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;db_file_name_convert '/app/oracle/oradata/mbs’,&lt;/span&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;'/app/oracle/rman_bkups'&lt;/span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;    &lt;p class="MsoNormal"&gt;&lt;span class="bodycopy"&gt;&lt;span style="font-size:11;"&gt;Now this file can be copied over to the target Solaris system, and the rest of the steps are easy.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-1725511373761871322?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/RxEnsEGw4xv7bOnlDx6splkRv4w/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/RxEnsEGw4xv7bOnlDx6splkRv4w/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/RxEnsEGw4xv7bOnlDx6splkRv4w/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/RxEnsEGw4xv7bOnlDx6splkRv4w/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/Sqtqb-uVJCc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/1725511373761871322/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=1725511373761871322" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/1725511373761871322?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/1725511373761871322?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/Sqtqb-uVJCc/tip13-big-vs-little-endian.html" title="Tip#13   Big Vs Little Endian" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>2</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2008/05/tip13-big-vs-little-endian.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUYFQ3Y8eCp7ImA9WxZaE0U.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-6828254471280527473</id><published>2008-04-28T13:31:00.004+02:00</published><updated>2008-04-28T13:45:12.870+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-28T13:45:12.870+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Admin" /><title>Tip#12   STATUS column of dba_undo_extents</title><content type="html">I am sure you might have seen loads of information regarding how to resize/drop/recreate UNDO tablspace but point to note during dropping (ex-default/previous) UNDO tablespace is to check a view dba_undo_extents to see if any undo statments is still used by any session or needed for flashback. Following SQL should tell you if you can go ahead and drop the ex-default/previous UNDO tablespace or not (assuming undo tablespace I want to drop is UNDOTBS2),&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(102, 51, 102);"&gt;SELECT tablespace_name, status, COUNT (*)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 51, 102);"&gt;    FROM SYS.dba_undo_extents&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 51, 102);"&gt;   WHERE tablespace_name = 'UNDOTBS2'&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 51, 102);"&gt;GROUP BY tablespace_name, status&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;What is of our interest is &lt;span style="font-weight: bold;"&gt;status&lt;/span&gt; column of dba_undo_extents, 3 possible values - ACTIVE, EXPIRED, UNEXPIRED. What are the meanings ?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;ACTIVE &lt;/span&gt;means that this undo segment contains active transactions&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;EXPIRED &lt;/span&gt;means that this segment is not rqeuired at all after considering Undo retention period&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;UNEXPIRED&lt;/span&gt; means that this segment does not contain any active transactions but it contains transactions which are still required for Flashback option (after considering Undo retention period).&lt;br /&gt;&lt;br /&gt;So if you have all extents EXPIRED then go ahead and drop the tablespace, as usual make sure that you have done proper backup before and after.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-6828254471280527473?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/4p5o3e8wcWeIZ6_0TUp9Ch1_YLI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4p5o3e8wcWeIZ6_0TUp9Ch1_YLI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/4p5o3e8wcWeIZ6_0TUp9Ch1_YLI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4p5o3e8wcWeIZ6_0TUp9Ch1_YLI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/_ovbHeAPDVk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/6828254471280527473/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=6828254471280527473" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/6828254471280527473?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/6828254471280527473?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/_ovbHeAPDVk/tip12-status-column-of-dbaundoextents.html" title="Tip#12   STATUS column of dba_undo_extents" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>5</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2008/04/tip12-status-column-of-dbaundoextents.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0MAR3o7cCp7ImA9WxJXEEk.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-7769998051573990002</id><published>2008-04-09T17:50:00.005+02:00</published><updated>2009-06-03T18:10:46.408+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-03T18:10:46.408+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Admin" /><category scheme="http://www.blogger.com/atom/ns#" term="Developer" /><title>Tip#11 SQL*Plus - Ignore Blank Lines in the Script</title><content type="html">Recently I came across a situation where during our database deploy one of our View script was exiting in SQLplus due to a blank line inside the script. To fix it, we had to set sqlblanllines setting in sqlplus to ignore the blank lines and that did the trick for us.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;SQL&gt; create or replace view xx&lt;br /&gt;  2      as&lt;br /&gt;  3      select&lt;br /&gt;  4      sysdate as x&lt;br /&gt;  5&lt;br /&gt;SQL&gt;     from&lt;br /&gt;SP2-0042: unknown command "from" - rest of line ignored.&lt;br /&gt;SQL&gt;     dual&lt;br /&gt;SP2-0042: unknown command "dual" - rest of line ignored.&lt;br /&gt;SQL&gt; &lt;span style="font-weight: bold;"&gt;set sqlblanklines on&lt;/span&gt;&lt;br /&gt;SQL&gt; create or replace view xx&lt;br /&gt;  2      as&lt;br /&gt;  3      select&lt;br /&gt;  4      sysdate as x&lt;br /&gt;  5&lt;br /&gt;  6      from&lt;br /&gt;  7      dual&lt;br /&gt;  8  ;&lt;br /&gt;&lt;br /&gt;View created.&lt;br /&gt;&lt;br /&gt;SQL&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-7769998051573990002?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/lM8SjfHYF_se9JcvcMwQAE7CUbE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/lM8SjfHYF_se9JcvcMwQAE7CUbE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/lM8SjfHYF_se9JcvcMwQAE7CUbE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/lM8SjfHYF_se9JcvcMwQAE7CUbE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/0-h1iZ8WOFg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/7769998051573990002/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=7769998051573990002" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/7769998051573990002?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/7769998051573990002?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/0-h1iZ8WOFg/tip11-sqlplus-ignore-blank-lines-in.html" title="Tip#11 SQL*Plus - Ignore Blank Lines in the Script" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>3</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2008/04/tip11-sqlplus-ignore-blank-lines-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0MAR3o7cCp7ImA9WxJXEEk.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-9110877311916547591</id><published>2008-04-04T16:49:00.001+02:00</published><updated>2009-06-03T18:10:46.408+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-03T18:10:46.408+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Admin" /><category scheme="http://www.blogger.com/atom/ns#" term="Developer" /><title>Tip#10 Dump to text file using UTL_FILE</title><content type="html">Dump the data from table/sql to text file (CSV or PIPE delimated etc) on the server using UTL_FILE&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Note : &lt;/span&gt;&lt;br /&gt;A)  Specify the accessible directories for the UTL_FILE functions in the initialization file using the &lt;span style="color: rgb(51, 51, 255);"&gt;UTL_FILE_DIR&lt;/span&gt; parameter. e.g. :  UTL_FILE_DIR = /app/oracle/my_dir&lt;br /&gt;FYI, UTL_FILE_DIR = *  means turn off directory access checking, and it makes any directory accessible to the UTL_FILE (NOT RECOMMANDED).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;EDIT:&lt;/span&gt; if you are using &gt; 9i , you can use DIRECTORY instead of UTL_FILE_DIR.&lt;br /&gt;&lt;br /&gt;B) Since we have data with special character, we open file with &lt;span style="color: rgb(51, 51, 255);"&gt;FOPEN_NCHAR&lt;/span&gt; to make sure we don’t loose special characters in the text dump.&lt;br /&gt;&lt;br /&gt;C) I have just tested it on Redhat Linux - Oracle 9.2.0.6&lt;br /&gt;&lt;br /&gt;This is the Function which I use (adapted to my requirements but thanks to Tom Kyte to get me started)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;CREATE OR REPLACE FUNCTION dump_to_file (&lt;br /&gt;   p_query       IN   VARCHAR2,&lt;br /&gt;   p_separator   IN   VARCHAR2 DEFAULT '|',&lt;br /&gt;   p_dir         IN   VARCHAR2,&lt;br /&gt;   p_filename    IN   VARCHAR2&lt;br /&gt;)&lt;br /&gt;   RETURN NUMBER&lt;br /&gt;IS&lt;br /&gt;   l_filehandle    UTL_FILE.file_type;&lt;br /&gt;   l_thecursor     INTEGER            DEFAULT DBMS_SQL.open_cursor;&lt;br /&gt;   l_columnvalue   VARCHAR2 (32767);&lt;br /&gt;   l_col_hdr       VARCHAR2 (32767);&lt;br /&gt;   l_status        INTEGER;&lt;br /&gt;   l_colcnt        NUMBER             DEFAULT 0;&lt;br /&gt;   l_separator     VARCHAR2 (10)      DEFAULT '';&lt;br /&gt;   l_cnt           NUMBER             DEFAULT 0;&lt;br /&gt;   col_cnt         PLS_INTEGER;&lt;br /&gt;   rec_tab         DBMS_SQL.desc_tab;&lt;br /&gt;   col_num         NUMBER;&lt;br /&gt;BEGIN&lt;br /&gt;   -- open a writable file in the UTL_FILE_DIR directory&lt;br /&gt;   l_filehandle := UTL_FILE.fopen_nchar (p_dir, p_filename, 'w', 32767);&lt;br /&gt; &lt;br /&gt;   -- parse the sql we got&lt;br /&gt;   DBMS_SQL.parse (l_thecursor, p_query, DBMS_SQL.native);&lt;br /&gt; &lt;br /&gt;   -- execute the sql cursor&lt;br /&gt;   l_status := DBMS_SQL.EXECUTE (l_thecursor);&lt;br /&gt; &lt;br /&gt;   -- get the column information l_colcnt OUT param to get us number of columns&lt;br /&gt;   -- and rec_tab is plsql table with all column related information like name, length,schema, precision, scale etc&lt;br /&gt;   DBMS_SQL.describe_columns (l_thecursor, l_colcnt, rec_tab);&lt;br /&gt; &lt;br /&gt;   -- we need to print the column names as the first line  &lt;br /&gt;   l_separator := '';&lt;br /&gt;   l_col_hdr := '';&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;   FOR i IN 1 .. l_colcnt&lt;br /&gt;   LOOP&lt;br /&gt;       -- we define which columns we need in the fetch &lt;br /&gt;       DBMS_SQL.define_column (l_thecursor, i, l_columnvalue, 4000);&lt;br /&gt;       -- print the column name in the file&lt;br /&gt;       l_col_hdr := l_col_hdr || l_separator || rec_tab (i).col_name;&lt;br /&gt;       l_separator := p_separator;&lt;br /&gt;   END LOOP;&lt;br /&gt;&lt;br /&gt;   UTL_FILE.put_nchar (l_filehandle, l_col_hdr);&lt;br /&gt;   UTL_FILE.new_line (l_filehandle);&lt;br /&gt;&lt;br /&gt;   -- lets print the data now&lt;br /&gt;   LOOP&lt;br /&gt;       EXIT WHEN (DBMS_SQL.fetch_rows (l_thecursor) &lt;= 0);         l_separator := '';          FOR i IN 1 .. l_colcnt         LOOP             DBMS_SQL.COLUMN_VALUE (l_thecursor, i, l_columnvalue);             UTL_FILE.put_nchar (l_filehandle, l_separator || l_columnvalue);             l_separator := p_separator;         END LOOP;          UTL_FILE.new_line (l_filehandle);         l_cnt := l_cnt + 1;     END LOOP;      DBMS_SQL.close_cursor (l_thecursor);     UTL_FILE.fclose (l_filehandle);     RETURN l_cnt; EXCEPTION     WHEN UTL_FILE.invalid_operation     THEN         UTL_FILE.fclose (l_filehandle);         raise_application_error (-20061, 'Dump To File Error: Invalid Operation');     WHEN UTL_FILE.invalid_filehandle     THEN         UTL_FILE.fclose (l_filehandle);         raise_application_error (-20062, 'Dump To File Error: Invalid File Handle');     WHEN UTL_FILE.write_error     THEN         UTL_FILE.fclose (l_filehandle);         raise_application_error (-20063, 'Dump To File Error: Write Error');     WHEN OTHERS     THEN         UTL_FILE.fclose (l_filehandle);         RAISE; END dump_to_file;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;How to Use above function ?&lt;br /&gt;&lt;br /&gt;To generate pipe (‘ | ’) delimated  file called emp.txt  in /app/oracle/my_dir for my query, I execute something like following&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;DECLARE&lt;br /&gt;   l_rows   NUMBER         := 0;&lt;br /&gt;   l_dir    VARCHAR2 (100) := '/app/oracle/my_dir';&lt;br /&gt;BEGIN&lt;br /&gt;   l_rows := dump_to_file ('select * FROM scott.emp ', '|', l_dir, 'emp.txt');&lt;br /&gt;   DBMS_OUTPUT.put_line ('Number of rows dumped to emp.txt : ' || l_rows);&lt;br /&gt;END;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0); font-weight: bold;"&gt;EDIT:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;if you want to use DIRECTORY instead of UTL_FILE_DIR, just create one like following,&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;create or replace directory my_dir as '&lt;/span&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;/app/oracle/my_dir&lt;/span&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;';&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;then use above code with 'my_dir' instead of l_dir.&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-9110877311916547591?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/kOKxDT_F_i31vH8ZevpnghHtDUs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kOKxDT_F_i31vH8ZevpnghHtDUs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/kOKxDT_F_i31vH8ZevpnghHtDUs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kOKxDT_F_i31vH8ZevpnghHtDUs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/TTxTCBjFRkE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/9110877311916547591/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=9110877311916547591" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/9110877311916547591?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/9110877311916547591?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/TTxTCBjFRkE/tip10-dump-to-text-file-using-utlfile.html" title="Tip#10 Dump to text file using UTL_FILE" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2008/04/tip10-dump-to-text-file-using-utlfile.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0UMRHk7eip7ImA9WxZUEEs.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-7323053451580503426</id><published>2008-04-01T17:17:00.000+02:00</published><updated>2008-04-01T17:54:45.702+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-01T17:54:45.702+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="OS" /><category scheme="http://www.blogger.com/atom/ns#" term="Admin" /><title>Tip#9 Some OS utilities  (Unix)</title><content type="html">&lt;span style="font-weight: bold;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;NOHUP&lt;/span&gt; :&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;nohup&lt;/span&gt; (no hangups) is a UNIX command that allows you to execute a command in the background while you are logged into UNIX. The background process will continue to run until completion, even if you log off. For long running processes, this is a nice way to execute them. In my case, it allows me to log into a client server remotely, execute a process interactively with &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;nohup&lt;/span&gt;, and then disconnect. Another benefit of &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;nohup&lt;/span&gt; is that by default, a log of all activity is recorded in the current directory in the file &lt;span style="font-weight: bold;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;nohup&lt;/span&gt;.out&lt;/span&gt; . e.g.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;nohup&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;sqlplus&lt;/span&gt; user/&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;pwd&lt;/span&gt;  @&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;sqlscript&lt;/span&gt; &amp;amp;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note : &amp;amp; at the end is for running the process in the background&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;SKILL:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Sometime I have a situations where I find that a process is consuming a lot of CPU and memory, but I don't want to kill it and I just wished if I could just 'pause' the process and that's where SKILL really helps me. e.g Process ID 1234 is taking too much resources and I need to somehow get other 'important' things done I will execute following command,&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;skill -STOP 1234&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Once I have finished other 'important' things done I can free the process with following command&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;skill -CONT 1234&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The nice feature is you can pass not just &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;PID&lt;/span&gt; but also User, Terminal ID OR Command which makes it more powerful then I initially thought. e.g. You can 'pause' all &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;RMAN&lt;/span&gt; commands on DB server with&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;skill -STOP &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;rman&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;SNICE&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;The command &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;snice&lt;/span&gt; is similar to skill but Instead of stopping a process it makes its priority a lower one. e.g. for the same heavy process 1234 I could decrease the priority by using something like this,&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 204);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;snice&lt;/span&gt; +4 -p 1234&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note: +4 means we are increasing the Nice Value and effectively the higher the number, the lower the priority.&lt;br /&gt;&lt;br /&gt;This utility is quite useful in reducing priorities. &lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-7323053451580503426?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/KrTbGPwiiFgpgFc2wViEWZnlQig/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/KrTbGPwiiFgpgFc2wViEWZnlQig/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/KrTbGPwiiFgpgFc2wViEWZnlQig/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/KrTbGPwiiFgpgFc2wViEWZnlQig/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/R5qttaKHQHY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/7323053451580503426/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=7323053451580503426" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/7323053451580503426?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/7323053451580503426?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/R5qttaKHQHY/some-os-utilities-unix.html" title="Tip#9 Some OS utilities  (Unix)" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2008/04/some-os-utilities-unix.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A04AQXc4fSp7ImA9WxJVE0k.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-1411356700843354407</id><published>2007-09-26T13:37:00.002+02:00</published><updated>2009-06-30T10:19:00.935+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-30T10:19:00.935+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Developer" /><title>Tip#8 Cursor best practice</title><content type="html">&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size:10;"&gt;Cursor best practice&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/p&gt;  &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:10;"&gt;Oracle provides three possible way to loop through the cursor rows and these are, &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ol start="1" type="1"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:10;"&gt;loop      with explicit cursor i.e. OPEN, FETCH one row at a time and CLOSE&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/li&gt;&lt;/ol&gt;  &lt;ol start="2" type="1"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:10;"&gt;Using      cursor FOR-LOOP&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/li&gt;&lt;/ol&gt;  &lt;ol start="3" type="1"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:10;"&gt;Bulk      collect and then loop through the collection.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-size:10;color:red;"  &gt;Which of the above methods is most efficient for a cursor?&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;/p&gt;  &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:10;"&gt;Without a doubt, you should use &lt;b&gt;BULK COLLECT&lt;/b&gt; whenever possible to query information from your tables. It will be significantly faster than either a cursor FOR loop or loop with explicit cursor. However,  a BULK COLLECT of many rows can consume a large amount of memory. But you can balance memory utilization against performance improvements by using the &lt;b&gt;LIMIT&lt;/b&gt; clause with BULK COLLECT. Here's an example: &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;tt&gt;&lt;span style=";font-size:7;color:blue;"  &gt;DECLARE&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;    &lt;span style="color:blue;"&gt;CURSOR&lt;/span&gt; allrows_cur&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;    &lt;span style="color:blue;"&gt;IS&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;        &lt;span style="color:blue;"&gt;SELECT&lt;/span&gt; *&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;          &lt;span style="color:blue;"&gt;FROM&lt;/span&gt; order_header_scratch&lt;span style="color:blue;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;    &lt;span style="color:blue;"&gt;TYPE&lt;/span&gt; order_header_scratch_aat &lt;span style="color:blue;"&gt;IS&lt;/span&gt; &lt;span style="color:blue;"&gt;TABLE&lt;/span&gt; &lt;span style="color:blue;"&gt;OF&lt;/span&gt; order_header_scratch%&lt;span style="color:blue;"&gt;ROWTYPE&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;        &lt;span style="color:blue;"&gt;INDEX&lt;/span&gt; &lt;span style="color:blue;"&gt;BY&lt;/span&gt; &lt;span style="color:blue;"&gt;BINARY_INTEGER;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;    l_order_header_scratch   order_header_scratch_aat&lt;span style="color:blue;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;    l_row                    &lt;span style="color:blue;"&gt;PLS_INTEGER;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style=";font-size:7;color:blue;"  &gt;BEGIN&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;    &lt;span style="color:blue;"&gt;OPEN&lt;/span&gt; allrows_cur&lt;span style="color:blue;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;    &lt;span style="color:blue;"&gt;LOOP&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;        &lt;span style="color:blue;"&gt;FETCH&lt;/span&gt; allrows_cur&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;        &lt;b&gt;&lt;span style="color:blue;"&gt;BULK&lt;/span&gt; &lt;span style="color:blue;"&gt;COLLECT&lt;/span&gt; &lt;span style="color:blue;"&gt;INTO&lt;/span&gt; l_order_header_scratch &lt;span style="color:blue;"&gt;LIMIT&lt;/span&gt; &lt;span style="color:maroon;"&gt;100&lt;/span&gt;&lt;span style="color:blue;"&gt;;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;        &lt;i&gt;&lt;span style="color:green;"&gt;-- Remember: BULK COLLECT will NOT raise NO_DATA_FOUND if no rows&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;        &lt;i&gt;&lt;span style="color:green;"&gt;-- are queried. Instead, check the contents of the collection to&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;        &lt;i&gt;&lt;span style="color:green;"&gt;-- see if you have anything left to process.&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;        &lt;span style="color:blue;"&gt;EXIT&lt;/span&gt; &lt;span style="color:blue;"&gt;WHEN&lt;/span&gt; l_order_header_scratch&lt;span style="color:blue;"&gt;.COUNT&lt;/span&gt; &lt;span style="color:blue;"&gt;=&lt;/span&gt; &lt;span style="color:maroon;"&gt;0&lt;/span&gt;&lt;span style="color:blue;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;        &lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;        &lt;i&gt;&lt;span style="color:green;"&gt;-- Process the data, if any.&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;        l_row &lt;span style="color:blue;"&gt;:=&lt;/span&gt; l_order_header_scratch&lt;span style="color:blue;"&gt;.FIRST;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;        &lt;span style="color:blue;"&gt;WHILE&lt;/span&gt; &lt;span style="color:blue;"&gt;(&lt;/span&gt;l_row &lt;span style="color:blue;"&gt;IS&lt;/span&gt; &lt;span style="color:blue;"&gt;NOT&lt;/span&gt; &lt;span style="color:blue;"&gt;NULL)&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;        &lt;span style="color:blue;"&gt;LOOP&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;            &lt;i&gt;&lt;span style="color:green;"&gt;-- Some processing ....&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;            process_order_header_scratch &lt;span style="color:blue;"&gt;(&lt;/span&gt;l_order_header_scratch &lt;span style="color:blue;"&gt;(&lt;/span&gt;l_row&lt;span style="color:blue;"&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;            &lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;            &lt;i&gt;&lt;span style="color:green;"&gt;-- get the next row &lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;            l_row &lt;span style="color:blue;"&gt;:=&lt;/span&gt; l_order_header_scratch&lt;span style="color:blue;"&gt;.NEXT&lt;/span&gt; &lt;span style="color:blue;"&gt;(&lt;/span&gt;l_row&lt;span style="color:blue;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;        &lt;span style="color:blue;"&gt;END&lt;/span&gt; &lt;span style="color:blue;"&gt;LOOP;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;    &lt;span style="color:blue;"&gt;END&lt;/span&gt; &lt;span style="color:blue;"&gt;LOOP;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;    &lt;i&gt;&lt;span style="color:green;"&gt;-- Clean up when done: close the cursor and delete everything&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;    &lt;i&gt;&lt;span style="color:green;"&gt;-- in the collection.&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;    &lt;span style="color:blue;"&gt;CLOSE&lt;/span&gt; allrows_cur&lt;span style="color:blue;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style="font-size:7;"&gt;    l_order_header_scratch&lt;span style="color:blue;"&gt;.DELETE;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;&lt;span style=";font-size:7;color:blue;"  &gt;END;&lt;/span&gt;&lt;/tt&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;EDIT : I just happen to read an interesting article regarding cursor for-loop and would certainly suggest to read it. &lt;a href="http://www.oracle.com/technology/oramag/oracle/08-nov/o68plsql.html"&gt;LINK&lt;/a&gt; .&lt;/p&gt;&lt;p&gt;Also I forgot to mention why bulk collect is faster compare to other, the biggest advantage of BULK COLLECT is: BULKING! obviously :)&lt;br /&gt;&lt;/p&gt; &lt;p&gt;In the cursor Oracle must refresh the binds every loop with the new data. Also the Insert is executed each time! With BULK COLLECT Oracle can put all the values into a collection at once. No need to refresh something again and again hence no soft parses, reading of the new values of the binds…&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;                                          &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size:130%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-1411356700843354407?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/CEIBgK0-cAqkqx4bNt7wNY31IeU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/CEIBgK0-cAqkqx4bNt7wNY31IeU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/CEIBgK0-cAqkqx4bNt7wNY31IeU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/CEIBgK0-cAqkqx4bNt7wNY31IeU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/Y5D4Lo8OnkY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/1411356700843354407/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=1411356700843354407" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/1411356700843354407?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/1411356700843354407?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/Y5D4Lo8OnkY/tip8-cursor-best-practice.html" title="Tip#8 Cursor best practice" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2007/09/tip8-cursor-best-practice.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0UARno_eCp7ImA9WxZUEEs.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-2398941648650588988</id><published>2007-09-17T14:25:00.000+02:00</published><updated>2008-04-01T17:54:07.440+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-01T17:54:07.440+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="OS" /><category scheme="http://www.blogger.com/atom/ns#" term="Admin" /><title>Tip#7 SQL*Plus Command Line History</title><content type="html">&lt;span style=";font-family:times new roman;font-size:85%;"  &gt;&lt;br /&gt;Thanks to Howard Rogers( &lt;a href="http://www.dizwell.com/prod/node/56"&gt;Link &lt;/a&gt;) , I got a very useful utility to have command line history for SQL*Plus on Linux. This small utility makes life so much easier for me especially as most of the time I do work on Linux platform.  All you have to do is&lt;br /&gt;&lt;br /&gt;1. Download a rpm (&lt;a href="http://www.dizwell.com/downloadables/rlwrap-0.18-1.i386.rpm"&gt;Link&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;2. As root user, Install it -&gt;  rpm -ivh rlwrap-0.18-1.i386.rpm&lt;br /&gt;&lt;br /&gt;3. Create alias for SQL*Plus in the user profile (Bash -&gt; .bash_profile , Ksh -&gt; .profile )&lt;br /&gt;&lt;strong&gt;alias sqlplus='rlwrap sqlplus'&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;This will make sure that every time you login and run sql*Plus, "rlwrap" captures all SQL*Plus commands which you can just recall with up/down arrow key.  Other nice feature is search capability of this utility, you can press Ctrl+R and type in key word to search for in your historical SQLs.&lt;br /&gt;&lt;br /&gt;I really find this utility very helpful, hope it helps you too!!!&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-2398941648650588988?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/iKrWaWEC7ehB2BztvDuTgoLNSwc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/iKrWaWEC7ehB2BztvDuTgoLNSwc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/iKrWaWEC7ehB2BztvDuTgoLNSwc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/iKrWaWEC7ehB2BztvDuTgoLNSwc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/es9zUfh5jXY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/2398941648650588988/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=2398941648650588988" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/2398941648650588988?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/2398941648650588988?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/es9zUfh5jXY/tip7-sqlplus-command-line-history.html" title="Tip#7 SQL*Plus Command Line History" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2007/09/tip7-sqlplus-command-line-history.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck8DSHc8fyp7ImA9WB5aFUw.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-1239124968936133528</id><published>2007-09-11T13:07:00.000+02:00</published><updated>2007-09-11T13:41:19.977+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-09-11T13:41:19.977+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Admin" /><title>Tip#6 Compile Invalid Objects</title><content type="html">&lt;span style="font-size:85%;"&gt;The Oracle database will invalidate objects if a dependent object is changed. In development environment it is sometimes pain as code is deployed very often and objects like packages, procedures and functions keep changing and need to compile all dependent objects.&lt;br /&gt;&lt;br /&gt;Earlier most of the time  we use a script to recompile invalid objects like PL/SQL packages and package bodies which may need to run it more than once for dependencies. But then as the number of objects grows so as dependencies and hence the number of times the compile script has to run.&lt;br /&gt;&lt;br /&gt;So to avoid executing multiple times the compile script, we created following stored procedure which compiles in hierarchical order to take care of dependencies. Since we had a inter schema dependencies as well and wanted each schema owner to compile there own objects we pass a parameter which is a schema owner who will be compiling their own invalid objects in a schema. As of now inter schema dependencies is not table driven but I will implement it soon.&lt;br /&gt;&lt;br /&gt;Please note to have generic solution, it needs to be created in a schema with DBA rights e.g. in Dev I created in SYS and then grant execute access to the schema owners.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="color: rgb(0, 0, 153);font-size:85%;" &gt;CREATE OR REPLACE PROCEDURE Compile_Invalid_Objects&lt;br /&gt;    (In_Owner  IN VARCHAR2)&lt;br /&gt;IS&lt;br /&gt; CURSOR obj_Cur IS&lt;br /&gt;   SELECT   'ALTER '&lt;br /&gt;            ||DECODE(a.Object_Type,'PACKAGE BODY','PACKAGE',&lt;br /&gt;                                   'TYPE BODY','TYPE',&lt;br /&gt;                                   'SYNONYM',DECODE(a.Owner,'PUBLIC','PUBLIC SYNONYM',&lt;br /&gt;                                                            'SYNONYM'),&lt;br /&gt;                                   a.Object_Type)&lt;br /&gt;            ||' '&lt;br /&gt;            ||DECODE(a.Owner,'PUBLIC',NULL,&lt;br /&gt;                             a.Owner&lt;br /&gt;                             ||'.')&lt;br /&gt;            ||a.Object_Name&lt;br /&gt;            ||DECODE(a.Object_Type,'JAVA CLASS',' RESOLVE',&lt;br /&gt;                                   ' COMPILE')&lt;br /&gt;            ||DECODE(a.Object_Type,'PACKAGE BODY',' BODY',&lt;br /&gt;                                   'TYPE BODY','BODY') Text&lt;br /&gt;   FROM     sys.dba_Objects a,&lt;br /&gt;            (SELECT   MAX(LEVEL) dLevel,&lt;br /&gt;                      Object_Id&lt;br /&gt;             FROM     sys.Public_Dependency&lt;br /&gt;             START WITH Object_Id IN (SELECT Object_Id&lt;br /&gt;                                      FROM   sys.dba_Objects&lt;br /&gt;                                      WHERE  Status = 'INVALID'&lt;br /&gt;                                             AND Owner = Upper(In_Owner))&lt;br /&gt;             CONNECT BY Object_Id = PRIOR Referenced_Object_Id&lt;br /&gt;             GROUP BY Object_Id) b&lt;br /&gt;   WHERE    a.Object_Id = b.Object_Id (+)&lt;br /&gt;            AND a.Status = 'INVALID'&lt;br /&gt;            AND a.Owner = Upper(In_Owner)&lt;br /&gt;   ORDER BY b.dLevel DESC,&lt;br /&gt;            a.Object_Name ASC;&lt;br /&gt;BEGIN&lt;br /&gt; FOR obj_rec IN obj_Cur LOOP&lt;br /&gt;   BEGIN&lt;br /&gt;     EXECUTE IMMEDIATE obj_rec.Text;&lt;br /&gt;   EXCEPTION&lt;br /&gt;     WHEN OTHERS THEN&lt;br /&gt;       util.Error_Handler('compile_invalid_objects'); -- Log any error       &lt;br /&gt;   END;&lt;br /&gt; END LOOP;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class="MsoNormal"&gt;&lt;span style="color: rgb(0, 0, 153);font-size:85%;" &gt;EXCEPTION&lt;br /&gt; WHEN OTHERS THEN&lt;br /&gt;   util.Error_Handler('compile_invalid_objects');&lt;br /&gt;END Compile_Invalid_Objects&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;/*-----------------------------------------------------------------------------&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    NAME:       compile_invalid_objects&lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;&lt;br /&gt;DESC:       Compile all invalid objects for the given USER  &lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;&lt;br /&gt;usage : exec compile_invalid_objects ('SCOTT');&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;-----------------------------------------------------------------------------*/&lt;/span&gt;&lt;br /&gt;;&lt;br /&gt;/&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="color: rgb(51, 51, 51);" class="MsoNormal"&gt;&lt;span style="color: rgb(0, 0, 153);font-size:85%;" &gt;Grant access to SCOTT user,&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="color: rgb(0, 0, 153);font-size:85%;" &gt;&lt;span style="color: rgb(102, 0, 0);"&gt;grant execute on sys.compile_invalid_objects to SCOTT;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="color: rgb(0, 0, 153);font-size:85%;" &gt;I also create a public synonym for the SP,&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="color: rgb(0, 0, 153);font-size:85%;" &gt;&lt;span style="color: rgb(102, 0, 0);"&gt;CREATE PUBLIC SYNONYM COMPILE_INVALID_OBJECTS FOR SYS.COMPILE_INVALID_OBJECTS;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-1239124968936133528?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/BHFJXF7O5b6eoLfwnc_HftqUtq8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BHFJXF7O5b6eoLfwnc_HftqUtq8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/BHFJXF7O5b6eoLfwnc_HftqUtq8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BHFJXF7O5b6eoLfwnc_HftqUtq8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/b-lHV6KmmW8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/1239124968936133528/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=1239124968936133528" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/1239124968936133528?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/1239124968936133528?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/b-lHV6KmmW8/tip6-compile-invalid-objects.html" title="Tip#6 Compile Invalid Objects" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2007/09/tip6-compile-invalid-objects.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0AGQng_eSp7ImA9WB5UGUs.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-6793622545921058634</id><published>2007-08-24T14:40:00.000+02:00</published><updated>2007-08-24T15:22:03.641+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-08-24T15:22:03.641+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Admin" /><title>Tip#5  DDL Auditing</title><content type="html">&lt;h3&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style="font-weight: normal;font-size:78%;" &gt;As a DBA , I sometimes get complains that this object is missing or changed on our development or UAT system. So in order to find out WHO is the culprit I need to setup the DDL auditing. This is how I generally do this,&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;STEP 1 :&lt;/span&gt;&lt;span style="font-weight: normal;font-size:78%;" &gt;&lt;br /&gt;Please note that you need to give the user (which you are going to use)  the following grant,&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;GRANT ADMINISTER DATABASE TRIGGER TO username;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;STEP 2 :&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: normal;font-size:78%;" &gt; Create Table to log the changes,  something like following&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;CREATE TABLE DDL_AUDIT&lt;br /&gt;(&lt;br /&gt;AUD_ID     NUMBER,&lt;br /&gt;USERNAME   VARCHAR2(50 BYTE),&lt;br /&gt;HOSTNAME   VARCHAR2(50 BYTE),&lt;br /&gt;DDL_DATE   DATE,&lt;br /&gt;OBJ_TYPE   VARCHAR2(50 BYTE),&lt;br /&gt;OBJ_OWNER  VARCHAR2(30 BYTE),&lt;br /&gt;OBJ_NAME   VARCHAR2(30 BYTE),&lt;br /&gt;DDL_EVENT  VARCHAR2(50 BYTE)&lt;br /&gt;)&lt;br /&gt;LOGGING&lt;br /&gt;NOCOMPRESS&lt;br /&gt;NOCACHE&lt;br /&gt;NOPARALLEL&lt;br /&gt;NOMONITORING&lt;br /&gt;/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;STEP 3  :&lt;/span&gt;&lt;span style="font-weight: normal;font-size:78%;" &gt;&lt;br /&gt;Create sequence for  the PK of the table,&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;CREATE SEQUENCE DDL_AUDIT_SEQ&lt;br /&gt;START WITH 1&lt;br /&gt;MAXVALUE 99999999999&lt;br /&gt;MINVALUE 0&lt;br /&gt;NOCYCLE&lt;br /&gt;NOCACHE&lt;br /&gt;NOORDER&lt;br /&gt;/&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;STEP 4 :&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: normal;font-size:78%;" &gt;Create a DDL auditing database trigger,&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;CREATE OR REPLACE TRIGGER ddl_audit_trigger&lt;br /&gt; AFTER DDL ON DATABASE&lt;br /&gt;BEGIN&lt;br /&gt; INSERT INTO ddl_audit&lt;br /&gt;             (aud_id, username,&lt;br /&gt;              hostname, ddl_date, obj_type, obj_owner,&lt;br /&gt;              obj_name, ddl_event&lt;br /&gt;             )&lt;br /&gt;      VALUES (ddl_audit_seq.NEXTVAL, SYS_CONTEXT ('USERENV', 'OS_USER'),&lt;br /&gt;              REPLACE (SYS_CONTEXT ('USERENV', 'HOST'), 'your_domain\', ''), SYSDATE,&lt;br /&gt;             &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-weight: normal;font-size:78%;" &gt;ora_dict_obj_type, ora_dict_obj_owner,  ora_dict_obj_name, ora_sysevent&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-weight: normal;font-size:78%;" &gt;&lt;br /&gt;             );&lt;br /&gt;EXCEPTION&lt;br /&gt; WHEN OTHERS&lt;br /&gt; THEN&lt;br /&gt;     -- log in the error table or ignore it&lt;br /&gt;   NULL;  -- ignore it&lt;br /&gt;END;&lt;br /&gt;/&lt;/span&gt;&lt;span style="font-weight: normal;font-size:78%;" &gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-6793622545921058634?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/gDCFmuJJsuBBASjsWTCVzkRShv0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/gDCFmuJJsuBBASjsWTCVzkRShv0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/gDCFmuJJsuBBASjsWTCVzkRShv0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/gDCFmuJJsuBBASjsWTCVzkRShv0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/tMmYKYkzKBA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/6793622545921058634/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=6793622545921058634" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/6793622545921058634?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/6793622545921058634?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/tMmYKYkzKBA/tip4-ddl-auditing.html" title="Tip#5  DDL Auditing" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2007/08/tip4-ddl-auditing.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0UCQ3wyfip7ImA9WxZUEEs.&quot;"><id>tag:blogger.com,1999:blog-7125531924605711471.post-1894847552540761903</id><published>2007-08-15T16:05:00.000+02:00</published><updated>2008-04-01T17:54:22.296+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-01T17:54:22.296+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Admin" /><category scheme="http://www.blogger.com/atom/ns#" term="Developer" /><title>Tip#4 Dump, Lock &amp; Nth Max/Min</title><content type="html">&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;DUMP Function :&lt;br /&gt;&lt;/span&gt;Sometimes if you need to handle special characters or like in my case various European characters then it is quite useful to know the Hexadecimal or decimal value of the character. You can use the DUMP sql function for the same as shown below,&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;dump( expression, [return_format], [start_position], [length] )&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt; =&gt; expression is the expression to analyze.&lt;br /&gt;&lt;br /&gt; =&gt; return_format is optional. It determines the format of the return value. This parameter can be any of the following values:&lt;br /&gt;&lt;br /&gt;Value  Explanation&lt;br /&gt;-----     -------------&lt;br /&gt;8....... octal notation&lt;br /&gt;10.....  decimal notation&lt;br /&gt;16 .....  hexadecimal notation&lt;br /&gt;17 .....  single characters&lt;br /&gt;1008... octal notation with the character set name&lt;br /&gt;1010...decimal notation with the character set name&lt;br /&gt;1016... hexadecimal notation with the character set name&lt;br /&gt;1017... single characters with the character set name&lt;br /&gt;&lt;br /&gt; =&gt; start_position and length are optional parameters. They determines which portion of the internal representation to display. If these parameters are omitted, the dump function will display the entire internal representation in decimal notation.&lt;br /&gt;&lt;br /&gt;e.g.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;select dump('öäüß',1016)  hex_value from dual;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Hex_Value&lt;br /&gt;-------------&lt;br /&gt;Typ=96 Len=8 CharacterSet=UTF8: c3,b6,c3,a4,c3,bc,c3,9f&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Lock any table explicitly :&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;LOCK table MV_REPORT_E2E_LOGIC IN EXCLUSIVE MODE NOWAIT;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;commit or rollback to release the lock.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Find Nth Maximum value of a column in a table :&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;SELECT  *  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;  FROM  MY_TAB  t1&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;WHERE  &amp;N = (SELECT count(DISTINCT(t2.col1)) &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;   FROM MY_TAB t2 WHERE t1.col1&lt;=t2.col1)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;e.g. N=1 will return first max or N=2 will return second max.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Find Nth Minimum value of a column in a table :&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt; SELECT  *  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;   FROM  MY_TAB  t1&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt; WHERE  &amp;N = (SELECT count(DISTINCT(t2.col1)) &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    FROM MY_TAB t2 WHERE t1.col1 &gt;=t2.col1)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;e.g. N=1 will return first min or N=2 will return second min.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7125531924605711471-1894847552540761903?l=dbatips4u.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/6L5KU27k5nnjzQrU2jW1k54j5fQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6L5KU27k5nnjzQrU2jW1k54j5fQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/6L5KU27k5nnjzQrU2jW1k54j5fQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6L5KU27k5nnjzQrU2jW1k54j5fQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/dbatip4u/~4/Mtmg40jJQpY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dbatips4u.blogspot.com/feeds/1894847552540761903/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7125531924605711471&amp;postID=1894847552540761903" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/1894847552540761903?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7125531924605711471/posts/default/1894847552540761903?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dbatip4u/~3/Mtmg40jJQpY/tip4-dump-lock-nth-maxmin.html" title="Tip#4 Dump, Lock &amp; Nth Max/Min" /><author><name>Mehul Shah</name><uri>http://www.blogger.com/profile/11133328033504365612</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total><feedburner:origLink>http://dbatips4u.blogspot.com/2007/08/tip4-dump-lock-nth-maxmin.html</feedburner:origLink></entry></feed>

