<?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>The Angry Geek &#187; Oracle Database</title>
	<atom:link href="http://www.angry-geek.org/category/oracle-database/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.angry-geek.org</link>
	<description>I am geek - hear me roar!</description>
	<lastBuildDate>Mon, 12 Apr 2010 16:27:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Oracle: Moving Data to a new Tablespace</title>
		<link>http://www.angry-geek.org/2009/01/oracle-moving-data-to-a-new-tablespace/</link>
		<comments>http://www.angry-geek.org/2009/01/oracle-moving-data-to-a-new-tablespace/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 16:02:02 +0000</pubDate>
		<dc:creator>Rocketeer</dc:creator>
				<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://www.angry-geek.org/?p=149</guid>
		<description><![CDATA[The worst thing about being the most technically competent person in a company is that all too often, the buck stops at my desk.  I can&#8217;t complain &#8211; it&#8217;s a problem of my own making; I&#8217;m too lazy to pass on knowledge in a usable format, so I end up having to do a lot [...]]]></description>
			<content:encoded><![CDATA[<!-- sphereit start --><p>The worst thing about being the most technically competent person in a company is that all too often, the buck stops at my desk.  I can&#8217;t complain &#8211; it&#8217;s a problem of my own making; I&#8217;m too lazy to pass on knowledge in a usable format, so I end up having to do a lot of the work.</p>
<p><span id="more-149"></span>One of my regular tasks is sorting out the database on our Support server.  This is a bit of a nightmare, since the users of that server are all &#8211; at least in their own minds &#8211; admin types, so configurations and usage changes on a daily basis.</p>
<p>Today &#8211; we ran out of space.  This isn&#8217;t as bad as it sounds, since I&#8217;ve put a restriction in place to limit any database file to 8GB (this is a limit enforced by my rather lame backup practices).  I knew the problem &#8211; one of our support databases was on the &#8220;USERS&#8221; tablespace, instead of the appropriate customer-specific tablespace.</p>
<p>Thanks to the guys at <a href="http://zhefeng.wordpress.com/2008/12/05/moving-tableindex-to-a-new-segment-or-tablespace/" target="_blank">DBA Sensation</a>, finding the correct commands to move Tables, Indexes and even LOB Segments to a new tablespace was trivial&#8230; But here&#8217;s a very useful script that generates a full set of commands to move all of a given user&#8217;s data from one tablespace to another&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> CASE
     WHEN segment_type <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'TABLE'</span> THEN
          <span style="color: #ff0000;">'ALTER TABLE '</span><span style="color: #66cc66;">||</span>seg<span style="color: #66cc66;">.</span>owner<span style="color: #66cc66;">||</span><span style="color: #ff0000;">'.'</span><span style="color: #66cc66;">||</span>seg<span style="color: #66cc66;">.</span>segment_name <span style="color: #66cc66;">||</span><span style="color: #ff0000;">' MOVE TABLESPACE '</span><span style="color: #66cc66;">||</span><span style="color: #ff0000;">'&amp;TARGET_TBSP'</span><span style="color: #66cc66;">||</span><span style="color: #ff0000;">';'</span>
     WHEN segment_type <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'INDEX'</span> THEN
          <span style="color: #ff0000;">'ALTER INDEX '</span><span style="color: #66cc66;">||</span>seg<span style="color: #66cc66;">.</span>owner<span style="color: #66cc66;">||</span><span style="color: #ff0000;">'.'</span><span style="color: #66cc66;">||</span>seg<span style="color: #66cc66;">.</span>segment_name <span style="color: #66cc66;">||</span><span style="color: #ff0000;">' REBUILD TABLESPACE '</span><span style="color: #66cc66;">||</span><span style="color: #ff0000;">'&amp;TARGET_TBSP'</span><span style="color: #66cc66;">||</span><span style="color: #ff0000;">';'</span>
     WHEN segment_type <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'LOBINDEX'</span> THEN
          <span style="color: #ff0000;">'ALTER TABLE '</span><span style="color: #66cc66;">||</span>seg<span style="color: #66cc66;">.</span>owner<span style="color: #66cc66;">||</span><span style="color: #ff0000;">'.'</span><span style="color: #66cc66;">||</span>lob<span style="color: #66cc66;">.</span>table_name <span style="color: #66cc66;">||</span><span style="color: #ff0000;">' MOVE LOB('</span><span style="color: #66cc66;">||</span>lob<span style="color: #66cc66;">.</span>column_name<span style="color: #66cc66;">||</span><span style="color: #ff0000;">') '</span> <span style="color: #66cc66;">||</span><span style="color: #ff0000;">'STORE AS (TABLESPACE '</span><span style="color: #66cc66;">||</span><span style="color: #ff0000;">'&amp;TARGET_TBSP'</span><span style="color: #66cc66;">||</span><span style="color: #ff0000;">');'</span>
     ELSE <span style="color: #ff0000;">'/* Segment '</span><span style="color: #66cc66;">||</span>seg<span style="color: #66cc66;">.</span>segment_name <span style="color: #66cc66;">||</span><span style="color: #ff0000;">' is of type: '</span><span style="color: #66cc66;">||</span>segment_type<span style="color: #66cc66;">||</span><span style="color: #ff0000;">' */'</span>
     END <span style="color: #993333; font-weight: bold;">AS</span> sql_command
<span style="color: #993333; font-weight: bold;">FROM</span> dba_segments seg<span style="color: #66cc66;">,</span> dba_lobs lob
<span style="color: #993333; font-weight: bold;">WHERE</span> seg<span style="color: #66cc66;">.</span>owner <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'&amp;SOURCE_OWNER'</span>
     <span style="color: #993333; font-weight: bold;">AND</span> seg<span style="color: #66cc66;">.</span>tablespace_name <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'&amp;SOURCE_TBSP'</span>
     <span style="color: #993333; font-weight: bold;">AND</span> seg<span style="color: #66cc66;">.</span>owner <span style="color: #66cc66;">=</span> lob<span style="color: #66cc66;">.</span>owner<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">+</span><span style="color: #66cc66;">&#41;</span>
     <span style="color: #993333; font-weight: bold;">AND</span> seg<span style="color: #66cc66;">.</span>segment_name <span style="color: #66cc66;">=</span> lob<span style="color: #66cc66;">.</span>index_name <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">+</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span> seg<span style="color: #66cc66;">.</span>owner<span style="color: #66cc66;">,</span> seg<span style="color: #66cc66;">.</span>segment_name<span style="color: #66cc66;">,</span> 
     seg<span style="color: #66cc66;">.</span>segment_type<span style="color: #66cc66;">,</span> seg<span style="color: #66cc66;">.</span>tablespace_name<span style="color: #66cc66;">,</span> 
     lob<span style="color: #66cc66;">.</span>table_name<span style="color: #66cc66;">,</span> lob<span style="color: #66cc66;">.</span>column_name
<span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> seg<span style="color: #66cc66;">.</span>segment_type <span style="color: #993333; font-weight: bold;">DESC</span><span style="color: #66cc66;">,</span> seg<span style="color: #66cc66;">.</span>segment_name;</pre></div></div>

<p>A word of warning: This will work for all tables, indexes and LOB segments, but will not handle any tables that have a LONG datatype.  <a href="http://www.orafaq.com/forum/t/21725/0/">OraFAQ has a helpful thread about this</a> &#8211; the simple answer is that LONG datatypes don&#8217;t support the MOVE command.</p>
<!-- sphereit end --><span style="margin-bottom:40px; border-bottom:none;"><a class="iconsphere" title="Sphere: Related Content" onclick="return Sphere.Widget.search('http://www.angry-geek.org/2009/01/oracle-moving-data-to-a-new-tablespace/')" href="http://www.sphere.com/search?q=sphereit:http://www.angry-geek.org/2009/01/oracle-moving-data-to-a-new-tablespace/">Sphere: Related Content</a></span><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.angry-geek.org/2009/01/oracle-moving-data-to-a-new-tablespace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ask Tom &#8220;Boolean Datatype&#8221;</title>
		<link>http://www.angry-geek.org/2009/01/ask-tom-boolean-datatype/</link>
		<comments>http://www.angry-geek.org/2009/01/ask-tom-boolean-datatype/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 20:00:46 +0000</pubDate>
		<dc:creator>Rocketeer</dc:creator>
				<category><![CDATA[Oracle Database]]></category>
		<category><![CDATA[Rant & Rage]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Rant]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.angry-geek.org/?p=7</guid>
		<description><![CDATA[Once upon a time, I got Tom Kyte to change his mind... everyone seems to want that fame!]]></description>
			<content:encoded><![CDATA[<!-- sphereit start --><p>Tom Kyte is a world renowned Oracle expert &#8211; just look through his &#8220;Ask Tom&#8221; site for confirmation (half the questions seem to come from India). Despite his fame, I once changed his mind on an interesting topic &#8211; the best substitute for a Boolean data-type in Oracle -<a href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6263249199595#876972400346931526">Ask Tom &#8220;Boolean Datatype&#8221;</a>.  Okay, so it was a moment of crowning glory for me &#8211; but hey, I&#8217;m a geek &#8211; recognition from a famous geek (even fleeting) is worth a lot to me!</p>
<p><span id="more-7"></span>
<p>This particular page though brings to mind a huge rant &#8211; pointless questions, and trolls.</p>
<p>If you read through the linked page from the top, there&#8217;s a recurring theme of &#8220;Why doesn&#8217;t Oracle have this feature &#8211; it should, because I want it!&#8221;  Reading between the lines, I&#8217;m sure that all the people asking this question know full well two facts:</p>
<ol>
<li>Tom can&#8217;t add the feature to Oracle</li>
<li>There&#8217;s 101 different work-arounds available, that all offer the functionality that is require</li>
</ol>
<p>So, the truth is, these people just want to have the satisfaction of trying to get the famous Tom Kyte to admit that Oracle isn&#8217;t perfect.  Which is true &#8211; but Tom will never admit it.</p>
<p>Now, this isn&#8217;t just about the &#8220;Ask Tom&#8221; website.  The truth of the matter is that this is a hugely prevalent attitude of &#8220;This is how it should be&#8221; and &#8220;This is how it used to be&#8221; that&#8217;s based on no evidence that the other way is by any measure better &#8211; except, of course, the fact that that&#8217;s the way it used to be.</p>
<p>A personal example, first&#8230; Back at the beginning of the year, the marketing department decided that our slightly ramshackle office wasn&#8217;t &#8220;pretty&#8221; enough for display to customers, and reorganised.  For at least two weeks, I hated the new layout &#8211; saw all kinds of problems &#8211; until I got used to it enough that I didn&#8217;t care that it was all different, at which point I realised that it was far better, and I did quite like it.</p>
<p>It&#8217;s the same with a lot of people, I think.  We all have a tendency to reject change out of hand &#8211; at least at first &#8211; just because it is different.  Whether it&#8217;s the &#8220;New Recipe&#8221; cola, or being forced to change to a new school, or a new version of Microsoft Office &#8211; we all hate being forced to change.</p>
<p>The most entertaining thing about it all is the fact that changes we control &#8211; new cars, new houses, all kinds of new toys &#8211; always get an extra shiny veneer while they&#8217;re still new.  We love new things that we&#8217;ve chosen to have &#8211; even if it turns out they&#8217;re not actually better than the old one.</p>
<p>There&#8217;s probably a moral about that&#8230; but I can&#8217;t quite figure it out right now!</p>
<!-- sphereit end --><span style="margin-bottom:40px; border-bottom:none;"><a class="iconsphere" title="Sphere: Related Content" onclick="return Sphere.Widget.search('http://www.angry-geek.org/2009/01/ask-tom-boolean-datatype/')" href="http://www.sphere.com/search?q=sphereit:http://www.angry-geek.org/2009/01/ask-tom-boolean-datatype/">Sphere: Related Content</a></span><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.angry-geek.org/2009/01/ask-tom-boolean-datatype/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
