<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Exploring Oracle</title>
	<atom:link href="http://mehrajdba.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mehrajdba.wordpress.com</link>
	<description>Oracle DBA</description>
	<lastBuildDate>Wed, 28 Oct 2009 11:12:50 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='mehrajdba.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/ff19a3b346b40d25b08179f5c8436a6b?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Exploring Oracle</title>
		<link>http://mehrajdba.wordpress.com</link>
	</image>
			<item>
		<title>steps to Migrate ASM diskgroups from one SAN to another SAN</title>
		<link>http://mehrajdba.wordpress.com/2009/10/28/steps-to-migrate-asm-diskgroups-from-one-san-to-another-san/</link>
		<comments>http://mehrajdba.wordpress.com/2009/10/28/steps-to-migrate-asm-diskgroups-from-one-san-to-another-san/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 11:12:50 +0000</pubDate>
		<dc:creator>Mohammed Mehraj Hussain</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://mehrajdba.wordpress.com/?p=248</guid>
		<description><![CDATA[1) Backup all your databases and valid the backup .
2) Add the new path (new disks from the new storage) to your asm_disktring to be recognized by ASM:
Example:
SQL&#62; alter system set asm_disktring = &#8216;/dev/dellpowerc*&#8217; , &#8216;/dev/dellpowerh*&#8217;;
Where: &#8216;/dev/dellpowerc*&#8217; are the current disks.
Where: &#8216;/dev/dellpowerh*&#8217; are the new disks.
3) Confirm that the new disks are being detected by [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=248&subd=mehrajdba&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>1) Backup all your databases and valid the backup .</p>
<p>2) Add the new path (new disks from the new storage) to your asm_disktring to be recognized by ASM:</p>
<p>Example:</p>
<p>SQL&gt; alter system set asm_disktring = &#8216;/dev/dellpowerc*&#8217; , &#8216;/dev/dellpowerh*&#8217;;</p>
<p>Where: &#8216;/dev/dellpowerc*&#8217; are the current disks.<br />
Where: &#8216;/dev/dellpowerh*&#8217; are the new disks.</p>
<p>3) Confirm that the new disks are being detected by ASM:</p>
<p>SQL&gt; select path from v$asm_disk;</p>
<p>4) Add the new disks to your desired diskgroup:</p>
<p>SQL&gt; alter diskgroup &lt;diskgroup name&gt; add disk<br />
‘&lt;new disk 1&gt;’,<br />
‘&lt;new disk 2&gt;’,<br />
‘&lt;new disk 3&gt;’,<br />
‘&lt;new disk 4&gt;’,<br />
.<br />
.<br />
.<br />
‘&lt;new disk N&gt;’;</p>
<p>5) Then wait until the rebalance operation completes:</p>
<p>SQL&gt; select * from v$asm_operation;</p>
<p>6) Finally, remove the old disks:</p>
<p>SQL&gt; alter diskgroup &lt;diskgroup name&gt; drop disk<br />
&lt;disk name A&gt;,<br />
&lt;disk name B&gt;,<br />
&lt;disk name D&gt;,<br />
&lt;disk name E&gt;,<br />
.<br />
.<br />
.<br />
&lt;disk name X&gt;;</p>
<p>7) Then wait until the rebalance operation completes:</p>
<p>SQL&gt; select * from v$asm_operation;</p>
<p> <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> Done, your ASM diskgroups and database have been migrated to the new storage.</p>
<p>Note: Alternatively, we can execute add disk &amp; drop disk statements in one operation, in that way only one rebalance operation will be started as follow:</p>
<p>SQL&gt; alter diskgroup &lt;diskgroup name&gt;<br />
add disk &#8216;&lt;new device physical name 1&gt;&#8217;, .., &#8216;&lt;new device physical name N&gt;&#8217;<br />
drop disk &lt;old disk logical name 1&gt;, &lt;old disk logical name 2&gt;, ..,&lt;old disk logical name N&gt;<br />
rebalance &lt;#&gt;;</p>
<p>This is more efficient than separated commands (add disk &amp; drop disk statements).</p>
Posted in Database  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mehrajdba.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mehrajdba.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mehrajdba.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mehrajdba.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mehrajdba.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mehrajdba.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mehrajdba.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mehrajdba.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mehrajdba.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mehrajdba.wordpress.com/248/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=248&subd=mehrajdba&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mehrajdba.wordpress.com/2009/10/28/steps-to-migrate-asm-diskgroups-from-one-san-to-another-san/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cbeac91208b1d3d18eaac1a3c87fdf18?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mehraj</media:title>
		</media:content>
	</item>
		<item>
		<title>Oracle Vs IBM</title>
		<link>http://mehrajdba.wordpress.com/2009/09/11/oracle-vs-ibm/</link>
		<comments>http://mehrajdba.wordpress.com/2009/09/11/oracle-vs-ibm/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 12:15:33 +0000</pubDate>
		<dc:creator>Mohammed Mehraj Hussain</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://mehrajdba.wordpress.com/?p=237</guid>
		<description><![CDATA[
Wow &#8230;..
It  will be a great challenge for Oracle to swipe  IBM in Hardware Business.
And We can expect  a Large improvements in Solaris and Sparc as Larry said.
Posted in Database       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=237&subd=mehrajdba&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a rel="attachment wp-att-238" href="http://mehrajdba.wordpress.com/2009/09/11/oracle-vs-ibm/sun_customers_lg/"><img class="aligncenter size-full wp-image-238" title="sun_customers_lg" src="http://mehrajdba.files.wordpress.com/2009/09/sun_customers_lg.gif?w=370&#038;h=552" alt="sun_customers_lg" width="370" height="552" /></a></p>
<p>Wow &#8230;..</p>
<p>It  will be a great challenge for Oracle to swipe  IBM in Hardware Business.</p>
<p>And We can expect  a Large improvements in Solaris and Sparc as Larry said.</p>
Posted in Database  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mehrajdba.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mehrajdba.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mehrajdba.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mehrajdba.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mehrajdba.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mehrajdba.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mehrajdba.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mehrajdba.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mehrajdba.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mehrajdba.wordpress.com/237/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=237&subd=mehrajdba&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mehrajdba.wordpress.com/2009/09/11/oracle-vs-ibm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cbeac91208b1d3d18eaac1a3c87fdf18?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mehraj</media:title>
		</media:content>

		<media:content url="http://mehrajdba.files.wordpress.com/2009/09/sun_customers_lg.gif" medium="image">
			<media:title type="html">sun_customers_lg</media:title>
		</media:content>
	</item>
		<item>
		<title>Oracle Clusterware</title>
		<link>http://mehrajdba.wordpress.com/2009/09/10/oracle-clusterware/</link>
		<comments>http://mehrajdba.wordpress.com/2009/09/10/oracle-clusterware/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 10:29:43 +0000</pubDate>
		<dc:creator>Mohammed Mehraj Hussain</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://mehrajdba.wordpress.com/?p=232</guid>
		<description><![CDATA[Oracle Clusterware is the cross platform cluster software required to run the Real Application Clusters (RAC) option for Oracle Database.
It provides the basic clustering services at the operating system level that enable Oracle software to run in clustering mode. In earlier versions of  Oracle (version 9i and earlier), RAC required a vendor supplied clusterware like [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=232&subd=mehrajdba&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Oracle Clusterware is the cross platform cluster software required to run the Real Application Clusters (RAC) option for Oracle Database.</p>
<p>It provides the basic clustering services at the operating system level that enable Oracle software to run in clustering mode. In earlier versions of  Oracle (version 9i and earlier), RAC required a vendor supplied clusterware like Sun Cluster or Veritas Cluster Server and with a seperate software for  Linux and Windows.</p>
<p>Oracle clusterware naming Evolution:</p>
<p>In 9i     - Third Party softwares  (Sun Cluster or Veritas Cluster Server)<br />
In 10gR1-Cluster  Ready services (Oracle corporation)<br />
In 10gR2- Oracle Clusterware     (Oracle corporation)</p>
<p>Oracle Clusterware stores configuration information in the Oracle Cluster Repository (OCR),<br />
which must be located on shared storage available to all nodes. The Membership of the cluster is determined using a  file known as the voting disk, which must also be available to all nodes. Voting Disk  acts a tiebreaker during communication failures and  Consistent heartbeat information from all the nodes is sent to voting disk when the cluster is running .</p>
<p>Oracle Clusterware comprises a set of daemons(Background process).</p>
<p>1.Cluster Ready Services Daemon(crsd)</p>
<p>This component manages high availability operations within the cluster. Objects managed by CRS are known as resources and can include databases, instances, services, listeners, virtual IP addresses, and application processes. By default, CRS manages four application process resources: Oracle Net listeners, virtual IP addresses, the Global Services Daemon (GSD), and the Oracle Notification Service (ONS).</p>
<p>Configuration information about each resource is stored in the Oracle Cluster Repository<br />
(OCR). When the status of a resource changes, CRS generates an event.</p>
<p>CRS monitors resources, such as instances and listeners. In the event of the failure of a resource, CRS will attempt to automatically restart the component.</p>
<p>2.Oracle Cluster Synchronization Service Daemon (OCSSD)</p>
<p>This component manages the cluster configuration by controlling which nodes are members of the cluster. When a node joins or leaves the cluster, CSS notifies the other nodes of the change in configuration.<br />
If this process fails, then the cluster will be restarted.</p>
<p>3.Event Volume Manager Daemon (evmd)</p>
<p>The EVM component publishes events created by Oracle Clusterware. It will restart Automatically on failures and death of the evmd process does not halt the instance</p>
<p>4.Process Monitor Daemon (oprocd)</p>
<p>Oprocd provides the I/O Fencing solution for the Oracle Clusterware. It is the process monitor for the oracle clusterware and it uses the hang check timer or watchdog timer (depending on the implementation) for the cluster integrity.</p>
Posted in Database  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mehrajdba.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mehrajdba.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mehrajdba.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mehrajdba.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mehrajdba.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mehrajdba.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mehrajdba.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mehrajdba.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mehrajdba.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mehrajdba.wordpress.com/232/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=232&subd=mehrajdba&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mehrajdba.wordpress.com/2009/09/10/oracle-clusterware/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cbeac91208b1d3d18eaac1a3c87fdf18?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mehraj</media:title>
		</media:content>
	</item>
		<item>
		<title>Dbms_Stats with method_opt</title>
		<link>http://mehrajdba.wordpress.com/2009/08/06/dbms_stats-with-method_opt/</link>
		<comments>http://mehrajdba.wordpress.com/2009/08/06/dbms_stats-with-method_opt/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 12:00:22 +0000</pubDate>
		<dc:creator>Mohammed Mehraj Hussain</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://mehrajdba.wordpress.com/?p=225</guid>
		<description><![CDATA[Hi,
Platform: windows server 2003
Database : 10.2.0.4
Recently we have faced an problem with Gathering statistics which leads to
an oracle internal error (Ora-00600).
There is a  production database which has doing some  large transactions.
we usally gather the statistics for this database bettweeen the interval of two weeks .
we will gather the ststistics using the folowing method
exec dbms_stats.gather_schema_stats(ownname=&#62;&#8217;user01&#8242;,estimate_percent=&#62;dbms_stats.auto_sample_size,cascade=&#62;true);
Last night [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=225&subd=mehrajdba&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Hi,</p>
<p>Platform: windows server 2003<br />
Database : 10.2.0.4</p>
<p>Recently we have faced an problem with Gathering statistics which leads to<br />
an oracle internal error (Ora-00600).</p>
<p>There is a  production database which has doing some  large transactions.</p>
<p>we usally gather the statistics for this database bettweeen the interval of two weeks .</p>
<p>we will gather the ststistics using the folowing method</p>
<p>exec dbms_stats.gather_schema_stats(ownname=&gt;&#8217;user01&#8242;,estimate_percent=&gt;dbms_stats.auto_sample_size,cascade=&gt;true);</p>
<p>Last night we have gathered statistics for the a schema .<br />
Suddenly  Only the next day morning Our users reported that some Oracle errors is<br />
flashed  on one of our applications when accessing some particular form .</p>
<p>Then we tried to find the table on which that particular form is been accessing,<br />
and we manually quried a simple statement on tht table:</p>
<p>SQL&gt; select * from Tabular_data;<br />
select * from Tabular_data<br />
*<br />
ERROR at line 1:<br />
ORA-00600: internal error code, arguments: [19004], [], [], [], [], [], [], []</p>
<p>After some search about the argument [19004] we finally understood that it is as a Bug .</p>
<p>This bug is due to the miscalculation of the Oracle&#8217;S Automatic Historgram collection on the table<br />
columns .</p>
<p>since we dint mention any method_opt parameter on the above statement , it leads to its default value</p>
<p>method_opt=&gt;&#8217;FOR ALL COLUMNS SIZE AUTO&#8217; (Oracle 10g&#8217;s Default value)</p>
<p>So we decided to include the method_opt parameter with the size 1 which is the default value in<br />
Oracle 9i.</p>
<p>method_opt=&gt;&#8217;FOR ALL COLUMNS SIZE 1&#8242; (Oracle 9i&#8217;s Default value)</p>
<p>This method will disable the collection of Histograms.</p>
<p>if we cant loose histograms , Ofcourse the Another way to escape from this error is to lock the</p>
<p>Statistics for that particular table and to proceed with the older approach .<br />
SQL&gt; exec dbms_stats.lock_table_stats(&#8216;USER01&#8242;, &#8216;TABULAR_DATA&#8217;);</p>
<p>PL/SQL procedure successfully completed.</p>
<p>SQL&gt; SELECT stattype_locked FROM dba_tab_statistics</p>
<p>WHERE table_name=&#8217;TABULAR_DATA&#8217;;</p>
<p>STATTYPE_LOCKED<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
ALL</p>
<p>So you cant able to gather statistics on the locked table.</p>
Posted in Database  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mehrajdba.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mehrajdba.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mehrajdba.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mehrajdba.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mehrajdba.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mehrajdba.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mehrajdba.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mehrajdba.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mehrajdba.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mehrajdba.wordpress.com/225/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=225&subd=mehrajdba&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mehrajdba.wordpress.com/2009/08/06/dbms_stats-with-method_opt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cbeac91208b1d3d18eaac1a3c87fdf18?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mehraj</media:title>
		</media:content>
	</item>
		<item>
		<title>Namespaces</title>
		<link>http://mehrajdba.wordpress.com/2009/07/22/namespaces/</link>
		<comments>http://mehrajdba.wordpress.com/2009/07/22/namespaces/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 05:26:56 +0000</pubDate>
		<dc:creator>Mohammed Mehraj Hussain</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://mehrajdba.wordpress.com/?p=222</guid>
		<description><![CDATA[Can we able to create an index with the same name as the table name ?
Yes . Because the table and index resides in the different namespaces.
A namespace defines a group of object types, within which all names must be uniquely identified—by schema and name. Objects in different namespaces can share the same name.
These object [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=222&subd=mehrajdba&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Can we able to create an index with the same name as the table name ?</p>
<p>Yes . Because the table and index resides in the different namespaces.</p>
<p>A namespace defines a group of object types, within which all names must be uniquely identified—by schema and name. Objects in different namespaces can share the same name.</p>
<p>These object types all share the same namespace:<br />
• Tables<br />
• Views<br />
• Sequences<br />
• Private synonyms<br />
• Stand-alone procedures<br />
• Stand-alone stored functions<br />
• Packages<br />
• Materialized views<br />
• User-defined types</p>
<p>So  it is impossible to create a view with the same name as a table; at least, it<br />
is impossible if they are in the same schema.</p>
<p>These object types each have their own namespace:<br />
• Indexes<br />
• Constraints<br />
• Clusters<br />
• Database triggers<br />
• Private database links<br />
• Dimensions<br />
Thus it is possible for an index to have the same name as a table, even within the<br />
same schema.</p>
<p>SQL&gt; select namespace from v$librarycache;</p>
<p>NAMESPACE<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
SQL AREA<br />
TABLE/PROCEDURE<br />
BODY<br />
TRIGGER<br />
INDEX<br />
CLUSTER<br />
OBJECT<br />
PIPE<br />
JAVA SOURCE<br />
JAVA RESOURCE<br />
JAVA DATA</p>
<p>11 rows selected.</p>
<p>Here there is an small test:</p>
<p>SQL&gt; create table t1 as select *  from user_objects;</p>
<p>Table created.</p>
<p>SQL&gt; create index t1 on t1(object_id);</p>
<p>Index created.</p>
<p>SQL&gt;  CREATE OR REPLACE package t1 as (ENO VARCHAR2);<br />
2  /<br />
CREATE OR REPLACE package t1 as (ENO VARCHAR2);<br />
*<br />
ERROR at line 1:<br />
ORA-00955: name is already used by an existing object</p>
<p>Here we are getting the error because the packages and tables resides in the same namespace.</p>
Posted in Database  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mehrajdba.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mehrajdba.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mehrajdba.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mehrajdba.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mehrajdba.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mehrajdba.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mehrajdba.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mehrajdba.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mehrajdba.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mehrajdba.wordpress.com/222/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=222&subd=mehrajdba&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mehrajdba.wordpress.com/2009/07/22/namespaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cbeac91208b1d3d18eaac1a3c87fdf18?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mehraj</media:title>
		</media:content>
	</item>
		<item>
		<title>Tracing a web application in Oracle</title>
		<link>http://mehrajdba.wordpress.com/2009/07/18/tracing-a-web-application-in-oracle/</link>
		<comments>http://mehrajdba.wordpress.com/2009/07/18/tracing-a-web-application-in-oracle/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 06:29:30 +0000</pubDate>
		<dc:creator>Mohammed Mehraj Hussain</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://mehrajdba.wordpress.com/?p=218</guid>
		<description><![CDATA[In a busy production environment with many active users, tracing a SQL session is time-consuming and complicated,
because processing SQL statements in any multitier system that uses a connection pool can span multiple processes,
or even different instances.
With Oracle Database 10g, Oracle rationalizes SQL tracing through a new built-in package, DBMS_MONITOR,
which encompasses the functionality of previously undocumented [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=218&subd=mehrajdba&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In a busy production environment with many active users, tracing a SQL session is time-consuming and complicated,<br />
because processing SQL statements in any multitier system that uses a connection pool can span multiple processes,<br />
or even different instances.</p>
<p>With Oracle Database 10g, Oracle rationalizes SQL tracing through a new built-in package, DBMS_MONITOR,<br />
which encompasses the functionality of previously undocumented trace tools, such as the DBMS_SUPPORT package.<br />
Now you can easily trace any user&#8217;s session from beginning to end—from client machine to middle tier to back end—and generate trace<br />
files based on specific client ID, module, or action.</p>
<p>Now you can add your own reference to the trace file for your easy identification,</p>
<p>alter session set<br />
tracefile_identifier =&#8221;webapp&#8221;;</p>
<p>Trace files generated by this command have the string value with &#8220;webapp&#8221;</p>
<p>The DBMS_MONITOR package has routines for enabling and disabling statistics aggregation as well as for tracing by session ID,<br />
or tracing based upon a combination of service name, module name, and action name.</p>
<p>PL/SQL developers can embed calls into their applications by using the DBMS_APPLICATION_INFO package to set module and action names</p>
<p>The service name is determined by the connect string used to connect to a service. User sessions not associated with a specific service are handled by sys$users (sys$background is the default service for the background processes).<br />
Since we have a service and a module name, we can turn on tracing for this module as follows:</p>
<p>SQL&gt; exec dbms_monitor.serv_mod_act_trace_enable(service_name=&gt;&#8217;test&#8217;, module_name=&gt;&#8217;w3link&#8217;);</p>
<p>PL/SQL procedure successfully completed.</p>
<p>To Disable:</p>
<p>SQL&gt;exec dbms_monitor.serv_mod_act_trace_disable(service_name=&gt;&#8217;test&#8217;, module_name=&gt;&#8217;w3link&#8217;);</p>
<p>PL/SQL procedure successfully completed.<br />
Tracing For a particular session:<br />
 <br />
SQL&gt; select sid, serial#, username<br />
from v$session;</p>
<p>   SID     SERIAL#  USERNAME<br />
     &#8212;&#8212;    &#8212;&#8212;-  &#8212;&#8212;&#8212;&#8212;<br />
       103       4152  SYS<br />
       107       2418  SYSMAN<br />
       129         53  TEST<br />
       130        561  HR<br />
       141          4  DBSNMP<br />
. . .<br />
       168          1<br />
       169          1<br />
       170          1<br />
15 rows selected.<br />
SQL&gt; exec dbms_monitor.session_trace_enable<br />
(session_id=&gt;129, serial_num=&gt;53, waits=&gt;true, binds=&gt;TRUE);<br />
PL/SQL procedure successfully completed.<br />
SQL&gt; exec dbms_monitor.session_trace_disable(129);<br />
PL/SQL procedure successfully completed.</p>
Posted in Database  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mehrajdba.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mehrajdba.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mehrajdba.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mehrajdba.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mehrajdba.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mehrajdba.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mehrajdba.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mehrajdba.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mehrajdba.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mehrajdba.wordpress.com/218/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=218&subd=mehrajdba&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mehrajdba.wordpress.com/2009/07/18/tracing-a-web-application-in-oracle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cbeac91208b1d3d18eaac1a3c87fdf18?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mehraj</media:title>
		</media:content>
	</item>
		<item>
		<title>Importance Of SQL Design</title>
		<link>http://mehrajdba.wordpress.com/2009/07/16/importance-of-sql-design/</link>
		<comments>http://mehrajdba.wordpress.com/2009/07/16/importance-of-sql-design/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 12:35:26 +0000</pubDate>
		<dc:creator>Mohammed Mehraj Hussain</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://mehrajdba.wordpress.com/?p=212</guid>
		<description><![CDATA[If the sql statement  is designed poorly, nothing much can be done by optimizer or indexes
Few are the well known rules
-Enabling indexes to eliminate the need for full table scans
-Avoid Cartesian joins
–Use UNION ALL instead of UNION – if possible
–Use EXIST clause instead of IN &#8211; (Wherever appropiate)
–Use order by when you really require it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=212&subd=mehrajdba&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>If the sql statement  is designed poorly, nothing much can be done by optimizer or indexes</p>
<p>Few are the well known rules</p>
<p>-Enabling indexes to eliminate the need for full table scans</p>
<p>-Avoid Cartesian joins</p>
<p>–Use UNION ALL instead of UNION – if possible</p>
<p>–Use EXIST clause instead of IN &#8211; (Wherever appropiate)</p>
<p>–Use order by when you really require it – Its very costly</p>
<p>–When joining 2 views that themselves select from other views, check that the 2 views that you are using do not join the same tables!</p>
<p>–Avoid NOT in or NOT = on indexed columns. They prevent the optimizer from using indexes. Use where amount &gt; 0 instead of where amount != 0</p>
<p>- Avoid writing where is not null. nulls can prevent the optimizer from using an index</p>
<p>- Avoid calculations on indexed columns. Write WHERE amount &gt; 26000/3 instead of WHERE approved_amt/3 &gt; 26000</p>
Posted in Database  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mehrajdba.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mehrajdba.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mehrajdba.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mehrajdba.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mehrajdba.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mehrajdba.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mehrajdba.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mehrajdba.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mehrajdba.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mehrajdba.wordpress.com/212/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=212&subd=mehrajdba&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mehrajdba.wordpress.com/2009/07/16/importance-of-sql-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cbeac91208b1d3d18eaac1a3c87fdf18?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mehraj</media:title>
		</media:content>
	</item>
		<item>
		<title>Automatic Storage Management !</title>
		<link>http://mehrajdba.wordpress.com/2009/06/26/automatic-storage-management/</link>
		<comments>http://mehrajdba.wordpress.com/2009/06/26/automatic-storage-management/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 11:28:34 +0000</pubDate>
		<dc:creator>Mohammed Mehraj Hussain</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://mehrajdba.wordpress.com/?p=202</guid>
		<description><![CDATA[ASM is a powerful and portable storage manager designed to manage Oracle Database 10g and 11g database files. ASM simplifies storage management so that DBA&#8217;s worry less about Oracle Database file layout and management . ASM delivers lower total cost of ownership while increasing storage utilization, all without compromising performance or availability. With ASM, a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=202&subd=mehrajdba&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>ASM is a powerful and portable storage manager designed to manage Oracle Database 10g and 11g database files. ASM simplifies storage management so that DBA&#8217;s worry less about Oracle Database file layout and management . ASM delivers lower total cost of ownership while increasing storage utilization, all without compromising performance or availability. With ASM, a fraction of the time is needed to manage your database files.</p>
<p><a rel="attachment wp-att-205" href="http://mehrajdba.wordpress.com/2009/06/26/automatic-storage-management/asm-2/"><img class="aligncenter size-full wp-image-205" title="asm" src="http://mehrajdba.files.wordpress.com/2009/06/asm1.jpg?w=460&#038;h=214" alt="asm" width="460" height="214" /></a></p>
<p>Some important ASM key features are:</p>
<p>· Volume Management<br />
· Database File System with performance of RAW I/O<br />
· Supports clustering (RAC) and single instance<br />
· Automatic data distribution<br />
· Online add/drop/resize disk with automated data relocation<br />
· Automatic file management<br />
· Flexible mirror protection</p>
<p>Basically, ASM is a storage manager designed to manage Oracle Database files with Volume Manager (1MB/128KB striping, Flexible mirroring and Online disk reconfigurations and automatic rebalancing), File System (Even data distribution with optimal performance) and Automatic file management using Oracle Managed Files (OMF).</p>
<p>Files supported by ASM</p>
<p>Only Oracle files are supported:</p>
<p>Data files<br />
Control files<br />
Online redo log files<br />
Archived redo log files<br />
Flash recovery area files<br />
RMAN files (image copy and backup)</p>
<p> Files not Supported:</p>
<p>ORACLE_BASE files( including alert log, trace files, etc)<br />
CRS voting disk and OCR files<br />
Output data from UTL_FILE<br />
Any user or application specific files(e.g. XML or Java files)<br />
Oracle 9i external table files</p>
Posted in Database  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mehrajdba.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mehrajdba.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mehrajdba.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mehrajdba.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mehrajdba.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mehrajdba.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mehrajdba.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mehrajdba.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mehrajdba.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mehrajdba.wordpress.com/202/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=202&subd=mehrajdba&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mehrajdba.wordpress.com/2009/06/26/automatic-storage-management/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cbeac91208b1d3d18eaac1a3c87fdf18?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mehraj</media:title>
		</media:content>

		<media:content url="http://mehrajdba.files.wordpress.com/2009/06/asm1.jpg" medium="image">
			<media:title type="html">asm</media:title>
		</media:content>
	</item>
		<item>
		<title>Caching a Sequence &#8211; Will it helps !</title>
		<link>http://mehrajdba.wordpress.com/2009/05/27/caching-a-sequence-will-it-helps/</link>
		<comments>http://mehrajdba.wordpress.com/2009/05/27/caching-a-sequence-will-it-helps/#comments</comments>
		<pubDate>Wed, 27 May 2009 09:12:50 +0000</pubDate>
		<dc:creator>Mohammed Mehraj Hussain</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://mehrajdba.wordpress.com/?p=199</guid>
		<description><![CDATA[Yesterday, when I was reviewing AWR report of a busy OLTP database, I came across a dictionary related “Update” statement. This update statement was listed in top 10 SQL’s under “SQL ordered by Parse Calls” and “SQL ordered by Executions” sections of the AWR report and was parsed and executed 698 times during 30 minutes [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=199&subd=mehrajdba&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Yesterday, when I was reviewing AWR report of a busy OLTP database, I came across a dictionary related “Update” statement. This update statement was listed in top 10 SQL’s under “SQL ordered by Parse Calls” and “SQL ordered by Executions” sections of the AWR report and was parsed and executed 698 times during 30 minutes (A 30 minutes AWR report).</p>
<p>Here is the complete SQL Statement:</p>
<p>“update seq$ set increment$=:2, minvalue=:3, maxvalue=:4, cycle#=:5, order$=:6, cache=:7, highwater=:8, audit$=:9, flags=:10 where obj#=:1”</p>
<p>Immediately, I queried Oracle data dictionary for a list of sequences of one of our most important schema. Following is the query and its output:</p>
<p><span><span>sql&gt;select</span><span> sequence_name, cache_size, last_number </span><span>from</span><span> dba_sequences</span></span></p>
<p><span><span> where</span><span> sequence_owner = </span><span>&#8216;OM_TEST&#8217;</span><span>;</span></span><span> </span></p>
<p>SEQUENCE_NAME                  CACHE_SIZE       LAST_NUMBER</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;-                         &#8212;&#8212;&#8212;&#8211;</p>
<p>SEQ_AUDIT_DETAILS             0                                     6728991<br />
SEQ_MTR_LOG                             0                                    1<br />
SEQ_TRANS_LOG                        20                                  991</p>
<p>Sequence “SEQ_AUDIT_DETAILS” seems to be a culprit here, it has been used for more than 6 Million times and is not cached.</p>
<p>Upon further investigation, it was revealed that this sequence is used by an audit detail table to generate unique serial.</p>
<p>I altered the sequence definition to cache 1000 values. Caching instructs Oracle to pre-allocate (in my case 1000) values in the memory for faster access.</p>
<p><span><span>SQL&gt; </span><span>alter</span><span> </span><span>sequence</span><span> seq_audit_details cache 1000;</span></span></p>
<p style="text-align:left;"><span><span> </span></span>The above ALTER command did a magic and the UPDATE statement vanished from the AWR reports.</p>
<p style="text-align:left;">We need to cache sequences whenever possible to avoid extra physical I/O.</p>
Posted in Database  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mehrajdba.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mehrajdba.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mehrajdba.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mehrajdba.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mehrajdba.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mehrajdba.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mehrajdba.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mehrajdba.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mehrajdba.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mehrajdba.wordpress.com/199/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=199&subd=mehrajdba&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mehrajdba.wordpress.com/2009/05/27/caching-a-sequence-will-it-helps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cbeac91208b1d3d18eaac1a3c87fdf18?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mehraj</media:title>
		</media:content>
	</item>
		<item>
		<title>Export Error</title>
		<link>http://mehrajdba.wordpress.com/2009/05/26/export-error/</link>
		<comments>http://mehrajdba.wordpress.com/2009/05/26/export-error/#comments</comments>
		<pubDate>Tue, 26 May 2009 13:01:26 +0000</pubDate>
		<dc:creator>Mohammed Mehraj Hussain</dc:creator>
				<category><![CDATA[Ora-errors]]></category>

		<guid isPermaLink="false">http://mehrajdba.wordpress.com/?p=193</guid>
		<description><![CDATA[Oracle Version- 10.2.0.4
I Have taken an export of a particular user  which dump size is nearly to 14 gb.
While I am importing it  , i got an import error which says ,
illegal lob length marker 65279
bytesread = 00000000000
TABLE =cm_test
IMP-00098: INTERNAL ERROR: impgst2
IMP-00018: partial import of previous table completed: 2031183 rows imported
IMP-00008: unrecognized statement in the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=193&subd=mehrajdba&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Oracle Version- 10.2.0.4</p>
<p>I Have taken an export of a particular user  which dump size is nearly to 14 gb.</p>
<p>While I am importing it  , i got an import error which says ,</p>
<p>illegal lob length marker 65279<br />
bytesread = 00000000000<br />
TABLE =cm_test<br />
IMP-00098: INTERNAL ERROR: impgst2<br />
IMP-00018: partial import of previous table completed: 2031183 rows imported<br />
IMP-00008: unrecognized statement in the export file:<br />
ÿþÿþÿþÿ<br />
IMP-00008: unrecognized statement in the export file:<br />
IMP-00008: unrecognized statement in the export file:<br />
IMP-00008: unrecognized statement in the export file:<br />
IMP-00008: unrecognized statement in the export file:<br />
IMP-00008: unrecognized statement in the export file:</p>
<p>All the  googles and forums mentioned that the export dump file is corrupted .</p>
<p>So  later i have taken an export once again with the large buffer size (buffer=300000000)</p>
<p>And then the export has been taken successfully ,</p>
<p>Later i try to import it by setting the same buffer parameter (buffer=300000000) and the import error message seems to be vanished .</p>
<p>This  same issue is been reported as a Bug by oracle support in 10.1.0.3, But this  bug has been fixed in 10.1.0.4 and Later.</p>
<p>Bug no: 3890213  IMP-98 possible importing zero length Lobs with CHUNKSIZE &gt; 32767</p>
Posted in Ora-errors  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mehrajdba.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mehrajdba.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mehrajdba.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mehrajdba.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mehrajdba.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mehrajdba.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mehrajdba.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mehrajdba.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mehrajdba.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mehrajdba.wordpress.com/193/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=193&subd=mehrajdba&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mehrajdba.wordpress.com/2009/05/26/export-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cbeac91208b1d3d18eaac1a3c87fdf18?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mehraj</media:title>
		</media:content>
	</item>
		<item>
		<title>Is Index Expensive in DML?</title>
		<link>http://mehrajdba.wordpress.com/2009/05/26/is-index-expensive-in-dml/</link>
		<comments>http://mehrajdba.wordpress.com/2009/05/26/is-index-expensive-in-dml/#comments</comments>
		<pubDate>Tue, 26 May 2009 10:14:47 +0000</pubDate>
		<dc:creator>Mohammed Mehraj Hussain</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://mehrajdba.wordpress.com/?p=188</guid>
		<description><![CDATA[Indexes are used to enhance expensive queries to run more quickly. They provide faster access path to table data. But, there is a trade-off using indexes, DML statements against the table would consume more time as all indexes on the table have to be updated during the DML.
Here is a small test I performed to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=188&subd=mehrajdba&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Indexes are used to enhance expensive queries to run more quickly. They provide faster access path to table data. But, there is a trade-off using indexes, DML statements against the table would consume more time as all indexes on the table have to be updated during the DML.</p>
<p>Here is a small test I performed to see how index existence would affect the DML statements. For the test case, I create a small table without indexes, inserted 100,000 records and measure the time taken. I repeat the same test but this time with indexes on all columns. The difference in timing will show us, how much expensive are our indexes.</p>
<p><span style="font-weight:bold;">Test 1: Without Indexes</span></p>
<p>SQL&gt; set serveroutput on<br />
SQL&gt; create table t(a number, b varchar2(30), c date);</p>
<p>Table created.</p>
<p>SQL&gt; declare<br />
2     x number;<br />
3   begin<br />
4     x := dbms_utility.get_time;<br />
5     for i in 1..100000 loop<br />
6       insert into t values(i, &#8216;value = &#8216; || i, sysdate + mod(i,365));<br />
7     end loop;<br />
8   dbms_output.put_line(&#8216;Time taken WITHOUT indexes : &#8216; ||to_char(dbms_utility.get_time &#8211; x));<br />
9  end;<br />
10  /<br />
Time taken WITHOUT indexes : 1200</p>
<p>PL/SQL procedure successfully completed.</p>
<p>Now, repeat the same test by creating indexes on all the three columns.</p>
<p><span style="font-weight:bold;">Test 2: With Indexes: </span></p>
<p><span><span><br />
</span></span></p>
<p>SQL&gt; drop table t purge;</p>
<p>Table dropped.</p>
<p>SQL&gt; create table t(a number, b varchar2(30), c date);</p>
<p>Table created.</p>
<p>SQL&gt; create index t_idx1 on t(a);</p>
<p>Index created.</p>
<p>SQL&gt; create index t_idx2 on t(b);</p>
<p>Index created.</p>
<p>SQL&gt; create index t_idx3 on t(c);</p>
<p>Index created.</p>
<p>SQL&gt;  declare<br />
2   x number;<br />
3   begin<br />
4     x := dbms_utility.get_time;<br />
5     for i in 1..100000 loop<br />
6       insert into t values(i, &#8216;value = &#8216; || i, sysdate + mod(i,365));<br />
7     end loop;<br />
8     dbms_output.put_line(&#8216;Time taken WITH indexes : &#8216; ||to_char(dbms_utility.get_time &#8211; x));<br />
9   end;<br />
10 /<br />
Time taken WITH indexes : 4772</p>
<p>PL/SQL procedure successfully completed.</p>
<p>Well, it’s evident from the above tests that having too many indexes surely affects performance of DML statements. When I had three indexes, time taken to process 100,000 records was more than double compared to process the same number of records without indexes.   Moral of the test is to create indexes when required and avoid over-creating them</p>
Posted in Database  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mehrajdba.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mehrajdba.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mehrajdba.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mehrajdba.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mehrajdba.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mehrajdba.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mehrajdba.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mehrajdba.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mehrajdba.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mehrajdba.wordpress.com/188/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=188&subd=mehrajdba&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mehrajdba.wordpress.com/2009/05/26/is-index-expensive-in-dml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cbeac91208b1d3d18eaac1a3c87fdf18?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mehraj</media:title>
		</media:content>
	</item>
		<item>
		<title>GATHER_FIXED_OBJECT_STATS and GATHER_DICTIONARY_STATS</title>
		<link>http://mehrajdba.wordpress.com/2009/05/25/gather_fixed_object_stats-and-gather_dictionary_stats/</link>
		<comments>http://mehrajdba.wordpress.com/2009/05/25/gather_fixed_object_stats-and-gather_dictionary_stats/#comments</comments>
		<pubDate>Mon, 25 May 2009 11:56:42 +0000</pubDate>
		<dc:creator>Mohammed Mehraj Hussain</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://mehrajdba.wordpress.com/?p=184</guid>
		<description><![CDATA[There are two procedures in the DBMS_STATS package for gathering statistics on Oracle native objects:
GATHER_FIXED_OBJECT_STATS
GATHER_DICTIONARY_STATS
GATHER_FIXED_OBJECT_STATS collects statistics for fixed X$ and K$ objects. It needs to be run whenever any init.ora parameter is changed. Fixed objects are the magic tables that are not tables &#8211; they are not &#8220;dictionary&#8221; tables. The x$ tables would change [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=184&subd=mehrajdba&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>There are two procedures in the DBMS_STATS package for gathering statistics on Oracle native objects:</p>
<p>GATHER_FIXED_OBJECT_STATS</p>
<p>GATHER_DICTIONARY_STATS<br />
GATHER_FIXED_OBJECT_STATS collects statistics for fixed X$ and K$ objects. It needs to be run whenever any init.ora parameter is changed. Fixed objects are the magic tables that are not tables &#8211; they are not &#8220;dictionary&#8221; tables. The x$ tables would change size in response to init.ora setting changes generally. Setting processes higher will add rows to various x$ views for example.</p>
<p>So, they could be considered a one time thing unless you make a big change to your parameter<br />
settings.</p>
<p>GATHER_DICTIONARY_STATS collects statistics for SYS schema. It needs to be run whenever you do &#8220;big things&#8221; to the dictionary (loaded a schema &#8211; not put data into the schema, but rather did things in the schema that affect the dictionary like creating and dropping objects&#8230;) &#8211; you would consider gathering statistics.</p>
<p>Look at last_analyzed for the sys tables to see when the dictionary was gathered against. Metalink Note 281793.1 states that the DBA_OPTSTAT_OPERATIONS view may be used to determine the start and end time of all DBMS_STATS operations executed at the schema and database level.</p>
Posted in Database  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mehrajdba.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mehrajdba.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mehrajdba.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mehrajdba.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mehrajdba.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mehrajdba.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mehrajdba.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mehrajdba.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mehrajdba.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mehrajdba.wordpress.com/184/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=184&subd=mehrajdba&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mehrajdba.wordpress.com/2009/05/25/gather_fixed_object_stats-and-gather_dictionary_stats/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cbeac91208b1d3d18eaac1a3c87fdf18?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mehraj</media:title>
		</media:content>
	</item>
		<item>
		<title>Materialized view with Unique Index</title>
		<link>http://mehrajdba.wordpress.com/2009/05/19/materialized-view-with-unique-index/</link>
		<comments>http://mehrajdba.wordpress.com/2009/05/19/materialized-view-with-unique-index/#comments</comments>
		<pubDate>Tue, 19 May 2009 04:54:47 +0000</pubDate>
		<dc:creator>Mohammed Mehraj Hussain</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://mehrajdba.wordpress.com/?p=177</guid>
		<description><![CDATA[One of the uses of materialized views is replication. Mviews can be used to replicate a table to another database to prevent users from accessing several databases through database links. This can improve the performance of queries which frequently access that table by removing the latency of the database link.
Today the refresh job of one [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=177&subd=mehrajdba&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>One of the uses of materialized views is replication. Mviews can be used to replicate a table to another database to prevent users from accessing several databases through database links. This can improve the performance of queries which frequently access that table by removing the latency of the database link.</p>
<p>Today the refresh job of one of the mviews we use for this purpose started getting &#8220;ORA-00001 unique constraint violated&#8221; error. This was an mview with a unique index on it. After a simple search in Metalink I have found the reason of this behavior.</p>
<p>I will provide a simple test case to reproduce the problem.</p>
<p>SQL&gt; select * from v$version;</p>
<p>BANNER<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Oracle9i Enterprise Edition Release 9.2.0.8.0 &#8211; 64bit Production<br />
PL/SQL Release 9.2.0.8.0 &#8211; Production<br />
CORE    9.2.0.8.0       Production<br />
TNS for Solaris: Version 9.2.0.8.0 &#8211; Production<br />
NLSRTL Version 9.2.0.8.0 &#8211; Production</p>
<p>SQL&gt; create table master as select rownum r,&#8217;ROW&#8217;||rownum line from all_objects where rownum&lt;=5;<br />
Table created.</p>
<p>SQL&gt; alter table master add primary key(r);</p>
<p>Table altered.</p>
<p>SQL&gt; create unique index master_ind on master(line);</p>
<p>Index created.</p>
<p>SQL&gt; create materialized view log on master with primary key;</p>
<p>Materialized view log created.</p>
<p>SQL&gt; create materialized view snap refresh fast with primary key as select * from master;</p>
<p>Materialized view created.</p>
<p>SQL&gt; create unique index snap_ind on snap(line);</p>
<p>Index created.</p>
<p>SQL&gt; select * from master;</p>
<p>R LINE<br />
&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
1 ROW1<br />
2 ROW2<br />
3 ROW3<br />
4 ROW4<br />
5 ROW5</p>
<p>After these steps we have now one master table, an mview log on it and a fast refreshable mview of the master table. Now we make some updates to the master table to switch the LINE column&#8217;s data of two rows.</p>
<p>SQL&gt; update master set line=&#8217;DUMMY&#8217; where r=1;</p>
<p>1 row updated.</p>
<p>SQL&gt; update master set line=&#8217;ROW1&#8242; where r=2;</p>
<p>1 row updated.</p>
<p>SQL&gt; update master set line=&#8217;ROW2&#8242; where r=1;</p>
<p>1 row updated.</p>
<p>SQL&gt; commit;</p>
<p>Commit complete.</p>
<p>SQL&gt; select * from master;</p>
<p>R LINE<br />
&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
1 ROW2<br />
2 ROW1<br />
3 ROW3<br />
4 ROW4<br />
5 ROW5</p>
<p>Now when we try to refresh the mview we get the error.</p>
<p>SQL&gt; exec dbms_mview.refresh(&#8216;SNAP&#8217;);<br />
BEGIN dbms_mview.refresh(&#8216;SNAP&#8217;); END;</p>
<p>*<br />
ERROR at line 1:<br />
ORA-12008: error in materialized view refresh path<br />
ORA-00001: unique constraint (YAS.SNAP_IND) violated<br />
ORA-06512: at &#8220;SYS.DBMS_SNAPSHOT&#8221;, line 820<br />
ORA-06512: at &#8220;SYS.DBMS_SNAPSHOT&#8221;, line 877<br />
ORA-06512: at &#8220;SYS.DBMS_SNAPSHOT&#8221;, line 858<br />
ORA-06512: at line 1</p>
<p>If we drop the unique index and recreate it as nonunique we can refresh the mview without errors.</p>
<p>SQL&gt; drop index snap_ind;</p>
<p>Index dropped.</p>
<p>SQL&gt; create index snap_ind on snap(line);</p>
<p>Index created.</p>
<p>SQL&gt; exec dbms_mview.refresh(&#8216;SNAP&#8217;);</p>
<p>PL/SQL procedure successfully completed.</p>
<p>SQL&gt; select * from snap;</p>
<p>R LINE<br />
&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
1 ROW2<br />
2 ROW1<br />
3 ROW3<br />
4 ROW4<br />
5 ROW5</p>
<p>The reason of this error is explained in Metalink note 284101.1. According to that note the refresh mechanism may temporarily leave the data in an inconsistent state during the refresh. The modifications are not made with the same order as the modifications to the master table. Because of this creating unique indexes, foreign keys or primary keys on mviews can cause problems in the refresh process. This totally makes sense as it is better to keep the integrity checks on the master table rather than the mview. An mview is just a copy of the master table, so if we define the integrity constraints on the master table the mview will take care of itself.</p>
<p>This behaviour reproduces in 10G also.</p>
Posted in Database  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mehrajdba.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mehrajdba.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mehrajdba.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mehrajdba.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mehrajdba.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mehrajdba.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mehrajdba.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mehrajdba.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mehrajdba.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mehrajdba.wordpress.com/177/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=177&subd=mehrajdba&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mehrajdba.wordpress.com/2009/05/19/materialized-view-with-unique-index/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cbeac91208b1d3d18eaac1a3c87fdf18?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mehraj</media:title>
		</media:content>
	</item>
		<item>
		<title>Monitoring Indexes</title>
		<link>http://mehrajdba.wordpress.com/2009/04/22/monitoring-indexes/</link>
		<comments>http://mehrajdba.wordpress.com/2009/04/22/monitoring-indexes/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 11:01:18 +0000</pubDate>
		<dc:creator>Mohammed Mehraj Hussain</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://mehrajdba.wordpress.com/?p=175</guid>
		<description><![CDATA[The SQL engine maintains all indexes defined against a table regardless of their usage. Index maintenance can cause significant amounts of CPU and I/O usage, which can be detrimental to performance in a write-intensive system. With this in mind, it makes sense to identify and remove any indexes that are not being used as they [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=175&subd=mehrajdba&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The SQL engine maintains all indexes defined against a table regardless of their usage. Index maintenance can cause significant amounts of CPU and I/O usage, which can be detrimental to performance in a write-intensive system. With this in mind, it makes sense to identify and remove any indexes that are not being used as they are a pointless drain on resources. Index monitoring allows unused indexes to be identified accurately, removing the risks associated with dropping useful indexes.</p>
<p>It is important to make sure that index monitoring is performed over a representative time period. If you only monitor indexes during specific time frames you may incorrectly highlight indexes as being unused. The safest method is to use a monitoring period which spans the whole lifecycle of your application, including any OLTP and batch operations. In a Decision Support System (DSS) this may involve a period of weeks or months, while OLTP systems typically have shorter cycles.</p>
<h2>ALTER INDEX</h2>
<p>Index monitoring is started and stopped using the <code>ALTER INDEX</code> syntax shown below.</p>
<blockquote>
<pre>ALTER INDEX my_index_i MONITORING USAGE;
ALTER INDEX my_index_i NOMONITORING USAGE;</pre>
</blockquote>
<p>Information about the index usage can be displayed using the <code>V$OBJECT_USAGE</code> view.</p>
<blockquote>
<pre>SELECT index_name,
       table_name,
       monitoring,
       used,
       start_monitoring,
       end_monitoring
FROM   v$object_usage
WHERE  index_name = 'MY_INDEX_I'
ORDER BY index_name;

------------------------------------------------

SET PAGESIZE 0
SET FEEDBACK OFF
SET VERIFY OFF
SPOOL temp.sql

SELECT 'ALTER INDEX "' || i.owner || '"."' || i.index_name || '" MONITORING USAGE;'
FROM   dba_indexes i
WHERE  owner      = UPPER('&amp;1')
AND    table_name = DECODE(UPPER('&amp;2'), 'ALL', table_name, UPPER('&amp;2'));

SPOOL OFF

SET PAGESIZE 18
SET FEEDBACK ON

@temp.sql

-----------------------------------------------
SET PAGESIZE 0
SET FEEDBACK OFF
SET VERIFY OFF
SPOOL temp.sql

SELECT 'ALTER INDEX "' || i.owner || '"."' || i.index_name || '" NOMONITORING USAGE;'
FROM   dba_indexes i
WHERE  owner      = UPPER('&amp;1')
AND    table_name = DECODE(UPPER('&amp;2'), 'ALL', table_name, UPPER('&amp;2'));

SPOOL OFF

SET PAGESIZE 18
SET FEEDBACK ON

@temp.sql

------------------------------------------------</pre>
</blockquote>
<h2>Foreign Key Indexes</h2>
<p>To quote the Oracle Database Concepts manual:</p>
<blockquote><p>&#8220;You should almost always index foreign keys. The only exception is when the matching unique or primary key is never updated or deleted.&#8221;</p></blockquote>
<p>When a foreign key is unindexed, DML on the parent primary key results in a share row exclusive table lock (or share-subexclusive table lock, SSX) on the child table, preventing DML from other transactions against the child table. If the DML affects several rows in the parent table, the lock on the child table is obtained and released immediately for each row in turn. Despite the speed of the lock-release process, this can cause significant amounts of contention on the child table during periods of heavy update/delete activity on the parent table.</p>
<p>When a foreign key is indexed, DML on the parent primary key results in a row share table lock (or subshare table lock, SS) on the child table. This type of lock prevents other transactions from issuing whole table locks on the child table, but does not block DML on either the parent or the child table. Only the rows relating to the parent primary key are locked in the child table.</p>
Posted in Database  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mehrajdba.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mehrajdba.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mehrajdba.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mehrajdba.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mehrajdba.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mehrajdba.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mehrajdba.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mehrajdba.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mehrajdba.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mehrajdba.wordpress.com/175/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=175&subd=mehrajdba&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mehrajdba.wordpress.com/2009/04/22/monitoring-indexes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cbeac91208b1d3d18eaac1a3c87fdf18?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mehraj</media:title>
		</media:content>
	</item>
		<item>
		<title>Resumable space allocation in 10g</title>
		<link>http://mehrajdba.wordpress.com/2009/03/31/resumable-space-allocation-in-10g/</link>
		<comments>http://mehrajdba.wordpress.com/2009/03/31/resumable-space-allocation-in-10g/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 07:09:04 +0000</pubDate>
		<dc:creator>Mohammed Mehraj Hussain</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://mehrajdba.wordpress.com/?p=172</guid>
		<description><![CDATA[ 
Resumable space allocation, introduced in Oracle 9i, is for all tablespaces at the session level. Database operations are suspended when an out-of-space condition is encountered. These suspended operations automatically resume when the error condition disappears. In Oracle Database 10g, this can be enabled at the instance level. Besides this improvement, automatic alert notification is sent [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=172&subd=mehrajdba&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p> </p>
<p>Resumable space allocation, introduced in Oracle 9i, is for all tablespaces at the session level. Database operations are suspended when an out-of-space condition is encountered. These suspended operations automatically resume when the error condition disappears. In Oracle Database 10g, this can be enabled at the instance level. Besides this improvement, automatic alert notification is sent when an operation is suspended.</p>
<p>In  Oracle 10gR1 the parameter RESUMABLE_TIMEOUT<br />
can also be set on system level for all sessions.<br />
SQL*Plus: Release 10.2.0.4.0 &#8211; Production on Tue Mar 31 11:58:08 2009</p>
<p>Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.</p>
<p>Enter user-name: / as sysdba</p>
<p>Connected to:<br />
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 &#8211; Production<br />
With the Partitioning, OLAP, Data Mining and Real Application Testing options</p>
<p>SQL&gt; create user test identified by test<br />
  2  default tablespace example<br />
  3  quota 1m on example;</p>
<p>User created.</p>
<p>SQL&gt; grant create session ,create table to test;</p>
<p>Grant succeeded.</p>
<p>SQL&gt; conn test<br />
Enter password:<br />
Connected.<br />
SQL&gt; create table t1 (eno number);</p>
<p>Table created.<br />
SQL&gt; BEGIN FOR i IN 1..10000 LOOP<br />
  2   INSERT INTO t1 VALUES(i);<br />
  3  END LOOP;<br />
  4   COMMIT;<br />
  5   END;<br />
  6  /</p>
<p>PL/SQL procedure successfully completed.<br />
SQL&gt;  insert into t1 select * from t1;</p>
<p>10000 rows created.</p>
<p>SQL&gt;  insert into t1 select * from t1;</p>
<p>20000 rows created.</p>
<p>SQL&gt;  insert into t1 select * from t1;<br />
 insert into t1 select * from t1<br />
*<br />
ERROR at line 1:<br />
ORA-01536: space quota exceeded for tablespace &#8216;EXAMPLE&#8217;</p>
<p> </p>
<p>SQL&gt; SELECT COUNT(*) FROM t1;</p>
<p>  COUNT(*)<br />
&#8212;&#8212;&#8212;-<br />
     40000</p>
<p>SQL&gt; ALTER SESSION ENABLE RESUMABLE TIMEOUT 600;<br />
ERROR:<br />
ORA-01031: insufficient privileges<br />
SQL&gt; conn sys as sysdba<br />
Enter password:<br />
Connected.<br />
SQL&gt; grant resumable to test;</p>
<p>Grant succeeded.<br />
SQL&gt; conn test<br />
Enter password:<br />
Connected.<br />
SQL&gt;  insert into t1 select * from t1;<br />
 insert into t1 select * from t1<br />
*<br />
ERROR at line 1:<br />
ORA-01536: space quota exceeded for tablespace &#8216;EXAMPLE&#8217;<br />
SQL&gt; ALTER SESSION ENABLE RESUMABLE TIMEOUT 600;</p>
<p>Session altered.</p>
<p>SQL&gt;  insert into t1 select * from t1;(this statement will wait )</p>
<p> </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;from Another session (session 2) &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>SQL*Plus: Release 10.2.0.4.0 &#8211; Production on Tue Mar 31 12:19:46 2009</p>
<p>Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.<br />
Enter user-name: / as sysdba<br />
SQL&gt; select sid,state,event from v$session_wait where sid=159;</p>
<p>       SID STATE         EVENT<br />
&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>       159 WAITING     statement suspended, wait error to be cleared</p>
<p> </p>
<p>SQL&gt; alter user test quota unlimited on example;</p>
<p>User altered.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;Now check the SESSION 1&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
SQL&gt;  insert into t1 select * from t1;</p>
<p>40000 rows created.</p>
Posted in Database  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mehrajdba.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mehrajdba.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mehrajdba.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mehrajdba.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mehrajdba.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mehrajdba.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mehrajdba.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mehrajdba.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mehrajdba.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mehrajdba.wordpress.com/172/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=172&subd=mehrajdba&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mehrajdba.wordpress.com/2009/03/31/resumable-space-allocation-in-10g/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cbeac91208b1d3d18eaac1a3c87fdf18?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mehraj</media:title>
		</media:content>
	</item>
		<item>
		<title>RMAN -Block change tracking</title>
		<link>http://mehrajdba.wordpress.com/2009/03/17/rman-block-change-tracking/</link>
		<comments>http://mehrajdba.wordpress.com/2009/03/17/rman-block-change-tracking/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 06:41:03 +0000</pubDate>
		<dc:creator>Mohammed Mehraj Hussain</dc:creator>
				<category><![CDATA[RMAN]]></category>

		<guid isPermaLink="false">http://mehrajdba.wordpress.com/?p=167</guid>
		<description><![CDATA[Hello DBA&#8217;S,
In our Production database(10.2.0.4) , currently we are using a backup  stratergy with
a full backup once a month and an incremental backup each week and the archived logs are backed up once a day.
All backups are directly taken in the  tape drives through a network , These tape drives are located in the different [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=167&subd=mehrajdba&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Hello DBA&#8217;S,</p>
<p>In our Production database(10.2.0.4) , currently we are using a backup  stratergy with<br />
a full backup once a month and an incremental backup each week and the archived logs are backed up once a day.<br />
All backups are directly taken in the  tape drives through a network , These tape drives are located in the different server&#8230;</p>
<p>In case of any recovery issues we need to transfer the backup sets from the tape to the disk through the network,so we found that there is some increase in the  recovery time .<br />
And we decided to increase the frequency of the incremental backup in order to reduce its size .So we decided to use the Oracle 10g new feature of Block Change Tracking .</p>
<p><strong>Block change tracking</strong> causes the changed database blocks to be flagged in a file.As data blocks change, the Change Tracking Writer (CTWR) background process tracks the changed blocks in a private area of memory. When a commit is issued against the data block, the block change tracking information is copied to a shared area in Large Pool called the CTWR buffer. During the checkpoint, the CTWR process writes the information from the CTWR RAM buffer to the change-tracking file.To achive this we need to enable the block change traking in our database:</p>
<p>SQL&gt; conn sys as sysdba;<br />
connected.</p>
<p>SQL&gt; SELECT status FROM v$block_change_tracking;</p>
<p>STATUS<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
DISABLED</p>
<p>To enable this you need to create a new file for block change traking.</p>
<p>SQL&gt; ALTER DATABASE ENABLE BLOCK CHANGE TRACKING<br />
  2  using file &#8216;D:\ORACLE\PRODUCT\10.2.0\ORADATA\PRD\change_track_file.dbf&#8217; reuse;</p>
<p>Database altered.</p>
<p>SQL&gt; SELECT status FROM v$block_change_tracking;</p>
<p>STATUS<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
ENABLED</p>
<p>If a block is changed in the database, the fact is recorded in this  file:D:\ORACLE\PRODUCT\10.2.0\ORADATA\PRD\change_track_file.dbf.<br />
During incremental backup, RMAN checks this file to see which blocks need to be backed up instead of checking all the blocks of a data file.</p>
<p>It dramatically reduces CPU cycles and speeds up incremental backup in the process.<br />
The block change tracking file, if present, is used automatically by the incremental backup; no special RMAN syntax is required. Using a block change tracking file saves enough time and CPU cycles  to take incremental backups every  night instead of taking once a week.</p>
<p>In case if you want to disable it ,you can use the below syntax.</p>
<p>SQL&gt; ALTER DATABASE DISABLE BLOCK CHANGE TRACKING;<br />
 <br />
Database altered.</p>
Posted in RMAN  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mehrajdba.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mehrajdba.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mehrajdba.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mehrajdba.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mehrajdba.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mehrajdba.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mehrajdba.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mehrajdba.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mehrajdba.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mehrajdba.wordpress.com/167/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=167&subd=mehrajdba&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mehrajdba.wordpress.com/2009/03/17/rman-block-change-tracking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cbeac91208b1d3d18eaac1a3c87fdf18?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mehraj</media:title>
		</media:content>
	</item>
		<item>
		<title>DBA best practices</title>
		<link>http://mehrajdba.wordpress.com/2009/02/19/dba-best-practices/</link>
		<comments>http://mehrajdba.wordpress.com/2009/02/19/dba-best-practices/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 05:33:22 +0000</pubDate>
		<dc:creator>Mohammed Mehraj Hussain</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://mehrajdba.wordpress.com/?p=160</guid>
		<description><![CDATA[Hi DBA&#8217;s,
I would like to share a nice presentation which has been given by Mr.Arup Nanda ,The President of Proligence and As a recognition of his outstanding accomplishments and contributions to the user community, Oracle awarded Arup the most coveted DBA of the Year Award at Oracle open World in September 2003.
  The following five [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=160&subd=mehrajdba&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Hi DBA&#8217;s,</p>
<p>I would like to share a nice presentation which has been given by <strong>Mr.Arup Nanda</strong> ,The President of Proligence and As a recognition of his outstanding accomplishments and contributions to the user community, Oracle awarded Arup the most coveted DBA of the Year Award at Oracle open World in September 2003.</p>
<p>  The following five essential best practices were derived from his years of experience working with Oracle systems large and small.</p>
<p><em><strong>#1: Multiple Oracle Homes</strong></em></p>
<p>My favorite best practice is the one about multiple Oracle Homes. Here it how it goes. When applying a patch or a patchset, I recommend against applying to the existing Oracle Home. Instead, I suggest creating a new Oracle Home, and apply the patches there. I create the first Oracle Home at /app/oracle/db_1, for instance. When a patch comes out, I install the whole Oracle software in a different home &#8212; /app/oracle/db_2 &#8212; and then apply the patch there. During the process of installation and patch application, the database is up and running, as it runs off the home /db_1. When the outage window comes, all I have to do is to shut down Oracle; change Oracle Home to db_2 and bring the database up. If there is a problem, I can reset the Oracle Home back to the old one.</p>
<p>So, here is the conventional approach:<br />
1.Shut down the database<br />
2.Apply patch to the Oracle Home<br />
3.Start the database In case of problems<br />
4.Shut down the database<br />
5.Roll back the patch<br />
6.Start the database</p>
<p>Steps 2 and 6 could take as much as three hours depending on the amount of patching. The database is down during these times.</p>
<p> In the new approach:<br />
1.Install new Oracle Home<br />
2.Apply the patch to the new Home<br />
3.Shut down the database<br />
4.Change Oracle Home to the new location<br />
5.Start the database<br />
7.In case of problems<br />
8.Shut down the database Change Oracle Home to the old one<br />
9.Start the database</p>
<p>The database is down only during steps 4 and 8, which takes a couple of minutes at the most, not hours.</p>
<p> So, here are the advantages:</p>
<p>1.The downtime is significantly reduced, to one 60th of the original time. 2.The risk is reduced significantly, as there is no rolling back a patch; you just go to the older version.<br />
3.You can perform a &#8220;diff&#8221; on these two homes to see what changed. You can see the differences across multiple homes as well.<br />
4.You can take several databases running on the same server to the new Oracle Home one by one.<br />
5.You can see the various Oracle Homes and what patch level they are on using the inventory.</p>
<p>The only negative part is the space consumption &#8212; you need space for two Oracle Homes. But considering a typical Oracle Home takes about 4 GB or less, this aspect of the suggestion is trivial.</p>
<p><strong><em> #2: Set audit trail to DB</em></strong></p>
<p>Set the audit trail to DB by placing the parameter AUDIT_TRAIL = DB in the initialization parameter file during the database creation. Setting this parameter does not start the auditing, because an explicit AUDIT command must be given on the object. But the parameter must be set to a value other than FALSE (the default) for the command to take effect. Being a non-dynamic parameter, the database must be bounced to change the value of AUDIT_TRAIL. To save the trouble and avoid an outage, always set the value to DB, even if you never intend to audit anything. It does not break anything and you will always be ready to audit when the time comes.</p>
<p><strong><em>#3: Don&#8217;t use .log</em></strong></p>
<p>Don&#8217;t use .log as the extension of redo logs. Someone may run a script to remove all the log files assuming they are redundant and you will end up losing the online redo logs as well, forcing a database recovery. Instead, name them with extension &#8220;redo&#8221; or &#8220;rdo.&#8221;</p>
<p><strong><em>#4: Preview RMAN Restore</em></strong></p>
<p> Preview RMAN Restore to identify all the various backup pieces that will be used in the recovery process without doing an actual recovery. This eliminates any surprises from missing pieces during an actual recovery process.</p>
<p><strong><em>#5: Create a new Oracle user for clients running on the same server as the DB</em></strong></p>
<p>The Oracle Database server software also contains the client piece, which allows the clients to connect to the database on the same server. But as a best practice do not use the same user or the software; use a new one. For instance, if &#8220;oracle&#8221; is the user to install Oracle software, create a new user called, say, &#8220;oraapp&#8221; and install the client-only software using that user. The user &#8220;oraapp&#8221; should not be part of the dba or the oinstall group; so this user can&#8217;t log on to the database as sysdba. Create a new group called &#8220;appgrp&#8221; and assign the user oraaap to this group. All the application users on the box should also be part of the appgrp group. This way they can use the sqlplus, sqlldr and other executables on the server, but be able to connect as sysdba. The common practice is to use the client software in the same user as the database software owner; but starting with 10.2, Oracle has changed the security policy that takes away the global execution permissions from the Oracle Home. So the only option is to let app users be part of the dba group or change the permissions on Oracle Home &#8212; both make the database extremely vulnerable.</p>
Posted in Database  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mehrajdba.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mehrajdba.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mehrajdba.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mehrajdba.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mehrajdba.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mehrajdba.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mehrajdba.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mehrajdba.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mehrajdba.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mehrajdba.wordpress.com/160/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=160&subd=mehrajdba&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mehrajdba.wordpress.com/2009/02/19/dba-best-practices/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cbeac91208b1d3d18eaac1a3c87fdf18?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mehraj</media:title>
		</media:content>
	</item>
		<item>
		<title>Materialized Views</title>
		<link>http://mehrajdba.wordpress.com/2009/02/11/materialized-views/</link>
		<comments>http://mehrajdba.wordpress.com/2009/02/11/materialized-views/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 06:01:44 +0000</pubDate>
		<dc:creator>Mohammed Mehraj Hussain</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://mehrajdba.wordpress.com/?p=128</guid>
		<description><![CDATA[A materialized view  is a database object that contains the results of a query. They are local copies of data located remotely, or are used to create summary tables based on aggregations of a table’s data. Materialized views, which store data based on remote tables are also, know as snapshots (in previous versions of oracle), [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=128&subd=mehrajdba&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A <strong>materialized view </strong> is a database object that contains the results of a query. They are local copies of data located remotely, or are used to create summary tables based on aggregations of a table’s data. Materialized views, which store data based on remote tables are also, know as snapshots (in previous versions of oracle), Materialized Views can increase many times the speed of queries that access huge data records</p>
<p>When you create a materialized view, Oracle Database creates one internal table and at least one index, and may create one view, all in the schema of the materialized view. Oracle Database uses these objects to maintain the materialized view data. You must have the privileges necessary to create these objects.</p>
<p>The following types of refresh methods are supported by Oracle.</p>
<p>Complete &#8211; build from scratch<br />
Fast &#8211; only apply the data changes<br />
Force &#8211; try a fast refresh, if that is not possible, do a complete refresh<br />
Never &#8211; never refresh the materialized view<br />
<strong></strong></p>
<p><strong>Materialized View Log:</strong></p>
<p>When DML changes are made to master table data, Oracle Database stores rows describing those changes in the materialized view log and then uses the materialized view log to refresh materialized views based on the master table. This process is called incremental or fast refresh. Without a materialized view log, Oracle Database must re-execute the materialized view query to refresh the materialized view. This process is called a complete refresh. Usually, a fast refresh takes less time than a complete refresh.</p>
<p>A materialized view log is located in the master database in the same schema as the master table. A master table can have only one materialized view log defined on it. Oracle Database can use this materialized view log to perform fast refreshes for all fast-refreshable materialized views based on the master table.</p>
<p>To fast refresh a materialized join view, you must create a materialized view log for each of the tables referenced by the materialized view.</p>
<p><strong>Privileges required:</strong></p>
<p>create materialized view<br />
create any materialized view<br />
drop any materialized view<br />
delete any table<br />
insert any table<br />
lock any table<br />
select any table<br />
under any table<br />
update any table<br />
create table<br />
create view</p>
<p>There is one mandatory INIT.ORA parameter necessary for materialized views to function, this is the COMPATIBLE parameter. The value of COMPATIBLE should be set to 8.1.0, or above, in order for query rewrites to be functional. If this value is not set appropriately, query rewrite will not be invoked.</p>
<p>There are two other relevant parameters that may be set at either the system-level via the INIT.ORA file, or the session-level via the ALTER SESSION command.</p>
<p>       QUERY_REWRITE_ENABLED</p>
<p>Unless the value of this parameter is set to TRUE, query rewrites will not take place. The default value is FALSE.</p>
<p>       QUERY REWRITE INTEGRITY<br />
This parameter controls how Oracle rewrites queries and may be set to one of three values:</p>
<p>ENFORCED &#8211; Queries will be rewritten using only constraints and rules that are enforced and guaranteed by Oracle. There are mechanisms, by which we can tell Oracle about other inferred relationships, and this would allow for more queries to be rewritten, but since Oracle does not enforce those relationships, it would not make use of these facts at this level.</p>
<p>TRUSTED &#8211; Queries will be rewritten using the constraints that are enforced by Oracle, as well as any relationships existing in the data that we have told Oracle about, but are not enforced by the database.</p>
<p>STALE TOLERATED &#8211; Queries will be rewritten to use materialized views even if Oracle knows the data contained in the materialized view is ‘ stale ‘ (out-of-sync with the details). This might be useful in an environment where the summary tables are refreshed on a recurring basis, not on commit, and a slightly out-of-sync answer is acceptable.</p>
<p><strong></strong></p>
<p><strong>Syntax (Fast Refresh)</strong></p>
<p>CREATE MATERIALIZED VIEW &lt;schema.name&gt;<br />
PCTFREE &lt;integer&gt;<br />
PCTUSED &lt;integer&gt;<br />
TABLESPACE &lt;tablespace_name&gt;<br />
BUILD IMMEDIATE<br />
REFRESH &lt;FAST | FORCE&gt; ON &lt;COMMIT | DEMAND&gt;<br />
&lt;USING INDEX | USING NO INDEX&gt;<br />
INITRANS &lt;integer&gt;<br />
STORAGE CLAUSE<br />
AS (&lt;SQL statement&gt;);</p>
<p>Example: (Here we need to create a materialized view log first)</p>
<p>CREATE MATERIALIZED VIEW LOG ON employees;</p>
<p>CREATE MATERIALIZED VIEW mv_fast<br />
TABLESPACE example<br />
BUILD IMMEDIATE<br />
REFRESH FAST ON COMMIT AS<br />
SELECT * FROM employees;<br />
<strong></strong></p>
<p><strong>Syntax (Force Refresh)</strong></p>
<p>CREATE MATERIALIZED VIEW &lt;schema.name&gt;<br />
PCTFREE &lt;integer&gt;<br />
PCTUSED &lt;integer&gt;<br />
TABLESPACE &lt;tablespace_name&gt;<br />
BUILD IMMEDIATE<br />
REFRESH &lt;FAST | FORCE&gt; ON &lt;COMMIT | DEMAND&gt;<br />
AS (&lt;SQL statement&gt;);</p>
<p> Example:</p>
<p>CREATE MATERIALIZED VIEW mv_force<br />
TABLESPACE example<br />
NOCACHE<br />
LOGGING<br />
NOCOMPRESS<br />
NOPARALLEL<br />
BUILD IMMEDIATE<br />
REFRESH FORCE ON DEMAND<br />
WITH ROWID AS<br />
SELECT * FROM employees;<br />
<strong></strong></p>
<p><strong>Syntax (Complete Refresh)</strong></p>
<p>CREATE MATERIALIZED VIEW &lt;schema.name&gt;<br />
PCTFREE &lt;integer&gt;<br />
PCTUSED &lt;integer&gt;<br />
TABLESPACE &lt;tablespace_name&gt;<br />
REFRESH &lt;COMPLETE | FORCE&gt;<br />
START WITH &lt;date&gt;<br />
NEXT &lt;date_calculation&gt;<br />
[FOR UPDATE]<br />
AS (&lt;SQL statement&gt;);</p>
<p> Example:</p>
<p>CREATE MATERIALIZED VIEW mv_complete<br />
TABLESPACE example<br />
REFRESH COMPLETE<br />
START WITH SYSDATE<br />
NEXT SYSDATE + 1<br />
AS SELECT a.employee_id,a.last_name,a.salary,b.department_id<br />
from employees a,departments b<br />
where a.department_id=b.department_id;<br />
Materialized views significantly improves the performance of Oracle systems required to process complex SQL statements.<br />
<strong></strong></p>
<p><strong>&#8212;&#8212;&#8212;&#8212;&#8212;A Performance Test on Materialized views&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</strong></p>
<p>SQL&gt; create table sample as select rownum as id, owner,object_name , object_type from all_objects ;</p>
<p>Table created.<br />
SQL&gt; CREATE INDEX ind ON sample(ID);</p>
<p>Index created.<br />
SQL&gt; analyze table sample compute statistics;</p>
<p>Table analyzed.<br />
SQL&gt; set autotrace traceonly;</p>
<p>SQL&gt; set timing on</p>
<p>SQL&gt;  select owner,count(object_name) from sample group by owner;</p>
<p>24 rows selected.</p>
<p>Elapsed: 00:00:00.10</p>
<p>Execution Plan<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Plan hash value: 3791231185</p>
<p>Execution Plan<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Plan hash value: 3791231185</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
| Id  | Operation          | Name   | Rows  | Bytes | Cost (%CPU)| Time     |<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
|   0 | SELECT STATEMENT   |        |    24 |   120 |    87  (11)| 00:00:02 |<br />
|   1 |  HASH GROUP BY     |        |    24 |   120 |    87  (11)| 00:00:02 |<br />
|   2 |   TABLE ACCESS FULL| SAMPLE | 49717 |   242K|    80   (3)| 00:00:01 |<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Statistics<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
          1      recursive calls<br />
          0     db block gets<br />
        337  consistent gets<br />
          0     physical reads<br />
          0     redo size<br />
        955  bytes sent via SQL*Net to client<br />
        392  bytes received via SQL*Net from client<br />
          3      SQL*Net roundtrips to/from client<br />
          0      sorts (memory)<br />
          0      sorts (disk)<br />
         24     rows processed</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;Login as a SYS user&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
SQL&gt; conn / as sysdba<br />
Connected.</p>
<p>SQL&gt; grant query rewrite to hr;</p>
<p>Grant succeeded.</p>
<p> </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;Login Back to HR user&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>SQL&gt; conn hr/hr;<br />
Connected.</p>
<p>SQL&gt; alter session set query_rewrite_enabled=true;</p>
<p>Session altered.<br />
SQL&gt;  alter session set query_rewrite_integrity=enforced;</p>
<p>Session altered.</p>
<p> </p>
<p>SQL&gt; create materialized view mv_sample<br />
  2  build immediate<br />
  3  refresh on commit<br />
  4  enable query rewrite<br />
  5  as<br />
  6 select owner,count(object_name) from sample group by owner;</p>
<p>Materialized view created.</p>
<p>Elapsed: 00:00:00.65<br />
SQL&gt; analyze table mv_sample compute statistics;</p>
<p>Table analyzed.</p>
<p>Elapsed: 00:00:00.03<br />
SQL&gt; set autotrace traceonly<br />
SQL&gt;  select owner,count(object_name) from sample group by owner;</p>
<p>24 rows selected.</p>
<p>Elapsed: 00:00:00.18</p>
<p>Execution Plan<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Plan hash value: 1060132680</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
| Id  | Operation                    | Name      | Rows  | Bytes | Cost (%CPU)| Time     |<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
|   0 | SELECT STATEMENT             |           |    24 |   216 |     3   (0)| 00:00:01 |<br />
|   1 |  MAT_VIEW REWRITE ACCESS FULL| MV_SAMPLE |    24 |   216 |     3   (0)| 00:00:01 |<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Statistics<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
          0  recursive calls<br />
          0  db block gets<br />
          5  consistent gets<br />
          0  physical reads<br />
          0  redo size<br />
        955  bytes sent via SQL*Net to client<br />
        392  bytes received via SQL*Net from client<br />
          3  SQL*Net roundtrips to/from client<br />
          0  sorts (memory)<br />
          0  sorts (disk)<br />
         24  rows processed</p>
Posted in Database  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mehrajdba.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mehrajdba.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mehrajdba.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mehrajdba.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mehrajdba.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mehrajdba.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mehrajdba.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mehrajdba.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mehrajdba.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mehrajdba.wordpress.com/128/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=128&subd=mehrajdba&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mehrajdba.wordpress.com/2009/02/11/materialized-views/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cbeac91208b1d3d18eaac1a3c87fdf18?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mehraj</media:title>
		</media:content>
	</item>
		<item>
		<title>Index Clustering Factor</title>
		<link>http://mehrajdba.wordpress.com/2009/02/09/index-clustering-factor/</link>
		<comments>http://mehrajdba.wordpress.com/2009/02/09/index-clustering-factor/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 05:19:39 +0000</pubDate>
		<dc:creator>Mohammed Mehraj Hussain</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://mehrajdba.wordpress.com/?p=116</guid>
		<description><![CDATA[The clustering factor is a number which represent the degree to which data is randomly distributed in a table. In simple terms it is the number of “block switches” while reading a table using an index
 
Figure: Bad clustering factor
The above diagram explains that how scatter the rows of the table are. The first index entry [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=116&subd=mehrajdba&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The clustering factor is a number which represent the degree to which data is randomly distributed in a table. In simple terms it is the number of “block switches” while reading a table using an index</p>
<p> <img class="alignnone size-full wp-image-115" title="bad_cf1" src="http://mehrajdba.files.wordpress.com/2009/02/bad_cf1.png?w=333&#038;h=153" alt="bad_cf1" width="333" height="153" /></p>
<p><em>Figure: Bad clustering factor</em></p>
<p>The above diagram explains that how scatter the rows of the table are. The first index entry (from left of index) points to the first data block and second index entry points to second data block. So while making index range scan or full index scan, optimizer have to switch between blocks and have to revisit the same block more than once because rows are scatter. So the number of times optimizer will make these switches is actually termed as <em>“Clustering factor”.</em></p>
<p><em><img class="alignnone size-full wp-image-117" title="good_cf" src="http://mehrajdba.files.wordpress.com/2009/02/good_cf.png?w=345&#038;h=166" alt="good_cf" width="345" height="166" /></em></p>
<p> <em>Figure: Good clustering factor</em>The above image represents &#8220;Good CF”. In an event of index range scan, optimizer will not have to jump to next data block as most of the index entries points to same data block. This helps significantly in reducing the cost of your SELECT statements.</p>
<p> </p>
<p>Clustering factor is stored in data dictionary and can be viewed from dba_indexes (or user_indexes)</p>
<p>SQL&gt; create table sac as select * from all_objects;</p>
<p>Table created.</p>
<p>SQL&gt; create index obj_id_indx on sac(object_id);</p>
<p>Index created.</p>
<p>SQL&gt; select clustering_factor from user_indexes where index_name=&#8217;OBJ_ID_INDX&#8217;;</p>
<p>CLUSTERING_FACTOR<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
545</p>
<p>SQL&gt; select count(*) from sac;</p>
<p>COUNT(*)<br />
&#8212;&#8212;&#8212;-<br />
38956</p>
<p>SQL&gt; select blocks from user_segments where segment_name=&#8217;OBJ_ID_INDX&#8217;;</p>
<p>BLOCKS<br />
&#8212;&#8212;&#8212;-<br />
96</p>
<p>The above example shows that index has to jump 545 times to give you the full data had you performed full table scan using the index.</p>
<p><strong><span style="text-decoration:underline;">Note:</span></strong><br />
- A good CF is equal (or near) to the values of number of blocks of table.</p>
<p>- A bad CF is equal (or near) to the number of rows of table.</p>
<p><strong><span style="text-decoration:underline;">Myth:</span></strong><br />
- Rebuilding of index can improve the CF.</p>
<p><strong><span style="text-decoration:underline;">Then how to improve the CF?<br />
</span></strong><br />
- To improve the CF, it’s the table that must be rebuilt (and reordered).<br />
- If table has multiple indexes, careful consideration needs to be given by which index to order table.</p>
<p> References:</p>
<p> Cost-Based Oracle Fundamentals:By: <strong>Jonathan Lewis</strong></p>
<p><img class="alignnone size-thumbnail wp-image-125" title="cbo2" src="http://mehrajdba.files.wordpress.com/2009/02/cbo2.jpg?w=72&#038;h=96" alt="cbo2" width="72" height="96" /></p>
Posted in Database  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mehrajdba.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mehrajdba.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mehrajdba.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mehrajdba.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mehrajdba.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mehrajdba.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mehrajdba.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mehrajdba.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mehrajdba.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mehrajdba.wordpress.com/116/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=116&subd=mehrajdba&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mehrajdba.wordpress.com/2009/02/09/index-clustering-factor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cbeac91208b1d3d18eaac1a3c87fdf18?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mehraj</media:title>
		</media:content>

		<media:content url="http://mehrajdba.files.wordpress.com/2009/02/bad_cf1.png" medium="image">
			<media:title type="html">bad_cf1</media:title>
		</media:content>

		<media:content url="http://mehrajdba.files.wordpress.com/2009/02/good_cf.png" medium="image">
			<media:title type="html">good_cf</media:title>
		</media:content>

		<media:content url="http://mehrajdba.files.wordpress.com/2009/02/cbo2.jpg?w=72" medium="image">
			<media:title type="html">cbo2</media:title>
		</media:content>
	</item>
		<item>
		<title>To change the Database name using NID utility</title>
		<link>http://mehrajdba.wordpress.com/2009/01/31/to-change-the-database-name-using-nid-utiliy/</link>
		<comments>http://mehrajdba.wordpress.com/2009/01/31/to-change-the-database-name-using-nid-utiliy/#comments</comments>
		<pubDate>Sat, 31 Jan 2009 10:53:11 +0000</pubDate>
		<dc:creator>Mohammed Mehraj Hussain</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://mehrajdba.wordpress.com/2009/01/31/to-change-the-database-name-using-nid-utiliy/</guid>
		<description><![CDATA[1)Make a whole database backup.
2)Login as a sys user..
sql&#62;conn sys as sysdba
3)Check your database name
sql&#62;SELECT nameFROM v$database;
NAME
&#8212;&#8212;&#8212;
ORCL
4)Make a proper shutdown of the database 
here you can user immediate or transactional or normal
sql&#62;SHUTDOWN IMMEDIATE
5) Invoke the newid utility 
C:\mohd.dba&#62;nid TARGET=system/manager@orcl DBNAME=newdb SETNAME=Y
DBNEWID: Release 10.2.0.1.0 &#8211; Production on Sat Jan 31 12:45:03 2009
Copyright (c) 1982, 2005, Oracle. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=108&subd=mehrajdba&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>1)Make a whole database backup.</p>
<p>2)Login as a sys user..</p>
<p>sql&gt;conn sys as sysdba</p>
<p>3)Check your database name</p>
<p>sql&gt;SELECT nameFROM v$database;</p>
<p>NAME<br />
&#8212;&#8212;&#8212;<br />
ORCL</p>
<p>4)Make a proper shutdown of the database </p>
<p>here you can user immediate or transactional or normal</p>
<p>sql&gt;SHUTDOWN IMMEDIATE</p>
<p>5) Invoke the newid utility </p>
<p>C:\mohd.dba&gt;nid TARGET=system/manager@orcl DBNAME=newdb SETNAME=Y</p>
<p>DBNEWID: Release 10.2.0.1.0 &#8211; Production on Sat Jan 31 12:45:03 2009</p>
<p>Copyright (c) 1982, 2005, Oracle.  All rights reserved.</p>
<p>Connected to database ORCL (DBID=1203749959)</p>
<p>Connected to server version 10.2.0</p>
<p>Control Files in database:<br />
    G:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL01.CTL<br />
    G:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL02.CTL<br />
    G:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL03.CTL</p>
<p>Changing database name from ORCL to NEWDB<br />
    Control File G:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL01.CTL &#8211; modified<br />
    Control File G:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL02.CTL &#8211; modified<br />
    Control File G:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL03.CTL &#8211; modified<br />
    Datafile G:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF &#8211; wrote new name<br />
    Datafile G:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF &#8211; wrote new name<br />
    Datafile G:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF &#8211; wrote new name<br />
    Datafile G:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF &#8211; wrote new name<br />
    Datafile G:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF &#8211; wrote new name<br />
    Datafile G:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEMP01.DBF &#8211; wrote new name<br />
    Control File G:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL01.CTL &#8211; wrote new name<br />
    Control File G:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL02.CTL &#8211; wrote new name<br />
    Control File G:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL03.CTL &#8211; wrote new name<br />
    Instance shut down</p>
<p>Database name changed to NEWDB.<br />
Modify parameter file and generate a new password file before restarting.<br />
Succesfully changed database name.<br />
DBNEWID &#8211; Completed succesfully.</p>
<p>6)Edit the pfile to change the db_name:</p>
<p>change the db_name parameter in the pfile to the new database name</p>
<p>db_name=newdb</p>
<p>7)Create a new password file using the ORAPWD utility</p>
<p>C:\mohd.dba&gt;orapwd file=orapw001 password=confidential entries=10</p>
<p>8)Start the database using pfile:</p>
<p>sql&gt;conn sys as sysdba</p>
<p>sql&gt;startup  pfile =G:\oracle\product\10.2.0\admin\orcl\pfile\init.ora.0122009171812</p>
<p>9)Recreate the spfile from the pfile </p>
<p>sql&gt; create spfile from pfile=&#8217;G:\oracle\product\10.2.0\admin\orcl\pfile\init.ora.0122009171812&#8242;;</p>
<p>10) start the database using spfile:</p>
<p>SQL&gt; startup force;<br />
ORACLE instance started.</p>
<p>Total System Global Area  289406976 bytes<br />
Fixed Size                  1248600 bytes<br />
Variable Size              92275368 bytes<br />
Database Buffers          192937984 bytes<br />
Redo Buffers                2945024 bytes<br />
Database mounted.<br />
Database opened.</p>
Posted in Database  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mehrajdba.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mehrajdba.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mehrajdba.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mehrajdba.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mehrajdba.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mehrajdba.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mehrajdba.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mehrajdba.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mehrajdba.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mehrajdba.wordpress.com/108/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mehrajdba.wordpress.com&blog=5749578&post=108&subd=mehrajdba&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://mehrajdba.wordpress.com/2009/01/31/to-change-the-database-name-using-nid-utiliy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cbeac91208b1d3d18eaac1a3c87fdf18?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mehraj</media:title>
		</media:content>
	</item>
	</channel>
</rss>