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

<channel>
	<title>An Oracle blog - Amardeep Sidhu &#187; Oracle Basics</title>
	<atom:link href="http://amardeepsidhu.com/blog/category/oracle-basics/feed/" rel="self" type="application/rss+xml" />
	<link>http://amardeepsidhu.com/blog</link>
	<description>Little bit of fun with Oracle and the related technologies...</description>
	<lastBuildDate>Thu, 22 Dec 2011 05:59:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Learning Regular Expressions</title>
		<link>http://amardeepsidhu.com/blog/2008/02/27/learning-regular-expressions/</link>
		<comments>http://amardeepsidhu.com/blog/2008/02/27/learning-regular-expressions/#comments</comments>
		<pubDate>Wed, 27 Feb 2008 15:59:50 +0000</pubDate>
		<dc:creator>Sidhu</dc:creator>
				<category><![CDATA[Oracle Basics]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Regular Expressions]]></category>

		<guid isPermaLink="false">http://amardeepsidhu.com/blog/2008/02/27/learning-regular-expressions/</guid>
		<description><![CDATA[From Eddie&#8217;s blog I got a link to 3 posts on Regular Expressions on OTN written by CD. Wonderful stuff. Check out. Part 1 Part 2 Part 3 &#38; Thanks CD&#8230;wonderful work buddy !<div class="addthis_toolbox addthis_default_style " addthis:url='http://amardeepsidhu.com/blog/2008/02/27/learning-regular-expressions/' addthis:title='Learning Regular Expressions '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></description>
			<content:encoded><![CDATA[<p>From <a href="http://awads.net/wp/2008/02/25/5-useful-links-for-2008-02-25/" title="Eddie's blog" target="_blank">Eddie&#8217;s blog</a> I got a link to 3 posts on Regular Expressions on OTN written by <a href="http://www.l2is.com/apex/f?p=999:3:3754894570320873::NO::P3_NAME:ARTICLE46" title="CD's blog" target="_blank">CD</a>. Wonderful stuff. Check out.</p>
<p><a href="http://forums.oracle.com/forums/thread.jspa?threadID=427716" title="Part 1" target="_blank">Part 1</a></p>
<p><a href="http://forums.oracle.com/forums/thread.jspa?threadID=430647" title="Part 2" target="_blank">Part 2</a></p>
<p><a href="http://forums.oracle.com/forums/thread.jspa?threadID=435109" title="Part 3" target="_blank">Part 3</a></p>
<p>&amp; Thanks CD&#8230;wonderful work buddy !</p>
<div class="addthis_toolbox addthis_default_style " addthis:url='http://amardeepsidhu.com/blog/2008/02/27/learning-regular-expressions/' addthis:title='Learning Regular Expressions '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></content:encoded>
			<wfw:commentRss>http://amardeepsidhu.com/blog/2008/02/27/learning-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Oracle from Dizwell&#8230;</title>
		<link>http://amardeepsidhu.com/blog/2008/01/03/oracle-from-dizwell/</link>
		<comments>http://amardeepsidhu.com/blog/2008/01/03/oracle-from-dizwell/#comments</comments>
		<pubDate>Thu, 03 Jan 2008 17:11:00 +0000</pubDate>
		<dc:creator>Sidhu</dc:creator>
				<category><![CDATA[Oracle Basics]]></category>
		<category><![CDATA[dizwell]]></category>
		<category><![CDATA[howard rogers]]></category>

		<guid isPermaLink="false">http://amardeepsidhu.com/blog/?p=47</guid>
		<description><![CDATA[Howard has posted a pdf on Oracle Administration on his new website. Do check out. Its awesome. Update: Howard has shutdown his website, so unfortunately this pdf is not available. Sidhu<div class="addthis_toolbox addthis_default_style " addthis:url='http://amardeepsidhu.com/blog/2008/01/03/oracle-from-dizwell/' addthis:title='Oracle from Dizwell&#8230; '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Howard has posted <a href="http://www.dizwell.net/prod/concepts">a pdf</a> on <span style="font-style: italic">Oracle Administration</span> on his <a href="http://www.dizwell.net/prod/">new website</a>. Do check out. Its awesome.</p>
<p><strong>Update:</strong> Howard has <a href="http://dizwell.net/" target="_blank">shutdown</a> his website, so unfortunately this pdf is not available.</p>
<p>Sidhu</p>
<div class="addthis_toolbox addthis_default_style " addthis:url='http://amardeepsidhu.com/blog/2008/01/03/oracle-from-dizwell/' addthis:title='Oracle from Dizwell&#8230; '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></content:encoded>
			<wfw:commentRss>http://amardeepsidhu.com/blog/2008/01/03/oracle-from-dizwell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Oracle from Eddie Awad&#8230;</title>
		<link>http://amardeepsidhu.com/blog/2007/11/27/oracle-from-eddie-awad/</link>
		<comments>http://amardeepsidhu.com/blog/2007/11/27/oracle-from-eddie-awad/#comments</comments>
		<pubDate>Tue, 27 Nov 2007 15:15:00 +0000</pubDate>
		<dc:creator>Sidhu</dc:creator>
				<category><![CDATA[Oracle Basics]]></category>
		<category><![CDATA[eddie awad]]></category>
		<category><![CDATA[learning oracle]]></category>

		<guid isPermaLink="false">http://amardeepsidhu.com/blog/?p=44</guid>
		<description><![CDATA[Eddie Awad started a new series Oracle in 3 minutes on his blog. In the first post he has discussed about multi-versioning. Its a must watch for everyone who is working on Oracle. Hoping to get more of such stuff from Eddie. Sidhu<div class="addthis_toolbox addthis_default_style " addthis:url='http://amardeepsidhu.com/blog/2007/11/27/oracle-from-eddie-awad/' addthis:title='Oracle from Eddie Awad&#8230; '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></description>
			<content:encoded><![CDATA[<p><a href="http://awads.net/wp/">Eddie Awad</a> started a new series <a href="http://awads.net/wp/2007/11/26/oracle-in-3-minutes-multi-versioning/"><span style="font-weight: bold;">Oracle in 3 minutes</span></a> on his <a href="http://awads.net/wp/">blog</a>. In the first post he has discussed about multi-versioning. Its a must watch for everyone who is working on Oracle. Hoping to get more of such stuff from Eddie.</p>
<p>Sidhu</p>
<div class="addthis_toolbox addthis_default_style " addthis:url='http://amardeepsidhu.com/blog/2007/11/27/oracle-from-eddie-awad/' addthis:title='Oracle from Eddie Awad&#8230; '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></content:encoded>
			<wfw:commentRss>http://amardeepsidhu.com/blog/2007/11/27/oracle-from-eddie-awad/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>UNDO tablespace in Oracle&#8230;</title>
		<link>http://amardeepsidhu.com/blog/2007/10/09/undo-tablespace-in-oracle/</link>
		<comments>http://amardeepsidhu.com/blog/2007/10/09/undo-tablespace-in-oracle/#comments</comments>
		<pubDate>Tue, 09 Oct 2007 14:14:00 +0000</pubDate>
		<dc:creator>Sidhu</dc:creator>
				<category><![CDATA[Oracle Basics]]></category>

		<guid isPermaLink="false">http://amardeepsidhu.com/blog/?p=40</guid>
		<description><![CDATA[Today, I was following a thread on Oracle Forums. Someone asked a question about UNDO tablespace wrt to a scenario. The question was:There is a database and its hot backup is taken on Friday. Now for Saturday, Sunday and Monday there are archive logs but no backups. Suppose the machine crashes on Monday. After we [...]<div class="addthis_toolbox addthis_default_style " addthis:url='http://amardeepsidhu.com/blog/2007/10/09/undo-tablespace-in-oracle/' addthis:title='UNDO tablespace in Oracle&#8230; '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Today, I was following <a href="http://forums.oracle.com/forums/thread.jspa?threadID=571079">a thread</a> on <a href="http://forums.oracle.com">Oracle Forums</a>. Someone asked a question about UNDO tablespace wrt to a scenario. The question was:<br /><span style="font-style: italic;">There is a database and its hot backup is taken on Friday. Now for Saturday, Sunday and Monday there are archive logs but no backups. Suppose the machine crashes on Monday. After we restore the database to Friday (from backup), recovery will happen. As UNDO tablespace is of Friday so it has no information related to transactions that happened on Saturday, Sunday and Monday. So in the end of recovery process when we need to rollback some transactions from where that required information will come ?</p>
<p></span><a href="http://www.dizwell.com">Howard</a> did 3 beautiful follow ups of this post, explaining how UNDO works. Just saving it here for quick reference. Hope its no copyright mess <img src='http://amardeepsidhu.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span style="font-weight: bold;">Follow up 1: </span><br /><span style="font-style: italic;">Yes, it can certainly be confusing, especially when you get told completely incorrect information! As has already (and thankfully!) been pointed out, redo logs contain redo change records from both committed and uncommitted transactions. </span></p>
<p><span style="font-style: italic;">The answer to your question is that as we re-perform transactions by applying redo in a recovery session, we redo exactly what would have been done when the transactions were first performed. That is, we&#8217;d see a redo change record that says (in effect) update EMP set sal=900 where ename=&#8217;Bob&#8217;, so we&#8217;d find the Bob record in the restored Friday copy of the data file, and we&#8217;d lock that record. Then we&#8217;d store details of Bob&#8217;s existing salary in an undo block. Then we&#8217;d store the new and old salaries in redo (yup, recovery generates redo!). Then we&#8217;d change the Bob record itself. </span></p>
<p><span style="font-style: italic;">If that&#8217;s all that&#8217;s in the archives and online redo logs, that&#8217;s all that happens: Bob&#8217;s record is left locked and changed. At the end of the recovery process, we realise that a lot of re-performed transactions need rolling back, so SMON does that&#8230;. and it knows what to roll the stuff back to because in re-performing the transactions, we generated fresh undo.</span></p>
<p><span style="font-style: italic;">So your question says, &#8220;how does the uncommited transactions rolled back with the Friday undo tablespace since they do [not] have latest uncommited trnsactions&#8221;, but that&#8217;s not right. The undo tablespace certainly STARTS at the state it was in on Friday. But as recovery proceeds, it gets &#8216;freshened up&#8217;, because the new transactions generate fresh undo.</span></p>
<p><span style="font-style: italic;">(A slightly more accurate description would be to point out that when you generated undo on Saturday and Sunday, those changes to the undo blocks would themselves have generated redo. Therefore, your redo stream, archives and online alike, have the necessary information to recover the undo tablespace. Personally, I don&#8217;t find that any more informative than thinking that applying redo generates fresh undo, but it&#8217;s up to you which mental model you prefer to work with).</span></p>
<p><span style="font-weight: bold;">Follow up 2:<br /></span><i style="font-style: italic;">>does &#8220;recovery generates redo&#8221; mean that during recovery we regenerate the same amount >of redo that was generated since the last backup</i></p>
<p><span style="font-style: italic;">No, it&#8217;s not the same. If you do a simple test, you&#8217;ll see that. Update EMP, commit, check with Log Miner that the redo is in the logs in analyzable form. The blow up your database, restore it and recover it. Your log sequence number will have moved on, redo will have been generated&#8230; but you can mine the logs till Christmas and you won&#8217;t find a second &#8216;update EMP&#8217; set of redo records.</span></p>
<p><span style="font-style: italic;">That&#8217;s why I mentioned the &#8216;more accurately&#8217; bit further on in my original reply. Recovery is a bit more subtle than just sitting there issuing a lot of insert/update/delete statements as if from the keyboard of an incredibly fast typist! Metaphorically you can say, &#8220;We repeat transactions during recovery&#8221;. But actually, it&#8217;s &#8220;we apply redo change vectors&#8221;&#8230; and that doesn&#8217;t generate a one-for-one amount of redo as the original transactions did. </span></p>
<p><i style="font-style: italic;">>Will there be duplicate archive logs then?</i></p>
<p><span style="font-style: italic;">No. Do the Log Mining test to see this for yourself. The updates you did before the blow-up will not be visible in the logs from after (or during) the recovery.</span></p>
<p><i style="font-style: italic;">>Can we say that the undo tablespace starts from scratch with no undo at all</i></p>
<p><span style="font-style: italic;">I&#8217;m not sure what you&#8217;re getting at, but an undo segment is just a special sort of table, and it&#8217;s got data stored in it, even if the transactions that placed them there are long-since finished. So when you restore that file on Monday, it comes back in the state it was in when it was backed up -with data in it. Leaving aside undo_retention for a moment, it follows from the fact that you&#8217;re doing a database recovery that none of the stuff inside the rollback segments is related to &#8220;live&#8221; transactions, therefore all of it is over-writeable. So in that sense, yes, you could say the undo tablespace, just after restore and just before recovery, is &#8216;clean&#8217;.</span></p>
<p><span style="font-weight: bold;">Follow up 3:<br /></span><span style="font-style: italic;">I didn&#8217;t give &#8220;2 ideas&#8221;. I gave just one. I just happened to give you the option of thinking of it in two different ways. </span></p>
<p><span style="font-style: italic;">Applying redo causes transactions to be re-performed. That is the only, solo, number 1, all on its own, lonely idea being conveyed here.</span></p>
<p><span style="font-style: italic;">Now you can describe the re-performance of transactions either as &#8220;re-doing the transactions&#8221; as if some virtual user were sitting there typing insert, update and delete statements maniacally fast. That&#8217;s the way I usually think of it, largely because that&#8217;s what it looks like when you use Log Miner to peer inside the logs. Or you can think of it in a slightly more technical and accurate way, of taking the description of changes to byte-data which the redo change vectors represent and re-applying those changes.</span></p>
<p><span style="font-style: italic;">They&#8217;re both descriptions of exactly the same process with the same outcome. They just happen to use different words to describe them because some people&#8217;s mental models of what is happening work better with one than the other. It doesn&#8217;t help, however, to start thinking that somehow I&#8217;ve described two different processes. </span></p>
<p><span style="font-style: italic;">By way of a rather stretched analogy. Suppose you are a photographer. You take a lovely colour photograph of a landscape. You make a couple of copies of this photograph. The copy you framed and took especial care of one day gets damaged. Now, you can either repair that photo by going back to the scene, setting up the camera in the exact spot as before, waiting until the light conditions are exactly as they were, and then re-taking the shot. Or you can take the existing photo, compare it with another copy of the photo, and where you are lacking red/green/blue information in the damaged picture, you &#8216;paint in&#8217; the corresponding red/blue/green values determined from the other print. Either way, you end up with a new photograph that looks like the old one did, and that&#8217;s the important thing: you end up with a restored print to hang back on your wall. </span></p>
<p><span style="font-style: italic;">Technically, Oracle recoveries apply deltas to existing data, rather than re-performing transactions as if done by a human being with very fast fingers. So that&#8217;s the &#8220;truth&#8221; if you want to think in those terms. But the core fact is, recovery restores data and it doesn&#8217;t really matter precisely HOW that&#8217;s done: whatever description we give for the process will be &#8220;wrong&#8221;, in either case, because only people who have seen the source code know *actually* how it&#8217;s done. So, I just as happily thing of &#8220;very fast fingers&#8221; as &#8220;applying deltas&#8221;, and in fact, I prefer that mental model. I just gave you the choice of models, in other words. But don&#8217;t, please, confuse that with their being two mechanisms.</span></p>
<p><span style="font-style: italic;">I have no idea why on Earth anyone participating in this thread is so hung up about the undo tablespace. The central question appears to be, &#8216;How can an undo tablespace from Friday help in the recovery of a database the following Monday&#8217;. But I explained that the first time and 20 posts ago! Very simply, during a recovery, the undo tablespace gets rolled forward like any other part of the database. It gets redo applied to it just as much as the USERS tablespace does. At the end of the rolled forward process, your undo tablespace is effectively a Monday tablespace. It&#8217;s fresh. It&#8217;s got all the undo generated by the weekend&#8217;s transactions in it. And there&#8217;s a bunch of transactions which were uncomitted at the time the database blew up, so although recovery blindly replayed those transactions and therefore re-performed them, they are left there in an uncommitted state and SMON goes ahead and rolls them back (users also help, but SMON does the bulk of the work). </span></p>
<p><span style="font-style: italic;">And SMON knows what to roll the uncommitted transactions back to because all the undo needed to do that was FRESHLY created by the recovery&#8217;s roll forward phase.</span></p>
<p><span style="font-style: italic;">You don&#8217;t need to read anything into the sentence in bold that isn&#8217;t there in plain English. You have to stop looking for deep and secret meanings and just read the words that are there: Your redo, whether it comes from the online logs or the archives, contains all the information necessary to recover the undo tablespace. Just as it has all the information necessary to recover ANY tablespace, in fact. </span></p>
<p><span style="font-style: italic;">Think of an undo segment just as if it were the EMP segment, or the DEPT segment. You don&#8217;t seem to be bothered about EMP or DEPT being restored from Friday and yet managing to be recovered to the state they were in on Monday. Neither should anyone be surprised that a Friday undo segment can be transformed into a Monday undo segment. That is, after all, what recovery </span><i style="font-style: italic;">does</i><span style="font-style: italic;">.</span></p>
<p><span style="font-style: italic;">Recovery is the application of redo to a datafile to make it and the segments it contains -be they &#8220;ordinary&#8221; segments like tables and indexes, or more &#8220;exotic&#8221; segments like undo segments- more up&#8211;to-date. That means recovery is the &#8220;rolling forward in time of a datafile&#8221;. </span></p>
<p><span style="font-style: italic;">But when we start rolling forward, we can&#8217;t predict the future. So when I see &#8220;update EMP set sal=900&#8243; in the redo stream, I do not yet know whether you managed to commit that or not. I can&#8217;t see ahead. So I just blindly re-play that update and keep my fingers crossed. And I do that for every transaction recorded in the redo stream. And in the process of replaying that transaction, I also re-generate the fact that the original salaries in the EMP table were 800&#8230; which means I&#8217;ve just re-generated the undo for the EMP transaction.</span></p>
<p><span style="font-style: italic;">Only at the end of the roll forward phase can I look around and see, &#8216;Ah, that one wasn&#8217;t committed; neither was that one; and this one wasn&#8217;t even finished when the database blew up&#8217;. I therefore set SMON to work rolling those uncommitted transactions back&#8230; and it is at THAT point that the undo tablespace, storing that freshly-recreated undo, becomes vital for completing the recovery process.</span></p>
<p><span style="font-style: italic;">In words of few syllables: every recovery requires a roll forward and a roll back phase. Redo lets us roll things forward. Undo allows us to do the roll back. The undo tablespace is vital to recovering a database, therefore, because without it, half the job couldn&#8217;t be done.</span></p>
<p>Sidhu<span style="font-style: italic;"><br /></span></p>
<div class="addthis_toolbox addthis_default_style " addthis:url='http://amardeepsidhu.com/blog/2007/10/09/undo-tablespace-in-oracle/' addthis:title='UNDO tablespace in Oracle&#8230; '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></content:encoded>
			<wfw:commentRss>http://amardeepsidhu.com/blog/2007/10/09/undo-tablespace-in-oracle/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Oracle concepts&#8230;</title>
		<link>http://amardeepsidhu.com/blog/2007/06/13/oracle-concepts/</link>
		<comments>http://amardeepsidhu.com/blog/2007/06/13/oracle-concepts/#comments</comments>
		<pubDate>Wed, 13 Jun 2007 16:46:00 +0000</pubDate>
		<dc:creator>Sidhu</dc:creator>
				<category><![CDATA[Oracle Basics]]></category>

		<guid isPermaLink="false">http://amardeepsidhu.com/blog/?p=21</guid>
		<description><![CDATA[A very nice series of articles by Howard Rogers about Oracle Concepts. It includes all the basics like what a database, instance is ? Various types of files and all basic stuff. Read it here Sidhu<div class="addthis_toolbox addthis_default_style " addthis:url='http://amardeepsidhu.com/blog/2007/06/13/oracle-concepts/' addthis:title='Oracle concepts&#8230; '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></description>
			<content:encoded><![CDATA[<p>A very nice series of articles by Howard Rogers about Oracle Concepts. It includes all the basics like what a database, instance is ? Various types of files and all basic stuff. Read it <a href="http://www.dizwell.com/prod/node/271">here</a></p>
<p>Sidhu</p>
<div class="addthis_toolbox addthis_default_style " addthis:url='http://amardeepsidhu.com/blog/2007/06/13/oracle-concepts/' addthis:title='Oracle concepts&#8230; '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>]]></content:encoded>
			<wfw:commentRss>http://amardeepsidhu.com/blog/2007/06/13/oracle-concepts/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

