<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2enclosuresfull.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>ORACLE: DBA's day out</title><link>http://shaharear.blogspot.com/</link><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/shaharear" /><description>A blog about Oracle administration &amp;amp; configuration.</description><language>en</language><managingEditor>noreply@blogger.com (Hasan Shaharear)</managingEditor><lastBuildDate>Thu, 16 Feb 2012 06:12:21 PST</lastBuildDate><generator>Blogger http://www.blogger.com</generator><openSearch:totalResults xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">111</openSearch:totalResults><openSearch:startIndex xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">1</openSearch:startIndex><openSearch:itemsPerPage xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">25</openSearch:itemsPerPage><feedburner:info uri="shaharear" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><media:category scheme="http://www.itunes.com/dtds/podcast-1.0.dtd">Technology/Software How-To</media:category><itunes:owner><itunes:email>noreply@blogger.com</itunes:email></itunes:owner><itunes:explicit>no</itunes:explicit><itunes:subtitle>A blog about Oracle administration &amp;amp; configuration.</itunes:subtitle><itunes:category text="Technology"><itunes:category text="Software How-To" /></itunes:category><creativeCommons:license>http://creativecommons.org/licenses/by/2.0/</creativeCommons:license><image><link>http://creativecommons.org/licenses/by/2.0/</link><url>http://creativecommons.org/images/public/somerights20.gif</url><title>Some Rights Reserved</title></image><feedburner:emailServiceId>shaharear</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item><title>CTAS : Create Table as</title><link>http://feedproxy.google.com/~r/shaharear/~3/QLA0ULDmmy8/ctas-create-table-as.html</link><category>SQL PL/SQL Tips</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Thu, 12 Jan 2012 18:58:35 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-2963435682786477245</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/JQzzJg5pUpaGShvSTy3Ums8jZiI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/JQzzJg5pUpaGShvSTy3Ums8jZiI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/JQzzJg5pUpaGShvSTy3Ums8jZiI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/JQzzJg5pUpaGShvSTy3Ums8jZiI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;We all are very familiar with CTAS or 'Create Table as' clause that used to construct new table and populated it with data extract by 'Select' statement. That means table creation and population are done by executing a single sql CTAS statement.&lt;br /&gt;&lt;br /&gt;Fom example,&lt;br /&gt;&lt;br /&gt;CREATE TABLE employee_info As&lt;br /&gt;SELECT  emp.id, emp.name, dp.name FROM employee emp, department dp WHERE emp.dp_id =dp.id;&lt;br /&gt;&lt;br /&gt;The above CTAS statment create a new table named 'employee_info' and store the result of SELECT statement into that table.&lt;br /&gt;&lt;br /&gt;Here are some common use of CTAS statement:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Store the result of select statement into a table.&lt;/li&gt;&lt;li&gt;create a duplicate table for backup purpose.&lt;/li&gt;&lt;li&gt;Reorganize existing table for better performance.&lt;/li&gt;&lt;/ul&gt;There are some limitations of CTAS statement:&lt;br /&gt;&lt;ul&gt;&lt;li&gt; Can't create indexes ( in case of table duplication or Reorganization).&lt;/li&gt;&lt;li&gt;Can't create primary, unique or foreign key constraints ( in case of table duplication or Reorganization). But it can create 'NOT NULL' constraint.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Though CTAS mirrors metadata structure, it can't mirror 'DEFAULT' value checker for columns.&lt;/li&gt;&lt;/ul&gt;I have learned the 3rd pitfall of CTAS recently. I used CTAS to construct a duplicate table ( a sub task of table partitioning). The partitioning job was successful but the problem arose when we inserted new rows into the partitioned table. One of the column got null value stored instead of zero (the column's default value was zero). Through an investigation we discover that CATS statement skipped default value check of that column.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-2963435682786477245?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/QLA0ULDmmy8" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-13T08:58:35.734+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2012/01/ctas-create-table-as.html</feedburner:origLink></item><item><title>SPM - SQL PLAN MANAGER</title><link>http://feedproxy.google.com/~r/shaharear/~3/L0qIAC1i8JM/spm-sql-plan-manager.html</link><category>Oracle Tuning</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Wed, 28 Dec 2011 03:53:22 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-7360520121791953346</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/C9QAEwL8QbehkQbsSY3yaFwd0BQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/C9QAEwL8QbehkQbsSY3yaFwd0BQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/C9QAEwL8QbehkQbsSY3yaFwd0BQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/C9QAEwL8QbehkQbsSY3yaFwd0BQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;As a &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;DBA&lt;/span&gt; some I feel that Oracle is living thing ! for example query performance. Out of no where a gentle looking &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; statement may pop up your top time consuming query list. A &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;sql&lt;/span&gt; query which gives efficient performance in 3 months ago (Or even  week ago), now giving horrible performance that threatening you cool database performance :)&lt;br /&gt;&lt;br /&gt;Yes, we all &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;DBA&lt;/span&gt; know that a gentle statement can screwed up due to&lt;br /&gt;- Re-&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;guthering&lt;/span&gt; optimizer statistics&lt;br /&gt;- Change in optimizes parameters&lt;br /&gt;- Change in Schema? Object structure (i.e, &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;metadata&lt;/span&gt; definition)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Though Optimizer always try to choose list expensive plan for each &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; statement execution, Some time It (optimizer) choose expensive plans and raise annoying situations for peace loving &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;DBAs&lt;/span&gt; :)&lt;br /&gt;&lt;br /&gt;Well Oracle 11g come up with a new feature that can handle such weird situation. The simplest solution we can think is a mechanism that only allow trusted &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; plans to be executed and reject untrusted plans. O Yes Oracle 11g gives us a manager named &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SPM&lt;/span&gt; that do the same thing.&lt;br /&gt;&lt;br /&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; PLAN MANAGER (&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SPM&lt;/span&gt;) has three major components&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; Plan Baseline Capture - Create  &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; Plan Baseline for trusted (accepted) &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; plans.&lt;/li&gt;&lt;li&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; Plan Baseline Selection - Conform that only accepted &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQl&lt;/span&gt; plans are used when an &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; statement is executed.&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; Plan Baseline Evolution - Evaluated all &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; Plans (old &amp;amp; new) for each &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; statement. The new/old plan will only be excepted if it gives better or equal performance compared with existing trusted plan otherwise rejected. (If no trusted plan exist then current plan will be accepted)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;To enable this cool feature we just do the followings&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;ALTER SYSTEM set optimizer_capture_&lt;/span&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; font-style: italic;" class="J-JK9eJ-PJVNOc"&gt;sql&lt;/span&gt;&lt;span style="font-style: italic;"&gt;_plan_baselines= TRUE scope=both;&lt;/span&gt; [Default value is false]&lt;br /&gt;&lt;span style="font-style: italic;"&gt;ALTER SYSTEM set optimizer_user_&lt;/span&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; font-style: italic;" class="J-JK9eJ-PJVNOc"&gt;sql&lt;/span&gt;&lt;span style="font-style: italic;"&gt;_plan_baselines= TRUE scope=both; &lt;/span&gt;[Default value is true, so just check the parameter value]&lt;br /&gt;&lt;br /&gt;You are done ! Keep an eye in &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;DBA&lt;/span&gt;_&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt;_PLAN_BASELINES view and enjoying &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SPM's&lt;/span&gt; magic&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-7360520121791953346?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/L0qIAC1i8JM" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-28T17:53:22.074+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2011/12/spm-sql-plan-manager.html</feedburner:origLink></item><item><title>TABLE_EXISTS_ACTION</title><link>http://feedproxy.google.com/~r/shaharear/~3/8DY6iuB-YpI/tableexistsaction.html</link><category>Export-Import</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Tue, 27 Dec 2011 01:44:13 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-5354736727644668921</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/KiFTCfl9JxP3WuZACZdU1F3fF58/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/KiFTCfl9JxP3WuZACZdU1F3fF58/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/KiFTCfl9JxP3WuZACZdU1F3fF58/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/KiFTCfl9JxP3WuZACZdU1F3fF58/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Those who are familiar with oracle data pump may know very well about TABLE_EXISTS_ACTION import (impdp) parameter.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;TABLE_EXISTS_ACTION = {SKIP | APPEND | TRUNCATE | REPLACE}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This parameter is used when you import a table which is already exists in import schema. The default value is '&lt;span style="font-weight: bold;"&gt;SKIP&lt;/span&gt;', so if you not use this parameter and &lt;span style="font-style: italic;"&gt;impdp&lt;/span&gt; found that the table which to be imported is already exist then &lt;span style="font-style: italic;"&gt;impdp &lt;/span&gt;skip this table from import list.&lt;br /&gt;&lt;br /&gt;Now you may interested about rest of the three values-&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;APPEND &lt;/span&gt;- The import will be done if the   table does not have any Primary key or Unique key constraints.  If such constraint exists then you need to ensure that append operation does not violate Primary key or Unique key constraints (that means it does not occur data duplication).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;TRUNCATE&lt;/span&gt; - If the table is not a parent table ( i.e, No other table references it by creating foreign key constraint) then it truncate the existing data and load data from dump file. Otherwise data will not be loaded.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;REPLACE&lt;/span&gt; - This is the most tricky value of TABLE_EXISTS_ACTION parameter. If the importing table is a parent table ( i.e, other table references it by creating foreign key constraint ) then the foreign key will be deleted from child table.  All existing data will be replaced with imported data.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-5354736727644668921?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/8DY6iuB-YpI" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-27T15:44:13.760+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2011/12/tableexistsaction.html</feedburner:origLink></item><item><title>ORA-08102</title><link>http://feedproxy.google.com/~r/shaharear/~3/xk13b-N3BW8/ora-08102.html</link><category>ERROR: ORA-</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Wed, 19 Oct 2011 04:14:53 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-1436207338000763634</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ltrEhulQQqcGmKmmAtV_eG2M9hY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ltrEhulQQqcGmKmmAtV_eG2M9hY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ltrEhulQQqcGmKmmAtV_eG2M9hY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ltrEhulQQqcGmKmmAtV_eG2M9hY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;span style="font-weight: bold;"&gt;ORA-08102&lt;/span&gt;: index key not found, obj# 630, file 1, block 4353&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Cause:&lt;/b&gt;   Internal error: possible inconsistency in index.&lt;br /&gt;&lt;br /&gt;    &lt;b&gt;Action:&lt;/b&gt;   Send trace file to your customer support representative, along with information on reproducing the error&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Well I don't have access to oracle support (if you need it, you need to buy that service). So first of all, I tried to identify which index cause that problem.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;select * from dba_objects x where x.object_id=630;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Guess what ? it's an index own by 'SYS' user. So I issued index rebuild command and it didn't work. As the index lies in system tablespace, I didn't want to move it to other tablespace. Thus I droped and created the index again.&lt;br /&gt;&lt;br /&gt;It works. Previously, I thought that 'REBUILD' command internaly drop an object and recreate it. But, now I need to explore 'How rebuild command works ?'.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-1436207338000763634?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/xk13b-N3BW8" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-19T17:14:53.081+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2011/10/ora-08102.html</feedburner:origLink></item><item><title>ORA-01591: lock held by in-doubt distributed transaction string</title><link>http://feedproxy.google.com/~r/shaharear/~3/dclj2AOkKBM/ora-01591-lock-held-by-in-doubt.html</link><category>ERROR: ORA-</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Mon, 17 Oct 2011 01:17:06 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-8774073762964882674</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/EDDxS-6ZbafwQzopo1103YJsqPQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/EDDxS-6ZbafwQzopo1103YJsqPQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/EDDxS-6ZbafwQzopo1103YJsqPQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/EDDxS-6ZbafwQzopo1103YJsqPQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;span style="font-weight: bold;"&gt;Cause: &lt;/span&gt;    Trying to access resource that is locked by a dead two-phase commit transaction that is in prepared state.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Action:&lt;/span&gt;     DBA should query the DBA_PENDING_TRANSACTIONS and DBA_2PC_PENDING, and attempt to repair network connection(s) to coordinator and commit point. If timely repair is not possible, DBA should contact end user for rollback/commit the transection.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;sqlplus / as sysdba;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;SQL&amp;gt; SELECT * FROM DBA_2PC_PENDING;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;SQL&amp;gt; ROLLBACK FORCE LOCAL_TRAN_ID;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;SQL&amp;gt; commit;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;SQL&amp;gt; alter system enable distributed recovery;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;SQL&amp;gt; execute dbms_transaction.purge_lost_db_entry('LOCAL_TRAN_ID');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;SQL &amp;gt; commit;&lt;br /&gt;&lt;br /&gt;For more details plese go through this &lt;a href="http://download.oracle.com/docs/cd/B28359_01/server.111/b28310/ds_txnman007.htm#i1008132"&gt;document &lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-8774073762964882674?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/dclj2AOkKBM" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-17T14:17:06.820+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2011/10/ora-01591-lock-held-by-in-doubt.html</feedburner:origLink></item><item><title>Table Comparison and Synchronisation</title><link>http://feedproxy.google.com/~r/shaharear/~3/rJgmhjaNM_4/table-comparison-and-synchronisation.html</link><category>SQL PL/SQL Tips</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Mon, 25 Jul 2011 06:07:33 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-3446650202234852401</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/E0eBNsGlSM-7Ny9JqKP1FvKpa5E/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/E0eBNsGlSM-7Ny9JqKP1FvKpa5E/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/E0eBNsGlSM-7Ny9JqKP1FvKpa5E/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/E0eBNsGlSM-7Ny9JqKP1FvKpa5E/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="gmail_quote"&gt;If you are managing more than one databases for same application, it is very common that you need to compare one table ( say scott.employee) in two different databases. I think, we had previous experiences to do such job :) . The simplest way is just minus two tables. Like&lt;br /&gt;&lt;br /&gt;1. Two different tables In same DB - &lt;span style="font-style: italic;"&gt;SELECT * FROM table1 minus SELECT * FROM table2;&lt;/span&gt;&lt;br /&gt;2. Same table in two different DB - &lt;span style="font-style: italic;"&gt;SELECT * FROM table1 minus SELECT * FROM table2@remote_db;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;But this simple task can be time consuming if your tables are very big (say 1000000+ records). If targeted tables do not contain BLOB,CLOB or Long data type columns, you can easily use DBMS_COMPARISON, a new package introduce in Oracle 11g, to compare them. More over this package also provide Synchronization to remove miss match records in targeted tables. For details please go through &lt;a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_comparison.htm" target="_blank"&gt;Oracle Documentations&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Here we are going to compare and synchronise 'employee' table in two different DB.&lt;br /&gt;&lt;br /&gt;Requirement: A database link between host (i.e, where these script will be run) and remote DB.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Step One&lt;/b&gt;: Create comparison Task&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;BEGIN  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;DBMS_COMPARISON.CREATE_COMPARISON(&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;comparison_name =&amp;gt; 'compare_employee'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;, schema_name     =&amp;gt; 'SCOTT'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;, object_name     =&amp;gt; 'EMPLOYEE'  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;, dblink_name     =&amp;gt; 'db_link_to_remote'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  , remote_schema_name=&amp;gt;'SCOTT'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;, remote_object_name=&amp;gt;'EMPLOYEE'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;END;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; /&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you wish to compare two different table in same DB, set dblink_name     =&amp;gt; NULL,  object_name     =&amp;gt; 'table1' and remote_object_name=&amp;gt;'table2'&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Step Two&lt;/b&gt;: Execute comparison Task&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;DECLARE  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;consistent BOOLEAN;  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;scan_info DBMS_COMPARISON.COMPARISON_TYPE;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;BEGIN  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; consistent := DBMS_COMPARISON.COMPARE( comparison_name =&amp;gt;'compare_employee', scan_info=&amp;gt; scan_info, perform_row_dif =&amp;gt; TRUE);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   DBMS_OUTPUT.PUT_LINE('Scan ID: '||scan_info.scan_id);  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; IF consistent=TRUE THEN DBMS_OUTPUT.PUT_LINE('No differences found.');  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; ELSE &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  DBMS_OUTPUT.PUT_LINE('Differences were found.'); &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  END IF;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;END;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Step Three&lt;/b&gt;: See how may difference you got&lt;br /&gt;&lt;br /&gt;col COMPARISON_NAME format a15;&lt;br /&gt;col SCHEMA_NAME format a15;&lt;br /&gt;col OBJECT_NAME format a15;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SELECT s.scan_id ,c.COMPARISON_NAME,c.SCHEMA_NAME,c.OBJECT_NAME ,s.CURRENT_DIF_COUNT&lt;br /&gt;FROM USER_COMPARISON c,USER_COMPARISON_SCAN_SUMMARY s&lt;br /&gt;WHERE  c.COMPARISON_NAME = s.COMPARISON_NAME AND s.scan_id = 514;&lt;span style="font-style: italic;"&gt; &lt;/span&gt; (this number is a out put of step two)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Step Four&lt;/b&gt;: Synchronise Remote table with host table.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;DECLARE&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;scan_info DBMS_COMPARISON.COMPARISON_TYPE;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;BEGIN&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;DBMS_COMPARISON.CONVERGE (comparison_name  =&amp;gt; 'compare_employee',&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;scan_id =&amp;gt; 506,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;scan_info =&amp;gt; scan_info, --this number is a out put of step two&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  converge_options =&amp;gt; DBMS_COMPARISON.CMP_CONVERGE_LOCAL_WINS);  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;DBMS_OUTPUT.PUT_LINE('Local Rows Merged: '||scan_info.loc_rows_merged);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;DBMS_OUTPUT.PUT_LINE('Remote Rows Merged: '||scan_info.rmt_rows_merged);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  DBMS_OUTPUT.PUT_LINE('Local Rows Deleted: '||scan_info.loc_rows_deleted);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;DBMS_OUTPUT.PUT_LINE('Remote Rows Deleted: '||scan_info.rmt_rows_deleted);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;END;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can also Synchronise Host table by using Remote table, please visit given link.&lt;br /&gt;&lt;br /&gt;I hope you all will enjoy this exiting new package of Oracle 11g.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-3446650202234852401?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/rJgmhjaNM_4" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-25T19:07:33.608+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2011/07/table-comparison-and-synchronisation.html</feedburner:origLink></item><item><title>Traveling past with Log Miner</title><link>http://feedproxy.google.com/~r/shaharear/~3/yzuiXBok2Sc/traveling-past-with-log-miner.html</link><category>Audit</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Mon, 11 Jul 2011 02:49:34 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-7862559796486409915</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/FFnbBHmn9lrpmMID2Wgf0gFKpTI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/FFnbBHmn9lrpmMID2Wgf0gFKpTI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/FFnbBHmn9lrpmMID2Wgf0gFKpTI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/FFnbBHmn9lrpmMID2Wgf0gFKpTI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Some times you may wish to see what happen in recent past. In a beautiful morning, you may discover that a misshape occure in your database :(. Unfortunately you did not enabled any auditing options earlier.&lt;br /&gt;&lt;br /&gt;If your database is in &lt;span style="color: rgb(255, 0, 0);"&gt;archivelog&lt;/span&gt; mod and &lt;span style="color: rgb(204, 0, 0);"&gt;supplemental log&lt;/span&gt; is enabled then '&lt;span style="font-style: italic; color: rgb(255, 102, 102);"&gt;Log Miner&lt;/span&gt;' can save the day !  Oracle Log Miner is also capable of mining redo log, archive log of remote DB. Please see &lt;a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/logminer.htm#sthref1875"&gt;Oracle Utility Document&lt;/a&gt; for details.&lt;br /&gt;&lt;br /&gt;In this post, we only consider a scenario in which Source DB and Mining DB is same. Lets describe how you can do this&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 0, 0);"&gt;STEP 1 : Create Log Miner User&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;CREATE USER logminer_adm identified by logminer_adm;&lt;br /&gt;&lt;br /&gt;GRANT resource,connect to logminer_adm;&lt;br /&gt;GRANT EXECUTE_CATALOG_ROLE,DBA to logminer_adm;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 0, 0);"&gt;Step 2 : Enable Supplemental Login&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;Check whether supplemental login is enabled&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;SELECT SUPPLEMENTAL_LOG_DATA_MIN FROM V$DATABASE;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If not, then you can't mine all transections. So enable it for future and follow the remaining steps to mine a subset of all transections.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 0, 0);"&gt;Step 3:  Add Archieve Log Files to Log Miner&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-size:85%;"&gt;ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;EXECUTE DBMS_LOGMNR.ADD_LOGFILE(LOGFILENAME =&amp;gt;'/u/archivelog/2011_07_10/o1_mf_1_470_71m4jv90_.arc', OPTIONS =&amp;gt; DBMS_LOGMNR.NEW);&lt;br /&gt;EXECUTE DBMS_LOGMNR.ADD_LOGFILE(LOGFILENAME =&amp;gt;'/u/archivelog/2011_07_10/o1_mf_1_471_71m4kn09_.arc', OPTIONS =&amp;gt; DBMS_LOGMNR.ADDFILE);&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;You can add as much files as you need&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 0, 0);"&gt;Step 4: Start Log Miner&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;EXECUTE DBMS_LOGMNR.START_LOGMNR(STARTTIME =&amp;gt;'10-JUL-2011 19:50:00',ENDTIME =&amp;gt; '10-JUL-2011 19:55:00',OPTIONS =&amp;gt; DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;+DBMS_LOGMNR.CONTINUOUS_MINE);&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 0, 0);"&gt;Step 5: View What Happen Last Night :)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt;SELECT SEG_OWNER ,OPERATION, SQL_REDO, SQL_UNDO&lt;br /&gt;FROM V$LOGMNR_CONTENTS&lt;br /&gt;WHERE  SEG_OWNER = 'SYS';&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 0, 0);"&gt;Step 6: Stop Log Miner Session&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt;&lt;br /&gt;EXECUTE DBMS_LOGMNR.END_LOGMNR;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-7862559796486409915?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/yzuiXBok2Sc" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-11T15:49:34.526+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2011/07/traveling-past-with-log-miner.html</feedburner:origLink></item><item><title>DATA PUMP: Network mode import</title><link>http://feedproxy.google.com/~r/shaharear/~3/RQLKHECD0Gs/data-pump-network-mode-import.html</link><category>Export-Import</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Sat, 02 Jul 2011 00:58:47 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-6588658532256139295</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/LMp0pA4RICeNPmBLQX8ttjiP74I/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/LMp0pA4RICeNPmBLQX8ttjiP74I/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/LMp0pA4RICeNPmBLQX8ttjiP74I/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/LMp0pA4RICeNPmBLQX8ttjiP74I/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Some time we need to copy one schema from one DB machine to another machine or copy one schema as schema (i.e. remap schema) in same DB. The simplest way is to &lt;br /&gt;&lt;br /&gt; &lt;span style="font-style: italic;"&gt;(a) &lt;/span&gt;export required schema, move dump to remote DB and import [copy in 2 DB]&lt;br /&gt;&lt;br /&gt; &lt;span style="font-style: italic;"&gt;(b)&lt;/span&gt; export required&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" class="J-JK9eJ-PJVNOc"&gt;&lt;/span&gt; schema and import the dump with schema replace option [copy in same DB]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;span style="font-weight: bold;"&gt;Scenario ONE&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; Suppose the source schema is too small (say 1-3 GB) the above process is time consuming and labours compare with task requirements.&lt;br /&gt;&lt;br /&gt; &lt;span style="font-weight: bold;"&gt;Scenario TOW&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; Suppose the source schema is too big (say 100 GB+) and there is not enough disk space to store the 100G size dump.&lt;br /&gt;&lt;br /&gt; In above cases you can use the option of network import. But you need to consider that network import is a slower process because all the data should be travel in connection cable if your target is coping a schema in two different DB machine.&lt;br /&gt;&lt;br /&gt; Lets describe how we can achieve this. we move user_info schema from source db to remote db. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;STEP 1: grant exp_full_database role to socre shcema [IN REMOTE DB]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;conn system/pass; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;GRANT EXP_FULL_DATABASE to user_info;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;STEP 2: [IN DESTINATION DB] Create destination user and grant necessary roles&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;conn system/pass;&lt;br /&gt;CREATE USER user_info&lt;br /&gt;IDENTIFIED BY pass&lt;br /&gt;DEFAULT TABLESPACE USER&lt;br /&gt;TEMPORARY TABLESPACE TEMP;&lt;br /&gt;&lt;br /&gt;GRANT CONNECT , RESOURCE TO user_info;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;STEP 3: [IN DESTINATION DB] grant read/write on dump directory&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;conn system/pass;&lt;br /&gt;&lt;br /&gt;GRANT read,write on DIRECTORY dump_directory to user_info;&lt;br /&gt;&lt;br /&gt;Network import does not requer any dump file. This directory is only requer to write the import log file.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;STEP 4: [IN DESTINATION DB] create public DB Link &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;conn system/pass;&lt;br /&gt;CREATE PUBLIC DATABASE LINK SATURN&lt;br /&gt;connect to user_info identified by pass&lt;br /&gt;using '(DESCRIPTION=(&lt;br /&gt;ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=remote_db)&lt;br /&gt;(PORT=1521)))&lt;br /&gt;(CONNECT_DATA=(SERVICE_NAME=orcl.oracle.com)&lt;br /&gt;(server=DEDICATED)))';&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;STEP 5: [IN DESTINATION DB MACHINE] execute impdp &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;impdp user_info/pass directory=dump_dir network_link=SATURN  logfile=net_import_proddev.log EXCLUDE=GRANT,STATISTICS,SYNONYM,DB_LINK REMAP_SCHEMA=USER_INFO:USER_INFO&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-6588658532256139295?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/RQLKHECD0Gs" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-02T13:58:47.135+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2011/07/data-pump-network-mode-import.html</feedburner:origLink></item><item><title>Multiplex online Redo Logfile</title><link>http://feedproxy.google.com/~r/shaharear/~3/jb8i9E3qDc0/multiplex-online-redo-logfile.html</link><category>Oracle Administration and Maintenance</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Tue, 03 May 2011 20:43:53 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-3501506747169825047</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/XddZhXpQAc1Li21S04fchcL0byg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XddZhXpQAc1Li21S04fchcL0byg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/XddZhXpQAc1Li21S04fchcL0byg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XddZhXpQAc1Li21S04fchcL0byg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;It is important to have multiple (at list two) copy of each online redo logfile. To avoid the disaster of disk failure, it is recommended to place each member of a specific online redo logfile group in different disk.&lt;br /&gt;&lt;br /&gt;To view to current online redo logfile group members&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;SELECT GROUP#,STATUS,MEMBER FROM V$LOGFILES;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Suppose we have disk01 (mount point &lt;span style="font-style: italic;"&gt;/u01&lt;/span&gt; ) that contains current online redolog files .To add member in  redo logfile group 1,2 and 3 in disk02 ( mount point &lt;span style="font-style: italic;"&gt;/u02&lt;/span&gt; )&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; ALTER DATABASE ADD LOGFILE MEMBER '/u02/redo01.log' TO GROUP 1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; ALTER DATABASE ADD LOGFILE MEMBER '/u02/redo02.log' TO GROUP 2;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; ALTER DATABASE ADD LOGFILE MEMBER '/u02/redo03.log' TO GROUP 3;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-3501506747169825047?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/jb8i9E3qDc0" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2011-05-04T09:43:53.217+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2011/05/multiplex-online-redo-logfile.html</feedburner:origLink></item><item><title>Track Database Growth</title><link>http://feedproxy.google.com/~r/shaharear/~3/4ZomY2u1Vy8/track-database-growth.html</link><category>Oracle Administration and Maintenance</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Sun, 20 Mar 2011 21:19:06 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-1716149016844763705</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/nxtl2dI1_YfNDGoC3yRvbvzYOzI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/nxtl2dI1_YfNDGoC3yRvbvzYOzI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/nxtl2dI1_YfNDGoC3yRvbvzYOzI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/nxtl2dI1_YfNDGoC3yRvbvzYOzI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Some time it become very important to monitor your database growth specially in test database machines. Usually these machines have very limited disk space.&lt;br /&gt;Thus, tracking the consumption of disk space is one of the frequent tasks in administrative checklist. Here is a SQL script that gives you the current size of database and average disk space consumed in each day.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;SELECT b.tsname tablespace_name&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;, MAX(b.used_size_mb) cur_used_size_mb&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;, round(AVG(inc_used_size_mb),2)avg_increas_mb &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;FROM (&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  SELECT a.days,a.tsname&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  , used_size_mb&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  , used_size_mb - LAG (used_size_mb,1)  OVER ( PARTITION BY a.tsname ORDER BY a.tsname,a.days) inc_used_size_mb&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  FROM (&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;      SELECT TO_CHAR(sp.begin_interval_time,'MM-DD-YYYY') days &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       ,ts.tsname&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       ,MAX(round((tsu.tablespace_usedsize* dt.block_size )/(1024*1024),2)) used_size_mb&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;      FROM DBA_HIST_TBSPC_SPACE_USAGE tsu&lt;br /&gt;      , DBA_HIST_TABLESPACE_STAT ts &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       ,DBA_HIST_SNAPSHOT sp, DBA_TABLESPACES dt&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;      WHERE tsu.tablespace_id= ts.ts# AND tsu.snap_id = sp.snap_id&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       AND ts.tsname = dt.tablespace_name  AND sp.begin_interval_time &gt; sysdate-7&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;      GROUP BY TO_CHAR(sp.begin_interval_time,'MM-DD-YYYY'), ts.tsname &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;      ORDER BY ts.tsname, days&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  ) a&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;) b GROUP BY b.tsname ORDER BY b.tsname;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-1716149016844763705?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/4ZomY2u1Vy8" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-21T10:19:06.351+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2011/03/track-database-growth.html</feedburner:origLink></item><item><title>ORA-14519 Conflicting tablespace blocksizes while importing partition tables</title><link>http://feedproxy.google.com/~r/shaharear/~3/HGe8WJdmN8k/ora-14519-conflicting-tablespace.html</link><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Wed, 26 Jan 2011 03:02:35 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-144552125397658709</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Vi-f2RUtxsIoQ8qHMZFnBK7fcho/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Vi-f2RUtxsIoQ8qHMZFnBK7fcho/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Vi-f2RUtxsIoQ8qHMZFnBK7fcho/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Vi-f2RUtxsIoQ8qHMZFnBK7fcho/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;style type="text/css"&gt;p { margin-bottom: 0.08in; }&lt;/style&gt;   &lt;p  style="margin-bottom: 0in;font-family:verdana;"&gt;ORA-14519: Conflicting tablespace blocksizes for table : Tablespace T2 block size 16384 [partition specification] conflicts with previously specified/implied tablespace T1 block size 8192 [object-level default]&lt;/p&gt;  &lt;p  style="margin-bottom: 0in;font-family:verdana;"&gt;Well :) the error massage clearly indicate that I am trying to create a partition table in more than one tablespaces where the blocksize of the tablespaces are different. We all know that &lt;span style="font-style: italic; font-weight: bold;"&gt;table partitions can not be placed in different blocksize tablespaces&lt;/span&gt;. Though I know this and not did this mistake before, I get this error when I am trying to make a replica schema in local test database.  &lt;/p&gt;  &lt;p face="verdana" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p face="verdana" style="margin-bottom: 0in;"&gt;I took dump by using &lt;span style="font-style: italic; font-weight: bold;"&gt;EXPDP&lt;/span&gt; without any error and get the above error when try to import it by using &lt;span style="font-style: italic;"&gt;REMAP_SCHEMA&lt;/span&gt; option of &lt;span style="font-weight: bold; font-style: italic;"&gt;IMPDP&lt;/span&gt;. It is really annoying to get such error that can not be explainable. All of my table partitions are placed in a single tablespace but the error message says that I am trying to place table partitions in two tablespaces where their blocksize is different ! It sounds simply horrible.&lt;/p&gt;    &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;But at the end of a long research :) I have found the mistake.The user's default tablespace is T1 [8k blocksize] and I create the table in tablespace T2 [16K blocksize] just like this -&lt;br /&gt;&lt;/p&gt;    &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;CREATE TABLE TEST (ID NUMBER (10), TEXT VARCHAR2(50)&lt;/p&gt;  &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;) PARTITION BY RANGE (ID) (&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;PARTITION TEST_PART_1 VALUES LESS THAN (100001) TABLESPACE T2 ,&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;PARTITION "TEST_PART_2" VALUES LESS THAN (MAXVALUE) TABLESPACE T2&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;);&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;This script create 2 table partitions of TEST table in T2 tablespace but unfortunately the default tablespace attribute of TEST table set to T1 (As I did not mansion default table space of table TEST when I create it. So ORACLE set this attribute same as user's default tablespace). See! Sometime ORACLE does something smartly that can cause stupid scenario. IF you want to see this unbelievable thing, just generate the table's SQL. You will see this&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;&lt;br /&gt;&lt;/p&gt;   &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;CREATE TABLE TEST (ID NUMBER (10),TEXT VARCHAR2(50)&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;) &lt;span style="color: rgb(255, 102, 102);"&gt;TABLESPACE T1&lt;/span&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;PARTITION BY RANGE (ID) (&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;PARTITION TEST_PART_1 VALUES LESS THAN (100001) TABLESPACE T2 ,&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;PARTITION "TEST_PART_2" VALUES LESS THAN (MAXVALUE) TABLESPACE T2&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;);&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;This sturdiness of oracle cause ORA-14519 when I  tryed to import  TEST table because oracle can't create a partition table in  different blocksize tablespaces.&lt;/p&gt;  &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;So The solution is simple; mention default tablespace when you create a partition table. Just like this&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;CREATE TABLE TEST (&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;ID NUMBER (10),&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;TEXT VARCHAR2(50)&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;) TABLESPACE T2&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;PARTITION BY RANGE (ID) (&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;PARTITION TEST_PART_1 VALUES LESS THAN (100001) TABLESPACE T2 ,&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;PARTITION "TEST_PART_2" VALUES LESS THAN (MAXVALUE) TABLESPACE T2&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;);  &lt;/p&gt;  &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;[ It is not mandatory that all tablespace should be same (t2 in this case). You can put 3 different tablespace but their blocksize should be same.]&lt;/p&gt;   &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;But, what is the solution for already created partition tables ? Well, the solution is very simple, just change the default tablespace attribute of your partition tables that are already created. Here is a script to identify the problematic tables.&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;SELECT * FROM (&lt;/p&gt;  &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;SELECT x.table_name, x.def_tablespace_name&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;, (SELECT block_size from user_tablespaces where tablespace_name=x.def_tablespace_name) df  &lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;, x.tablespace_name  &lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;, (SELECT block_size from user_tablespaces where tablespace_name = x.tablespace_name) tb&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;FROM (&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;SELECT distinct t.table_name, t.def_tablespace_name, p.tablespace_name&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;FROM user_part_tables t, user_tab_partitions p&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;WHERE t.table_name = p.table_name&lt;/p&gt;  &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;) x ) k WHERE k.tb &lt;&gt; k.df;&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;Then reset the default tablespace attribute&lt;/p&gt;  &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;ALTER TABLE TEST MODIFY default attributes TABLESPACE T2;&lt;/p&gt;  &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;Now take dump and apply it without facing &lt;span style="font-weight: bold;"&gt;ORA-14519&lt;/span&gt; !&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-144552125397658709?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/HGe8WJdmN8k" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-26T17:02:35.794+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2011/01/ora-14519-conflicting-tablespace.html</feedburner:origLink></item><item><title>PL/SQL - Operator  Precedence</title><link>http://feedproxy.google.com/~r/shaharear/~3/DR9UIEuwoVI/plsql-operator-precedence.html</link><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Fri, 08 Oct 2010 02:15:58 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-769613794650570150</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/yytOuLujXHvGmHAe9zCRepjPCVU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/yytOuLujXHvGmHAe9zCRepjPCVU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/yytOuLujXHvGmHAe9zCRepjPCVU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/yytOuLujXHvGmHAe9zCRepjPCVU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Hi all, It has been almost an year since I posted a topic in this blog. After a 1 year study break, I back to my usual job and hopfully I am become regular in this blog again.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In SQL or PL/SQL we use several operators. Some are mathematical, logical and comparison operatiors. Oracle follow a order of precedence when execute an expression that contains more than one operators. If operatiors with same precidence are occured then it does not follow any order. Otherwise Oracle maintain the following order of precedence of operators.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Order |------------|        Operator     |------------|        Operation&lt;br /&gt;1         |------------|                     **        |------------|        exponentiation&lt;br /&gt;2         |------------|                +,                     |------------|        identity, negation&lt;br /&gt;3         |------------|                 *, /                   |------------|        multiplication, division&lt;br /&gt;4         |------------|              +, -, ||             |------------|        addition, subtraction, concatenation&lt;br /&gt;5     |------------|          =, &lt;, &gt;, &lt;=, &gt;=,            |------------|        comparison&lt;br /&gt;   &lt;&gt;, !=, ~=, ^=, IS NULL, LIKE,&lt;br /&gt;   BETWEEN, IN&lt;br /&gt;6     |------------|        NOT                              |------------|        logical negation&lt;br /&gt;7     |------------|        AND                              |------------|        conjunction&lt;br /&gt;8     |------------|        OR                                 |------------|        inclusion&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For example, when NOT, AND and OR operators are used in the same statement NOT is evaluated first, then AND and finally OR.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-769613794650570150?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/DR9UIEuwoVI" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2010-10-08T15:15:58.446+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2010/10/plsql-operator-precedence.html</feedburner:origLink></item><item><title>Estimate Tablespace growth</title><link>http://feedproxy.google.com/~r/shaharear/~3/BVMpgVolRaA/estimate-tablespace-growth.html</link><category>Oracle Tips And Tricks</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Tue, 15 Sep 2009 01:17:24 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-7907356797076148276</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/F08_D5FVsGWuqKRDY54Mp83strw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/F08_D5FVsGWuqKRDY54Mp83strw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/F08_D5FVsGWuqKRDY54Mp83strw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/F08_D5FVsGWuqKRDY54Mp83strw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Some time it is very helpful  to plan disk space/ tablespace management if you estimate the growth of  your  tablespace. Here is a select query which can be helpful : &lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;SELECT TO_CHAR (sp.begin_interval_time,'DD-MM-YYYY') days &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; , ts.tsname&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; , max(round((tsu.tablespace_size* dt.block_size )/(1024*1024),2) )  cur_size_MB&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; , max(round((tsu.tablespace_usedsize* dt.block_size )/(1024*1024),2)) usedsize_MB &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;FROM DBA_HIST_TBSPC_SPACE_USAGE tsu&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; , DBA_HIST_TABLESPACE_STAT ts &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; , DBA_HIST_SNAPSHOT sp&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; , DBA_TABLESPACES dt&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;WHERE tsu.tablespace_id= ts.ts#&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; AND tsu.snap_id = sp.snap_id&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; AND ts.tsname = dt.tablespace_name&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; AND ts.tsname NOT IN ('SYSAUX','SYSTEM')&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;GROUP BY TO_CHAR (sp.begin_interval_time,'DD-MM-YYYY'), ts.tsname &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;ORDER BY ts.tsname, days;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-7907356797076148276?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/BVMpgVolRaA" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-15T15:17:24.144+07:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">7</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2009/09/estimate-tablespace-growth.html</feedburner:origLink></item><item><title>Add Unique key in a table that contains duplicate row</title><link>http://feedproxy.google.com/~r/shaharear/~3/8vbB4pZS_Qo/add-unique-key-in-table-that-contains.html</link><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Wed, 26 Aug 2009 03:14:40 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-4176517669143094454</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/p5TOmdSG9jY27AmQnQPp87lb-DM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/p5TOmdSG9jY27AmQnQPp87lb-DM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/p5TOmdSG9jY27AmQnQPp87lb-DM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/p5TOmdSG9jY27AmQnQPp87lb-DM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Requirement : A table contains some duplicate data. Now we want to add a unique constraint that skip existing duplicate values but check newly inserted duplicate values.&lt;br /&gt;&lt;br /&gt;SQL&gt; create table t2 (id number(10), t varchar2(20));&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into t2 values (1,'A');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into t2 values (1,'A');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into t2 values (1,'A');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&gt; commit;&lt;br /&gt;&lt;br /&gt;Commit complete.&lt;br /&gt;&lt;br /&gt;SQL&gt; alter table t2 add constraint uk_t2 unique(id) ENABLE NOVALIDATE;&lt;br /&gt;alter table t2 add constraint uk_t2 unique(id) ENABLE NOVALIDATE&lt;br /&gt;                              *&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-02299: cannot validate (HASAN.UK_T2) - duplicate keys found&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&gt; select * from t2;&lt;br /&gt;&lt;br /&gt;        ID T&lt;br /&gt;---------- ------------------------------------------------------------&lt;br /&gt;         1 A&lt;br /&gt;         1 A&lt;br /&gt;         1 A&lt;br /&gt;&lt;br /&gt;So normal method does not work !&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;Case 1: New Table  That means initially the table does not have any data&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;SQL&gt; create table t3 (id number(10), t varchar2(20));&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&gt; alter table t3 add constraint gpu unique (id) deferrable initially deferred;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&gt; alter table t3 disable constraint gpu;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into t3 values(1,'A');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into t3 values(1,'A');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into t3 values(1,'A');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&gt; commit;&lt;br /&gt;&lt;br /&gt;Commit complete.&lt;br /&gt;&lt;br /&gt;SQL&gt;&lt;br /&gt;SQL&gt;&lt;br /&gt;SQL&gt;&lt;br /&gt;SQL&gt; select * from t3;&lt;br /&gt;&lt;br /&gt;        ID T&lt;br /&gt;---------- ------------------------------------------------------------&lt;br /&gt;         1 A&lt;br /&gt;         1 A&lt;br /&gt;         1 A&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&gt; alter table t3 enable novalidate constraint gpu;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into t3 values(2,'A');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&gt; commit;&lt;br /&gt;&lt;br /&gt;Commit complete.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into t3 values(2,'A');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&gt; commit;&lt;br /&gt;commit&lt;br /&gt;*&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-02091: transaction rolled back&lt;br /&gt;ORA-00001: unique constraint (HASAN.GPU) violated&lt;br /&gt;&lt;br /&gt;SQL&gt; alter table t3 modify constraint gpu INITIALLY IMMEDIATE;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into t3 values(1,'A');&lt;br /&gt;insert into t3 values(1,'A')&lt;br /&gt;*&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-00001: unique constraint (HASAN.GPU) violated&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;Case 2: Existing Table that contains duplicate data&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&gt; create table t2 (id number(1),a varchar2(10));&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into t2 values(1,'A');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into t2 values(1,'A');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&gt; commit;&lt;br /&gt;&lt;br /&gt;Commit complete.&lt;br /&gt;&lt;br /&gt;SQL&gt; alter table t2 add constraint uk_t2 unique(id) DEFERRABLE INITIALLY DEFERRED disable;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&gt; alter table t2 enable novalidate constraint uk_t2;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into t2 values(1,'A');&lt;br /&gt;&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;SQL&gt; commit;&lt;br /&gt;commit&lt;br /&gt;*&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-02091: transaction rolled back&lt;br /&gt;ORA-00001: unique constraint (HASAN.UK_T2) violated&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&gt; alter table t2 modify constraint uk_t2 INITIALLY IMMEDIATE;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into t2 values(1,'A');&lt;br /&gt;insert into t2 values(1,'A')&lt;br /&gt;*&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-00001: unique constraint (HASAN.UK_T2) violated&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;OR &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&gt; alter table t2 add constraint uk_t2 unique(id) disable;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&gt; alter table t2 enable novalidate constraint uk_t2;&lt;br /&gt;&lt;br /&gt;Table altered.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into t2 values(1,'A');&lt;br /&gt;insert into t2 values(1,'A')&lt;br /&gt;*&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-00001: unique constraint (HASAN.UK_T2) violated&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-4176517669143094454?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/8vbB4pZS_Qo" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-26T17:14:40.940+07:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2009/08/add-unique-key-in-table-that-contains.html</feedburner:origLink></item><item><title>Who use  Temporary Tablespace ?</title><link>http://feedproxy.google.com/~r/shaharear/~3/Q05MNpVn7Qk/who-use-temporary-tablespace.html</link><category>SQL PL/SQL Tips</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Tue, 26 May 2009 03:55:05 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-8779398749691339123</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/rCHUj3X7Akn7FLEQsexJQ-50alw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/rCHUj3X7Akn7FLEQsexJQ-50alw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/rCHUj3X7Akn7FLEQsexJQ-50alw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/rCHUj3X7Akn7FLEQsexJQ-50alw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Temporary Tablespace  is used for sorting purpose it also temporarily  data like  temporary tables.&lt;br /&gt;&lt;br /&gt;Here is a query that give you, which sql statement use who much on   Temporary Tablespace (I considered TEMP is a 8k block size tablespace)&lt;br /&gt;&lt;br /&gt;select su.username&lt;br /&gt;, dbms_lob.substr(sq.sql_fulltext, 4000, 1) sql_text&lt;br /&gt;, su.blocks&lt;br /&gt;, su.extents&lt;br /&gt;, su.segtype&lt;br /&gt;, (su.blocks*8)/1024 size_MB&lt;br /&gt;, sq.last_active_time&lt;br /&gt;, sq.last_load_time&lt;br /&gt;from v$sort_usage su&lt;br /&gt;join v$sqlarea  sq on (su.sql_id = sq.sql_id)&lt;br /&gt;left join  v$session s on (s.sql_id=su.sql_id)&lt;br /&gt;&lt;br /&gt;where su.tablespace='TEMP';&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-8779398749691339123?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/Q05MNpVn7Qk" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-26T16:55:05.791+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2009/05/who-use-temporary-tablespace.html</feedburner:origLink></item><item><title>ORA-10631</title><link>http://feedproxy.google.com/~r/shaharear/~3/eVRfX0rTA6k/ora-10631.html</link><category>ERROR: ORA-</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Mon, 04 May 2009 23:46:19 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-1550903969373012630</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/0qwEfBFte87BumlCZU0ccFvZk5Q/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/0qwEfBFte87BumlCZU0ccFvZk5Q/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/0qwEfBFte87BumlCZU0ccFvZk5Q/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/0qwEfBFte87BumlCZU0ccFvZk5Q/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;span style="font-weight: bold;"&gt;Message&lt;/span&gt;: ORA-10631: SHRINK clause should not be specified for this object&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Cause&lt;/span&gt;: shrink clause use inappropriately.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Solution&lt;/span&gt;:  Write the syntax correctly. If a table has function based index or Text index, it can not be shrinked&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-1550903969373012630?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/eVRfX0rTA6k" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-05T12:46:19.690+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2009/05/ora-10631.html</feedburner:origLink></item><item><title>Moving Oracle Text Index</title><link>http://feedproxy.google.com/~r/shaharear/~3/J_bEFkWrWDk/moving-oracle-text-index.html</link><category>Oracle Administration and Maintenance</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Sun, 26 Apr 2009 21:46:26 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-4642140727737003140</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Qq0VZT5ua_ymwjtVAket6u6t0MI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Qq0VZT5ua_ymwjtVAket6u6t0MI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Qq0VZT5ua_ymwjtVAket6u6t0MI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Qq0VZT5ua_ymwjtVAket6u6t0MI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Moving an index from one tablespace to another tablespace is very easy task. It can be accomplished by using rebuild option:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;ALTER INDEX index_name REBUILD TABLESPACE NEW_TABLESPACE;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can even do it online for most indexes:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;ALTER INDEX index_name REBUILD TABLESPACE NEW_TABLESPACE ONLINE;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;But trying to move a domain index (such as Oracle Text Index) is not so simple. If you follow thw above way it will cause error:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;ALTER INDEX my_text_index REBUILD TABLESPACE NEW_TABLESPACE;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;ORA-29871&lt;/span&gt;: invalid alter option for a domain index&lt;br /&gt;&lt;br /&gt;You may ask What is the reson behind that error  and how to resolve it? In fact Domain index is a set of other objects.  Oracle Text CONTEXT index is set of tables:&lt;br /&gt;&lt;br /&gt;   * DR$[index_name]$I&lt;br /&gt;   * DR$[index_name]$K&lt;br /&gt;   * DR$[index_name]$N&lt;br /&gt;   * DR$[index_name]$R&lt;br /&gt;&lt;br /&gt;Unfortunately to move context index you have to drop and recreate that text index. But first you need to specify storage parameters:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;begin&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   ctx_ddl.create_preference('TEXT_INDEX_STORE', 'BASIC_STORAGE');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   ctx_ddl.set_attribute('TEXT_INDEX_STORE', 'I_TABLE_CLAUSE',&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       'tablespace NEW_TABLESPACE');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   ctx_ddl.set_attribute('TEXT_INDEX_STORE', 'K_TABLE_CLAUSE',&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       'tablespace NEW_TABLESPACE');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   ctx_ddl.set_attribute('TEXT_INDEX_STORE', 'R_TABLE_CLAUSE',&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       'tablespace NEW_TABLESPACE');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   ctx_ddl.set_attribute('TEXT_INDEX_STORE', 'N_TABLE_CLAUSE',&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       'tablespace NEW_TABLESPACE');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   ctx_ddl.set_attribute('TEXT_INDEX_STORE', 'I_INDEX_CLAUSE',&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       'tablespace NEW_TABLESPACE COMPRESS 2');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   ctx_ddl.set_attribute('TEXT_INDEX_STORE', 'P_TABLE_CLAUSE',&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       'tablespace NEW_TABLESPACE');&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;end;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;and then just drop the previously created index and recreate that  index with changed parameters&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;create index MY_TEXT_I on MY_TAB(text_column) &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;indextype is ctxsys.context parameters('storage TEXT_INDEX_STORE');&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-4642140727737003140?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/J_bEFkWrWDk" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-27T10:46:26.791+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2009/04/moving-oracle-text-index.html</feedburner:origLink></item><item><title>TEXT Index Size</title><link>http://feedproxy.google.com/~r/shaharear/~3/VSUaxImSVfk/text-index-size.html</link><category>SQL PL/SQL Tips</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Wed, 22 Apr 2009 02:17:50 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-6475480596125258920</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/wiVx2NAInok8zc0NmA9ugXdXpTQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/wiVx2NAInok8zc0NmA9ugXdXpTQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/wiVx2NAInok8zc0NmA9ugXdXpTQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/wiVx2NAInok8zc0NmA9ugXdXpTQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Oracle Text Index, an interMedia Index, is powerful for searching user specified text within a column or columns. It is widely used in web applications such as search engines, content management systems. As a DBA, accurately identify sizes of text indexes in the database and monitor their growth is important. But the problem is that text index is a domain index, and every text index  internally consists of several tables with names prefixed with 'DR$'. Some of these tables have their own indexes and some of them are Index Organized Tables (IOTs). If you search in dba_segments, there is no segment for text indexes. SO when you try to calculate the size of an text index, you should consider all of these DR$ tables and their indexes. The script provided here gives a fast report of the sizes of all text indexes in the schema:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;COL table_name format A30;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;COL ind_nm format A30;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;COL KB 9999999999;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;select table_name, x.index_name, sum(KB) KB from &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;(select substr(table_name, 4, instr(table_name, '$', -1)-4) index_name,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;sum(bytes)/1024 KB&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;from user_tables t, user_segments s&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;where t.table_name = s.segment_name and t.table_name like 'DR$%$%'&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;group by substr(table_name, 4, instr(table_name, '$', -1)-4) &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;union&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;select substr(table_name, 4, instr(table_name, '$', -1)-4) index_name,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;sum(bytes)/1024 KB from user_indexes i, user_segments s&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;where i.index_name = s.segment_name and i.table_name like 'DR$%$%'&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;group by substr(table_name, 4, instr(table_name, '$', -1)-4)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;) x, user_indexes ind&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;where x.index_name = ind.index_name&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;group by table_Name, x.index_name&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;order by table_name, x.index_name;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;Related Topics:&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;ol&gt;&lt;li&gt;&lt;a href="http://shaharear.blogspot.com/2008/12/oracle-text.html"&gt;Introduction of Oracle Text&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shaharear.blogspot.com/2008/12/installation-of-oracle-text-on-10g.html"&gt;Oracle Text Installation&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-6475480596125258920?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/VSUaxImSVfk" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-22T15:17:50.887+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2009/04/text-index-size.html</feedburner:origLink></item><item><title>Features of Oracle Flashback</title><link>http://feedproxy.google.com/~r/shaharear/~3/CHUEBqVeUuo/features-of-oracle-flashback.html</link><category>Flashback</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Fri, 17 Apr 2009 23:24:27 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-6008409997239463228</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/dciY_iK_tRHA4k-c0fq_bD-DNUk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/dciY_iK_tRHA4k-c0fq_bD-DNUk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/dciY_iK_tRHA4k-c0fq_bD-DNUk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/dciY_iK_tRHA4k-c0fq_bD-DNUk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;span style="font-weight: bold;"&gt;1. Flashback query&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Introduced with Oracle9i, Flashback Query provides the ability to view the data as it existed in the past. By default, operations on the database use the most recent committed data available. If you want to query the database as it was at some time in the past, you can do so with the Flashback Query feature.&lt;br /&gt;&lt;br /&gt;SQL&gt; select dbms_flashback.get_system_change_number from dual;&lt;br /&gt;&lt;br /&gt;SQL&gt;select id from hasan.test where id in (100,101);&lt;br /&gt;SQL&gt;delete from  hasan.test where id in (100,101);&lt;br /&gt;SQL&gt;commit;&lt;br /&gt;&lt;br /&gt;SQL&gt;select id from hasan.test as of  timestamp systimestamp - interval '20' minute where id not in (select id from hasan.test);&lt;br /&gt;&lt;br /&gt;SQL&gt;insert into hasan.test&lt;br /&gt;select * from hasan.test as of  timestamp systimestamp - interval '10' minute&lt;br /&gt;where id not in (select id from hasan.test);&lt;br /&gt;&lt;br /&gt;SQL&gt;commit;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2. Flashback Table&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When a human or application error occurs, you want to be able to restore the state of one or more tables to a point in time before the problem occurred. Flashback Table provides the DBA the ability to recover a table or a set of tables to a specified point in time quickly, easily, and online. Flashback Table restores the tables while automatically maintaining its associated attributes such as - the current indexes, triggers and constraints&lt;br /&gt;&lt;br /&gt;SQL&gt; select dbms_flashback.get_system_change_number from dual;&lt;br /&gt;&lt;br /&gt;SQL&gt;select count(*) from hasan.test;&lt;br /&gt;SQL&gt;delete from  hasan.test;&lt;br /&gt;SQL&gt;commit;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&gt;alter table hasan.test enable row movement;&lt;br /&gt;SQL&gt;Flashback table hasan.test to SCN ;&lt;br /&gt;SQL&gt;Flashback table hasan.test to timestamp systimestamp - interval '5' minute ;&lt;br /&gt;&lt;br /&gt;SQL&gt;select count(*) from hasan.test;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3. Flashback Version Query&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Flashback Versions Query provides a way to audit the rows of a table and retrieve information about the transactions that changed the rows. It retrieves all committed versions of the rows that exist or ever existed between the time the query was issued and a point in time in the past. It accomplishes this by utilizing Automatic Undo Management.&lt;br /&gt;&lt;br /&gt;SQL&gt; select dbms_flashback.get_system_change_number from dual;&lt;br /&gt;&lt;br /&gt;SQL&gt; select password from  hasan.test where id in (100,101);&lt;br /&gt;&lt;br /&gt;SQL&gt; update hasan.test set password='Bang'where id in (101);&lt;br /&gt;SQL&gt; commit;&lt;br /&gt;SQL&gt; select dbms_flashback.get_system_change_number from dual;&lt;br /&gt;&lt;br /&gt;SQL&gt; update hasan.test set password='ladesh'where id in (100);&lt;br /&gt;SQL&gt; commit;&lt;br /&gt;SQL&gt; select dbms_flashback.get_system_change_number from dual;&lt;br /&gt;&lt;br /&gt;SQL&gt; delete from  hasan.test where id in (100,101);&lt;br /&gt;SQL&gt; select dbms_flashback.get_system_change_number from dual;&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into hasan.test&lt;br /&gt;select * from hasan.test as of  timestamp systimestamp - interval '20' minute&lt;br /&gt;where id not in (select id from hasan.test);&lt;br /&gt;SQL&gt; commit;&lt;br /&gt;SQL&gt; select dbms_flashback.get_system_change_number from dual;&lt;br /&gt;&lt;br /&gt;SQL&gt; SELECT versions_startscn start_scn&lt;br /&gt;, versions_endscn end_scn&lt;br /&gt;, versions_xid transection_id&lt;br /&gt;, DECODE(versions_operation,'I','Insert','U','Update','D','Delete',NULL) oper&lt;br /&gt;, id, password&lt;br /&gt;FROM hasan.test versions between scn 85174629 AND 85186130&lt;br /&gt;WHERE  id in (100,101) Order by start_scn;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4. Flashback Transaction Query&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You may discover that somehow data in a table has been inappropriately changed. To research this change, you can use multiple flashback queries to view row data at specific points in time. More efficiently, you can use Flashback Versions Query feature to view all changes to a row over a period of time and the associated transaction id's. This feature allows you to append VERSIONS BETWEEN clause to a SELECT statement that specifies an SCN or timestamp range between which you want to view changes to row values. Once you identify an erroneous transaction, you can then use the Flashback Transaction Query feature to identify other changes that were done by the transaction, and to request the undo SQL to reverse those changes.&lt;br /&gt;&lt;br /&gt;SQL&gt; sqlplus / as sysdba&lt;br /&gt;&lt;br /&gt;SQL&gt; SELECT * FROM flashback_transaction_query x&lt;br /&gt;where x.table_name='LOGIN' AND x.table_owner='HASAN'&lt;br /&gt;AND x.start_timestamp &gt;(systimestamp - interval '10' minute);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;5. Flashback Drop&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Dropping of objects by accident has always been a problem for users and DBAs alike. Users soon realize their mistake but then it's too late and historically there is no easy way to recover those dropped tables, indexes, constraints, triggers, etc. Flashback Drop provides a safety net when dropping objects in Oracle Database 10g. When a user drops a table, Oracle automatically places it into the Recycle Bin.&lt;br /&gt;&lt;br /&gt;SQL&gt; create table table1 (a number(1));&lt;br /&gt;SQL&gt; INSERT INTO table1 values(1);&lt;br /&gt;SQL&gt; INSERT INTO table1 values(2);&lt;br /&gt;SQL&gt; INSERT INTO table1 values(3);&lt;br /&gt;SQL&gt; INSERT INTO table1 values(4);&lt;br /&gt;SQL&gt; commit;&lt;br /&gt;&lt;br /&gt;SQL&gt; select dbms_flashback.get_system_change_number from dual;&lt;br /&gt;&lt;br /&gt;SQL&gt; DROP TABLE hasan.table1;&lt;br /&gt;&lt;br /&gt;SQL&gt; SELECT ur.base_object, ur.object_name,ur.original_name FROM user_recyclebin ur;&lt;br /&gt;&lt;br /&gt;SQL&gt;  FASHBACK TABLE table1 TO BEFORE DROP;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;6.Flashback Database&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Flashback Database quickly rewinds an Oracle database to a previous time, to correct any problems caused by logical data corruptions or user errors. Flashback Database is like a 'rewind button' for your database. It provides database point in time recovery without requiring a backup of the database to first be restored. When you eliminate the time it takes to restore a database backup from tape, database point in time recovery is fast&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(204, 0, 0);"&gt;Related Topics:&lt;br /&gt;&lt;/span&gt;&lt;ol&gt;&lt;li&gt;&lt;a href="http://shaharear.blogspot.com/2008/04/flashback.html"&gt;Flashback Part #1 Basics&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://shaharear.blogspot.com/2008/04/flashback-part-2.html"&gt;Flashback Part #2 Setup and Maintenance&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-6008409997239463228?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/CHUEBqVeUuo" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-18T12:24:27.696+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2009/04/features-of-oracle-flashback.html</feedburner:origLink></item><item><title>Uninstall Oracle 10gR2 On Solaris 5.10</title><link>http://feedproxy.google.com/~r/shaharear/~3/VtHzxwJ56j0/un-install-oracle-10gr2-on-solaris-510.html</link><category>Oracle Installation and Configuration</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Thu, 09 Apr 2009 00:08:13 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-8357230069933792364</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/BkfgwQANWXo6Y00-dvp9I1wQfw8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BkfgwQANWXo6Y00-dvp9I1wQfw8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/BkfgwQANWXo6Y00-dvp9I1wQfw8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BkfgwQANWXo6Y00-dvp9I1wQfw8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;To uninstall Oracle 10gR2 from Solaris 5.10, please do the followings&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Remove all database, by running dbca.&lt;/li&gt;&lt;li&gt;Stop aall oracle  running process : A. Database Control : $ORACLE_HOME/bin/emctl stop dbconsole B.Oracle Net listener : $ORACLE_HOME/bin/lsnrctl stop C. iSQL*Plus : $ORACLE_HOME/bin/isqlplusctl stop D.Ultra Search : $ORACLE_HOME/bin/searchctl stop&lt;/li&gt;&lt;li&gt;Start Oracle Universal installer locating at $ORACLE_HOME/oui/bin/runInstaller.&lt;/li&gt;&lt;li&gt;In the Welcome window, click Deinstall Products.&lt;/li&gt;&lt;li&gt;In the Inventory screen, select the Oracle home and the products that you want to remove, then click Remove.&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-8357230069933792364?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/VtHzxwJ56j0" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-09T13:08:13.537+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2009/04/un-install-oracle-10gr2-on-solaris-510.html</feedburner:origLink></item><item><title>Multiplexing Control File</title><link>http://feedproxy.google.com/~r/shaharear/~3/aGW-17ZCbzU/multiplexing-control-file.html</link><category>Oracle Administration and Maintenance</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Wed, 08 Apr 2009 23:15:10 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-1829933785956232459</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/bSasJd4RQXncOls2lD-12HN29fQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/bSasJd4RQXncOls2lD-12HN29fQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/bSasJd4RQXncOls2lD-12HN29fQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/bSasJd4RQXncOls2lD-12HN29fQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Oracle consist of three major physical files, they are :&lt;br /&gt;&lt;ul&gt;&lt;li&gt; Controlfiles&lt;/li&gt;&lt;li&gt; Datafiles&lt;/li&gt;&lt;li&gt;Online Redo log files&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Among them control files are the most impotent one. Controlfile contains Database name, database creation date, Tablespace names, Physical location of datafiles and Recovery information.&lt;br /&gt;&lt;br /&gt;With default  installation, Oracle has 3 control files placed in same physical location. According to database availability, It is safe to place the 3 controlfiles in disk.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To see the current physical location of control file&lt;br /&gt;&lt;br /&gt;SQL&gt; select name from v$controlfile;&lt;br /&gt;&lt;br /&gt;NAME&lt;br /&gt;---------------------------------------------------------&lt;br /&gt;/ua1/control01.ctl&lt;br /&gt;/ua1/control02.ctl&lt;br /&gt;/ua1/control03.ctl&lt;br /&gt;&lt;br /&gt;Suppose we have two HD and those two are mount as /ua1 and /ua2. So we need to move at list one controlfile in  /ua1 and we move the 3rd contronlife.  there are several way to do the  Control File Multiplexing:&lt;br /&gt;&lt;br /&gt;1. Using SPFILE:&lt;br /&gt;&lt;br /&gt;The steps to multiplex control files using an SPFILE are describe bellow:&lt;br /&gt;&lt;br /&gt;Login as SYSDBA&lt;br /&gt;  &lt;br /&gt;1.    Alter the SPFILE: Using the ALTER SYSTEM SET command, alter the SPFILE to include a list of all control files to be used.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;SQL&gt; ALTER SYSTEM SET control_files='/ua1/control01.ctl'&lt;br /&gt;,'/ua1/control01.ctl', &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;'/ua1/control01.ctl' scope=spfile;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2.    Shut down the database: Shut down the database in order to create the additional/ relocate control files on the operating system.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;SQL&gt; SHUTDOWN IMMEDIATE;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;3.    Create additional control files: Using the operating system copy command, create/move the additional control files as required and verify that the files have been created in the appropriate directories.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;mv  /ua1/control01.ct  /ua2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;4.    Start the database: When the database is started the SPFILE will be read and the Oracle server will maintain all the control files listed in the CONTROL_FILES parameter.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;SQL&gt;STARTUP&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To see the changed physical location of control file&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt; SQL&gt; select name from v$controlfile;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;NAME&lt;br /&gt;---------------------------------------------------------&lt;br /&gt;/ua1/control01.ctl&lt;br /&gt;/ua1/control02.ctl&lt;br /&gt;/ua2/control03.ctl&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-1829933785956232459?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/aGW-17ZCbzU" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-09T12:15:10.797+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2009/03/multiplexing-control-file.html</feedburner:origLink></item><item><title>Find Top N resource absorbing SQL Queries</title><link>http://feedproxy.google.com/~r/shaharear/~3/gKFEhFraCwY/find-top-n-resource-absorbing-sql.html</link><category>SQL PL/SQL Tips</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Mon, 23 Feb 2009 01:18:19 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-5170746562826081841</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/RAVPIV7wkRHDSWjVjUTROu10Nio/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/RAVPIV7wkRHDSWjVjUTROu10Nio/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/RAVPIV7wkRHDSWjVjUTROu10Nio/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/RAVPIV7wkRHDSWjVjUTROu10Nio/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;At times database performance problems arise that require your diagnosis and correction. Sometimes problems are brought to your attention by users who complain about slow performance. Other times you might notice performance spikes in the Host CPU chart on the home page. Suppose user reported slow performance and this occurred in night or in holiday. Now You need to see which sql queries were run at that specific time along with their resources usages details.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;With default settings, in every hour a snapshots taken by Automatic Workload Repository (AWR) and those snapshots are available for next 7 days.  Here is a SQL  query that give the desired top N resource  sensitive queries :&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt;SELECT * FROM &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt; (SELECT X.SNAP_ID, X.SQL_ID,SQL_TEXT&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt; ,ROUND(X.ELAPSED_TIME/1000000/X.EXECUTIONS_DELTA,3) AVG_ELAPSED_TIME_SEC &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt; ,ROUND(X.CPU_TIME /1000000/X.EXECUTIONS_DELTA,3) AVG_CPU_TIME_SEC&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt; ,X.ELAPSED_TIME TOTAL_ELAPSED_TIME_MIC_SEC&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt; ,X.CPU_TIME TOTAL_CPU_TIME_MIC_SEC&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt; ,X.EXECUTIONS_DELTA EXECUTIONS&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt; FROM DBA_HIST_SQLTEXT DHST,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt; (SELECT DHSS.SNAP_ID,DHSS.SQL_ID SQL_ID,SUM(DHSS.CPU_TIME_DELTA) CPU_TIME, SUM (DHSS.ELAPSED_TIME_DELTA) ELAPSED_TIME &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt; , SUM(DHSS.EXECUTIONS_DELTA) EXECUTIONS_DELTA&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt; FROM DBA_HIST_SQLSTAT DHSS&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt; WHERE DHSS.SNAP_ID IN(SELECT SNAP_ID FROM DBA_HIST_SNAPSHOT&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt; WHERE &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt;BEGIN_INTERVAL_TIME &gt;= TO_DATE('18-feb-2009 18:00', 'dd-mon-yyyy hh24:mi')&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt; AND END_INTERVAL_TIME &lt;= TO_DATE('18-feb-2009 18:40', 'dd-mon-yyyy hh24:mi'))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt; AND PARSING_SCHEMA_NAME='SCOTT' &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt; GROUP BY DHSS.SQL_ID,DHSS.SNAP_ID) X &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt; WHERE X.SQL_ID=DHST.SQL_ID &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt; ORDER BY AVG_ELAPSED_TIME_SEC DESC&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt; ) WHERE rownum &lt; =200;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-5170746562826081841?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/gKFEhFraCwY" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-23T15:18:19.470+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2009/02/find-top-n-resource-absorbing-sql.html</feedburner:origLink></item><item><title>DRIVING_SITE  SQL Hint</title><link>http://feedproxy.google.com/~r/shaharear/~3/fHAyUHxcit8/drivingsite-sql-hint.html</link><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Wed, 11 Feb 2009 00:30:40 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-7921939977012967804</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/cU7OOYjUvH21fkSU7s0zZIWfaCo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/cU7OOYjUvH21fkSU7s0zZIWfaCo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/cU7OOYjUvH21fkSU7s0zZIWfaCo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/cU7OOYjUvH21fkSU7s0zZIWfaCo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;We all are know about Oracle Data Base Link and I called it dblink in short throughout this article. Usisg dblink you can easily access remote Database Object. Now Please think the following situation:&lt;br /&gt;&lt;br /&gt;&lt;h4 style="color: rgb(153, 51, 0);"&gt;Situation:&lt;/h4&gt;Suppose you have 2 tables: 1. table1 in local DB 2. table2 in remote DB.The table1 size is 10 MB and table2 size is 100 MB. We need to join those two tables and we access only in local DB.&lt;br /&gt;&lt;br /&gt;If you now think about performance, it is important to where the sql query executed and the join perform. For above situation, it is better to bring table1 from local DB to Remote DB and execute the sql in remote server and finally bring back the result in local DB.&lt;br /&gt;&lt;br /&gt;&lt;h4 style="color: rgb(102, 0, 0);"&gt;Lets do the job&lt;/h4&gt;    The DRIVING_SITE hint forces query execution to be done at a different site than that selected by Oracle. This hint can be used with either rule-based or cost-based optimization. The syntax of this hint is:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(0, 153, 0);"&gt; /*+DRIVING_SITE(table)*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;where table is the name or alias for the table at which site the execution should take place.&lt;br /&gt;&lt;br /&gt;&lt;h4 style="color: rgb(102, 0, 0);"&gt;Example:&lt;/h4&gt;&lt;span style="font-style: italic; color: rgb(0, 153, 0);"&gt;SELECT /*+DRIVING_SITE(table2)*/ * FROM tabl1, table2@remote_db&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(0, 153, 0);"&gt;    WHERE table1.DEPTNO = table2.DEPTNO;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If this query is executed without the hint, rows from table2 will be sent to the local site and the join will be executed there. With the hint, the rows from table1 will be sent to the remote site and the query will be executed there, returning the result to the local DB.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-7921939977012967804?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/fHAyUHxcit8" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-11T14:30:40.112+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2009/02/drivingsite-sql-hint.html</feedburner:origLink></item><item><title>create Foreign key On two diffrent schema table</title><link>http://feedproxy.google.com/~r/shaharear/~3/edJnF8y1IZ0/create-foreign-key-on-two-diffrent.html</link><category>Oracle Basics</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Wed, 11 Feb 2009 00:33:17 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-567873072738489417</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/6G-wv1nJ83egGRfgCkprP2d8n2U/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6G-wv1nJ83egGRfgCkprP2d8n2U/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/6G-wv1nJ83egGRfgCkprP2d8n2U/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6G-wv1nJ83egGRfgCkprP2d8n2U/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Some times you may face easy questions which can put into difficulties.  Today I got that kind of a question and  i am happy so that I get the answer though it take some time find it.&lt;br /&gt;&lt;br /&gt;Here is the question which i got from a forum member :&lt;br /&gt;&lt;br /&gt;" &lt;span style="color: rgb(204, 0, 0);"&gt;how to link a table from scott user to the hr user using a foreign key. For  an example  hr.emp to scott.dept using a foreign key&lt;/span&gt; "&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In my answer, I assume &lt;span style="color: rgb(0, 0, 0);"&gt;hr.emp&lt;/span&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; table has a colunm name scott_dept_id . So I create a foreign key on &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;hr.emp (&lt;/span&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;scott_dept_id) by referencing scott.dept (id).&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 204, 0); font-style: italic;"&gt;sql&gt; connect scott / pass;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0); font-style: italic;"&gt;sql&gt; GRANT select,update, delete, references on dept to hr;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Though only references  privilege required to create the foreign key &lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;sql&gt; connect hr/password;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0); font-style: italic;"&gt;sql&gt;  alter table emp add constraint fk_test foreign key (scott_dept_id) references scott.dept (id);&lt;/span&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So simple ! but hard  enough to bother you, if you not know exactly .  Thanks to that forum user who lead me to learn this thing . &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-567873072738489417?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/edJnF8y1IZ0" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-11T14:33:17.481+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2009/02/create-foreign-key-on-two-diffrent.html</feedburner:origLink></item><item><title>Reverse Key Index</title><link>http://feedproxy.google.com/~r/shaharear/~3/pCVt1RkkvBA/reverse-key-index.html</link><category>Oracle Basics</category><author>noreply@blogger.com (Hasan Shaharear)</author><pubDate>Tue, 10 Feb 2009 22:43:52 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-4890098019255913769</guid><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Xc1KTfsrUdhi5MU7bEdQC8KuSsU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Xc1KTfsrUdhi5MU7bEdQC8KuSsU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Xc1KTfsrUdhi5MU7bEdQC8KuSsU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Xc1KTfsrUdhi5MU7bEdQC8KuSsU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;I think we are familiar with Oracle Index, specially Bitmap Index. Indexes are  used to help oracle retrieve data faster. But there is a drawback of Index, if an index create on a large table which under go massive insert/ update, the index may raise contention issue.  To get ride from this Oracle provides couple of solutions and Reverse key Index is one of them.&lt;br /&gt;&lt;br /&gt;&lt;h4 style="color: rgb(255, 204, 0);"&gt;&lt;span style="color: rgb(102, 51, 102); font-weight: bold;"&gt;Real world case scenario&lt;/span&gt;&lt;br /&gt;&lt;/h4&gt;&lt;span style="font-style: italic; color: rgb(102, 51, 0);"&gt;Case 1&lt;/span&gt;: Suppose table 'track_user' contains  login related information  of a system.  The primary key column  'ID' of the table  populated by an increasing sequence. So  every new entries (for the index) come to the same blocks when  a row inserted into the table. This is the way contention may increase!&lt;br /&gt;&lt;br /&gt;As all we know that the primary key constraint is impose on column by creating an unique index on that column. So if we use reverse key indexes in this case then the index entries will go to different blocks and contention will be reduced.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(51, 0, 0);"&gt;Case 2&lt;/span&gt;: If you have a table with column which is populated by an increasing sequence and some times it go under some delete operation for old records. A index was created on That column   and this index is on face range scan when you issue a select on that table. But this index has contention issues on index blocks.&lt;br /&gt;&lt;br /&gt;To avoide the contention issue you can use Reverse key index as a soluation.&lt;br /&gt;&lt;br /&gt;&lt;h4 style="color: rgb(102, 51, 102);"&gt;What is Reverse key index ?&lt;/h4&gt;Reverse key index was first introduce in Oracle 8. A reverse key index reverses the bytes of each column indexed (except for the ROWID) while keeping the column order same as normal index.&lt;br /&gt;&lt;br /&gt;&lt;h4 style="color: rgb(102, 51, 102);"&gt;Uses&lt;/h4&gt;&lt;ol&gt;&lt;li&gt;Reverse key index can help avoid performance degradation in indexes in an Oracle Parallel server environment where modifications to the index are concentrated on a small set of leaf blocks. For example, if you insert rows with keys 101, 102 and 103 into a table with a regular index, the rows are likely to be inserted into the same leaf block. When users connected to different instances of the same database insert into the same block a pingoccurs.(When a block is written to disk by one instance so that another instance can read it, it is called a ping.) Excessive pinging will severely degrade performance, so you want to reduce it. In a Reverse Key Index the keys in our example become 101, 201 and 301, and the rows are inserted into disparate parts of the index segment. This type of index is therefore useful in a parallel server environment because it reduces pinging.&lt;/li&gt;&lt;li&gt;Reverse Key Indexes can also be useful in situations where users insert ascending values and delete lower values from a table. A regular index would become skewed, but a Reverse Key Index would not.&lt;/li&gt;&lt;li&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h4 style="color: rgb(102, 51, 102);"&gt;Disadvantages&lt;/h4&gt;With a Reverse Key Index you cannot run an index range scanning query. This is because lexically adjacent keys are not stored next to each other in a Reverse Key Index. You can only perform fetch-by-key value  or full-index scans . Of course, you can avoid the index and perform full table scans or use the parallel query option.&lt;br /&gt;&lt;br /&gt;&lt;h4 style="color: rgb(102, 51, 102);"&gt;Create And Manage Reverse Key Index&lt;/h4&gt;You create a Reverse Key Index with the key word REVERSE:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt; Create Index &lt;/span&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt;index_name &lt;/span&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt;&lt;index_name&gt; on table_name &lt;table_name&gt; (a,b,c) Reverse;&lt;/table_name&gt;&lt;/index_name&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can rebuild a Reverse Key Index into a regular index with the keyword NOREVERSE&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 51, 0);"&gt; Alter Index &lt;index_name&gt;index_name  Rebuild Noreverse;&lt;/index_name&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you rebuild a Reverse Key Index without the keyword NOREVERSE, it will rebuilt the Reverse Key Index.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 0, 0);"&gt; Alter Index &lt;/span&gt;&lt;index_name style="font-style: italic; color: rgb(153, 0, 0);"&gt;index_name  Rebuild;&lt;/index_name&gt;&lt;br /&gt;&lt;br /&gt;You cannot rebuild a normal index into a reverse key index. You must drop the normal index and create the reverse index.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5794742462833718439-4890098019255913769?l=shaharear.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/shaharear/~4/pCVt1RkkvBA" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-11T12:43:52.660+06:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://shaharear.blogspot.com/2009/02/reverse-key-index.html</feedburner:origLink></item><media:rating>nonadult</media:rating></channel></rss>

