<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Interviewing: The difference between Delete and Truncate in Oracle</title>
	<atom:link href="http://oraclesponge.wordpress.com/2008/03/17/interviewing-the-difference-between-delete-and-truncate/feed/" rel="self" type="application/rss+xml" />
	<link>http://oraclesponge.wordpress.com/2008/03/17/interviewing-the-difference-between-delete-and-truncate/</link>
	<description>Oracle Data Warehouse Design and Architecture</description>
	<pubDate>Fri, 04 Jul 2008 18:46:36 +0000</pubDate>
	<generator>http://wordpress.org/?v=MU</generator>
		<item>
		<title>By: Kashif</title>
		<link>http://oraclesponge.wordpress.com/2008/03/17/interviewing-the-difference-between-delete-and-truncate/#comment-50930</link>
		<dc:creator>Kashif</dc:creator>
		<pubDate>Wed, 09 Apr 2008 21:02:33 +0000</pubDate>
		<guid isPermaLink="false">http://oraclesponge.wordpress.com/?p=356#comment-50930</guid>
		<description>Will do,  thanks.

Kashif</description>
		<content:encoded><![CDATA[<p>Will do,  thanks.</p>
<p>Kashif</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Aldridge</title>
		<link>http://oraclesponge.wordpress.com/2008/03/17/interviewing-the-difference-between-delete-and-truncate/#comment-50927</link>
		<dc:creator>David Aldridge</dc:creator>
		<pubDate>Wed, 09 Apr 2008 20:24:15 +0000</pubDate>
		<guid isPermaLink="false">http://oraclesponge.wordpress.com/?p=356#comment-50927</guid>
		<description>Hmm, let me think about that. I do have a list somewhere. If I don't post it in the next couple of days send me a reimnder ... :)</description>
		<content:encoded><![CDATA[<p>Hmm, let me think about that. I do have a list somewhere. If I don&#8217;t post it in the next couple of days send me a reimnder &#8230; :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kashif</title>
		<link>http://oraclesponge.wordpress.com/2008/03/17/interviewing-the-difference-between-delete-and-truncate/#comment-50925</link>
		<dc:creator>Kashif</dc:creator>
		<pubDate>Wed, 09 Apr 2008 19:02:01 +0000</pubDate>
		<guid isPermaLink="false">http://oraclesponge.wordpress.com/?p=356#comment-50925</guid>
		<description>Hi David,

I've seen you publish some lists on your blog in the past, so I was wondering if you have a list of interview questions you have asked ETL developers? I'm trying to come up with a list that is not too tool-specific (we use DataStage ourselves), and I'm debating if it should be Oracle-heavy. Thoughts on that?

Thanks.

Kashif</description>
		<content:encoded><![CDATA[<p>Hi David,</p>
<p>I&#8217;ve seen you publish some lists on your blog in the past, so I was wondering if you have a list of interview questions you have asked ETL developers? I&#8217;m trying to come up with a list that is not too tool-specific (we use DataStage ourselves), and I&#8217;m debating if it should be Oracle-heavy. Thoughts on that?</p>
<p>Thanks.</p>
<p>Kashif</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mathew Butler</title>
		<link>http://oraclesponge.wordpress.com/2008/03/17/interviewing-the-difference-between-delete-and-truncate/#comment-50850</link>
		<dc:creator>Mathew Butler</dc:creator>
		<pubDate>Mon, 24 Mar 2008 19:39:54 +0000</pubDate>
		<guid isPermaLink="false">http://oraclesponge.wordpress.com/?p=356#comment-50850</guid>
		<description>Given this some more thought...

I think it has nothing to do with the table stats. It's purely that truncate is DDL, and I hypothesise that the optimizer just doesn't know that kind of DDL and so has to re-parse cursors to ensure that the table can still support the cached query.</description>
		<content:encoded><![CDATA[<p>Given this some more thought&#8230;</p>
<p>I think it has nothing to do with the table stats. It&#8217;s purely that truncate is DDL, and I hypothesise that the optimizer just doesn&#8217;t know that kind of DDL and so has to re-parse cursors to ensure that the table can still support the cached query.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mathew Butler</title>
		<link>http://oraclesponge.wordpress.com/2008/03/17/interviewing-the-difference-between-delete-and-truncate/#comment-50848</link>
		<dc:creator>Mathew Butler</dc:creator>
		<pubDate>Mon, 24 Mar 2008 19:15:37 +0000</pubDate>
		<guid isPermaLink="false">http://oraclesponge.wordpress.com/?p=356#comment-50848</guid>
		<description>My interpretation:

The change in data object id signifies that the objects segments have been discarded. So, although the objects stats have not been affected - they would no longer reflect the data stored in the table. And in some senses this is really a new object ( as far as cached cursors are concerned ). 

I expect that the optimizer avoids making any assumptions about the state of the object before the truncate by invalidating referencing cursors.</description>
		<content:encoded><![CDATA[<p>My interpretation:</p>
<p>The change in data object id signifies that the objects segments have been discarded. So, although the objects stats have not been affected - they would no longer reflect the data stored in the table. And in some senses this is really a new object ( as far as cached cursors are concerned ). </p>
<p>I expect that the optimizer avoids making any assumptions about the state of the object before the truncate by invalidating referencing cursors.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Aldridge</title>
		<link>http://oraclesponge.wordpress.com/2008/03/17/interviewing-the-difference-between-delete-and-truncate/#comment-50844</link>
		<dc:creator>David Aldridge</dc:creator>
		<pubDate>Mon, 24 Mar 2008 12:01:25 +0000</pubDate>
		<guid isPermaLink="false">http://oraclesponge.wordpress.com/?p=356#comment-50844</guid>
		<description>Oh, maybe the reason it's there is because of the change in the data object id. Maybe that is significant.</description>
		<content:encoded><![CDATA[<p>Oh, maybe the reason it&#8217;s there is because of the change in the data object id. Maybe that is significant.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Aldridge</title>
		<link>http://oraclesponge.wordpress.com/2008/03/17/interviewing-the-difference-between-delete-and-truncate/#comment-50843</link>
		<dc:creator>David Aldridge</dc:creator>
		<pubDate>Mon, 24 Mar 2008 12:00:51 +0000</pubDate>
		<guid isPermaLink="false">http://oraclesponge.wordpress.com/?p=356#comment-50843</guid>
		<description>It's an interesting feature for sure. It makes sense in some ways, but since a truncate is not going to change the table statistics one also wonders why it's there. Maybe the truncate command ought to come with a "no invalidate" option, like dbms_stats gathering procedures.</description>
		<content:encoded><![CDATA[<p>It&#8217;s an interesting feature for sure. It makes sense in some ways, but since a truncate is not going to change the table statistics one also wonders why it&#8217;s there. Maybe the truncate command ought to come with a &#8220;no invalidate&#8221; option, like dbms_stats gathering procedures.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dombrooks</title>
		<link>http://oraclesponge.wordpress.com/2008/03/17/interviewing-the-difference-between-delete-and-truncate/#comment-50836</link>
		<dc:creator>dombrooks</dc:creator>
		<pubDate>Fri, 21 Mar 2008 19:42:37 +0000</pubDate>
		<guid isPermaLink="false">http://oraclesponge.wordpress.com/?p=356#comment-50836</guid>
		<description>&#62;  you know if that’s documented anywhere?
I've observed the behaviour, not sure I've read it definitively.

Just did a quick search of various sources.

They are hardly the most convincing of articles - their style and spelling and grammatical mistakes detracting from their authority, but from Metalink note 62143.1 "Understanding and Tuning the Shared Pool":

"
Avoid Invalidations

Some specific orders will change the state of cursors to INVALIDATE. These orders modify directly the context of related objects associated 
with cursors. That's orders are TRUNCATE, ANALYZE or DBMS_STATS.GATHER_XXX on tables or indexes, grants changes on underlying objects. The associated cursors will stay in the SQLAREA but when it will be reference next time, it should be reloaded and reparsed fully, so the global performance will be impacted. 
"

and also metalink note 123214.1 - "Truncate - Causes Invalidations in the LIBRARY CACHE".</description>
		<content:encoded><![CDATA[<p>&gt;  you know if that’s documented anywhere?<br />
I&#8217;ve observed the behaviour, not sure I&#8217;ve read it definitively.</p>
<p>Just did a quick search of various sources.</p>
<p>They are hardly the most convincing of articles - their style and spelling and grammatical mistakes detracting from their authority, but from Metalink note 62143.1 &#8220;Understanding and Tuning the Shared Pool&#8221;:</p>
<p>&#8221;<br />
Avoid Invalidations</p>
<p>Some specific orders will change the state of cursors to INVALIDATE. These orders modify directly the context of related objects associated<br />
with cursors. That&#8217;s orders are TRUNCATE, ANALYZE or DBMS_STATS.GATHER_XXX on tables or indexes, grants changes on underlying objects. The associated cursors will stay in the SQLAREA but when it will be reference next time, it should be reloaded and reparsed fully, so the global performance will be impacted.<br />
&#8221;</p>
<p>and also metalink note 123214.1 - &#8220;Truncate - Causes Invalidations in the LIBRARY CACHE&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Aldridge</title>
		<link>http://oraclesponge.wordpress.com/2008/03/17/interviewing-the-difference-between-delete-and-truncate/#comment-50832</link>
		<dc:creator>David Aldridge</dc:creator>
		<pubDate>Thu, 20 Mar 2008 18:20:47 +0000</pubDate>
		<guid isPermaLink="false">http://oraclesponge.wordpress.com/?p=356#comment-50832</guid>
		<description>Always easy to be wise in hindsight, but preventing an accidental truncation is sometimes just as easy as disabling table locks as long as you don't need table locks in your regular application processing.</description>
		<content:encoded><![CDATA[<p>Always easy to be wise in hindsight, but preventing an accidental truncation is sometimes just as easy as disabling table locks as long as you don&#8217;t need table locks in your regular application processing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Donald K. Burleson</title>
		<link>http://oraclesponge.wordpress.com/2008/03/17/interviewing-the-difference-between-delete-and-truncate/#comment-50831</link>
		<dc:creator>Donald K. Burleson</dc:creator>
		<pubDate>Thu, 20 Mar 2008 15:19:45 +0000</pubDate>
		<guid isPermaLink="false">http://oraclesponge.wordpress.com/?p=356#comment-50831</guid>
		<description>David did you see this?

http://www.freelists.org/archives/oracle-l/03-2008/msg00493.html

Very funny!

***********************************************

In this scenario you just truncated a table in production that you
meant to truncate in development.  Now what do you do?

1)      Shout OHHH SH**! (fill in the '*' with whatever letters you think
are appropriate)

2)      After you've gotten over the initial shock of this monumental mistake, 
do a

           Shutdown immediate;

3)      Stop, think and immediately tell your manager or coworkers what you did.

4)      Curse a coworker who had nothing to do with YOUR mistake.  It won't
help the situation, but now you can feel bad for two stupid mistakes.

5)      Apologize for cursing your coworker and accept FULL responsibility
for YOUR mistake.

6)      Now that you are rational, calmly discuss with your
manager/coworkers the best course of action.  If it is decided to
proceed with a point-in-time recovery, then continue with the
following steps.

7)      Backup the controlfile in case you have to restart the recovery:

           Alter database backup controlfile to
'$ORACLE_HOME/dbs/$ORACLE_SID_backup.ctl';

8)      Check the alert log for the exact time you started the "shutdown 
immediate".

9)      Think about how much time may have passed between step 1 and 2,
then decide on a safe point-in-time before the truncate occurred.

10)     Run 'rman'.

            RMAN&#62; connect target /
            RMAN&#62; restore database;
            -- After restore completes
            RMAN&#62; exit

11)     Run 'sqlplus "/ as sysdba'

            SQL&#62; recover database until time 'YYYY-MM-DD:HH24:MI:SS';
            SQL&#62; alter database open resetlogs;
            --shutdown may take a while to apply undo from recovery.
            SQL&#62; shutdown immediate;
            SQL&#62; Startup restrict;

12)     Check to make sure everything looks OK.

13)     If everything looks good, then open the database to the users:

            SQL&#62; shutdown immediate;
            SQL&#62; startup;

14)     Thank your coworkers for all their help and be grateful you still
have a job.</description>
		<content:encoded><![CDATA[<p>David did you see this?</p>
<p><a href="http://www.freelists.org/archives/oracle-l/03-2008/msg00493.html" rel="nofollow">http://www.freelists.org/archives/oracle-l/03-2008/msg00493.html</a></p>
<p>Very funny!</p>
<p>***********************************************</p>
<p>In this scenario you just truncated a table in production that you<br />
meant to truncate in development.  Now what do you do?</p>
<p>1)      Shout OHHH SH**! (fill in the &#8216;*&#8217; with whatever letters you think<br />
are appropriate)</p>
<p>2)      After you&#8217;ve gotten over the initial shock of this monumental mistake,<br />
do a</p>
<p>           Shutdown immediate;</p>
<p>3)      Stop, think and immediately tell your manager or coworkers what you did.</p>
<p>4)      Curse a coworker who had nothing to do with YOUR mistake.  It won&#8217;t<br />
help the situation, but now you can feel bad for two stupid mistakes.</p>
<p>5)      Apologize for cursing your coworker and accept FULL responsibility<br />
for YOUR mistake.</p>
<p>6)      Now that you are rational, calmly discuss with your<br />
manager/coworkers the best course of action.  If it is decided to<br />
proceed with a point-in-time recovery, then continue with the<br />
following steps.</p>
<p>7)      Backup the controlfile in case you have to restart the recovery:</p>
<p>           Alter database backup controlfile to<br />
&#8216;$ORACLE_HOME/dbs/$ORACLE_SID_backup.ctl&#8217;;</p>
<p>8)      Check the alert log for the exact time you started the &#8220;shutdown<br />
immediate&#8221;.</p>
<p>9)      Think about how much time may have passed between step 1 and 2,<br />
then decide on a safe point-in-time before the truncate occurred.</p>
<p>10)     Run &#8216;rman&#8217;.</p>
<p>            RMAN&gt; connect target /<br />
            RMAN&gt; restore database;<br />
            &#8212; After restore completes<br />
            RMAN&gt; exit</p>
<p>11)     Run &#8217;sqlplus &#8220;/ as sysdba&#8217;</p>
<p>            SQL&gt; recover database until time &#8216;YYYY-MM-DD:HH24:MI:SS&#8217;;<br />
            SQL&gt; alter database open resetlogs;<br />
            &#8211;shutdown may take a while to apply undo from recovery.<br />
            SQL&gt; shutdown immediate;<br />
            SQL&gt; Startup restrict;</p>
<p>12)     Check to make sure everything looks OK.</p>
<p>13)     If everything looks good, then open the database to the users:</p>
<p>            SQL&gt; shutdown immediate;<br />
            SQL&gt; startup;</p>
<p>14)     Thank your coworkers for all their help and be grateful you still<br />
have a job.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
