{"id":3168,"date":"2019-03-23T23:52:17","date_gmt":"2019-03-23T20:52:17","guid":{"rendered":"https:\/\/sysdba.org\/?p=3168"},"modified":"2019-03-23T23:52:17","modified_gmt":"2019-03-23T20:52:17","slug":"undo-tablespace-resize-recreate-drop","status":"publish","type":"post","link":"https:\/\/sysdba.org\/en\/undo-tablespace-resize-recreate-drop\/","title":{"rendered":"Undo TableSpace Resize (Recreate &#038; Drop)"},"content":{"rendered":"<p>The resize command can be used to shrink the Undo TableSpace, however most of the time it isn&#8217;t that useful.<br \/>\n[crayon]ALTER DATABASE DATAFILE &#8216;\/u01\/app\/oracle\/oradata\/smp\/UNDOTBS02.dbf&#8217; RESIZE 200;<\/p>\n<p>[\/crayon]<br \/>\nAn alternative to the resize command is to create an undo tablespace of the required size and delete the old tablespace.<\/p>\n<p>Undo TableSpace information.<br \/>\n[crayon]SELECT name,value FROM v$parameter WHERE name IN (&#8216;undo_management&#8217;,&#8217;undo_tablespace&#8217;);<\/p>\n<p>[\/crayon]<br \/>\n<strong>1.<\/strong> Create a new UNDO tablespace<br \/>\n[crayon]CREATE UNDO TABLESPACE UNDOTBS2<\/p>\n<p>DATAFILE &#8216;\/u01\/app\/oracle\/oradata\/smp\/UNDOTBS02.dbf&#8217; SIZE 100M;<\/p>\n<p>alternatively<\/p>\n<p>CREATE UNDO TABLESPACE UNDOTBS2 DATAFILE<\/p>\n<p>&#8216;\/oradata\/undotbs02.dbf&#8217;<\/p>\n<p>SIZE 2G<\/p>\n<p>AUTOEXTEND ON<\/p>\n<p>NEXT 200M<\/p>\n<p>MAXSIZE 3G[\/crayon]<br \/>\n<strong>2.<\/strong> Modify the database parameter to use the new UNDO tablespace<br \/>\n[crayon]ALTER SYSTEM SET undo_tablespace=UNDOTBS2 SCOPE=BOTH;<\/p>\n<p>[\/crayon]<br \/>\n<strong>3.<\/strong> Drop the previous tablespace<br \/>\n[crayon]drop tablespace undotbs1 including contents and datafiles;<\/p>\n<p>[\/crayon]<br \/>\n[crayon]host ls -l \/u01\/app\/oracle\/oradata\/smp\/<\/p>\n<p>[\/crayon]<br \/>\nThe resulting alert.log entry: &#8220;Undo Tablespace X moved to Pending Switch-Out state&#8221;<\/p>\n<p>A query to retrieve: Rollback Segment Number, Rollback Segment Name, Rollback Segment Status, Undo TableSpace Name, Transaction State Object Address, Session Identifier, Session Serial Number, Username to Run the Transaction, Program, Machine ID and the Operating System details.<br \/>\n[crayon]SELECT<\/p>\n<p>a.usn,<\/p>\n<p>a.name,<\/p>\n<p>b.status,<\/p>\n<p>c.tablespace_name,<\/p>\n<p>d.addr,<\/p>\n<p>e.sid,<\/p>\n<p>e.serial#,<\/p>\n<p>e.username,<\/p>\n<p>e.program,<\/p>\n<p>e.machine,<\/p>\n<p>e.osuser<\/p>\n<p>FROM<\/p>\n<p>v$rollname a,<\/p>\n<p>v$rollstat b,<\/p>\n<p>dba_rollback_segs c,<\/p>\n<p>v$transaction d,<\/p>\n<p>v$session e<\/p>\n<p>WHERE<\/p>\n<p>a.usn=b.usn AND<\/p>\n<p>a.name=c.segment_name AND<\/p>\n<p>a.usn=d.xidusn AND<\/p>\n<p>d.addr=e.taddr AND<\/p>\n<p>b.status=&#8217;PENDING OFFLINE&#8217;;<\/p>\n<p>Ex:<\/p>\n<p>USN NAME STATUS TABLESPACE_NAME ADDR SID SERIAL# USERNAME PROGRAM<\/p>\n<p>&#8212; &#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8211; &#8212;- &#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8211;<\/p>\n<p>5 _SYSSMU5$ PENDING OFFLINE UNDOTBS1 1477F404 9 2976 SYS sqlplus.exe<\/p>\n<p>MACHINE OS_USER<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>IDC-ORACLEbsriniva-pc bsriniva-pcbsriniva[\/crayon]<br \/>\n[crayon]Alter system kill session \u2018sid numarasi,serial# numarasi\u2019;<\/p>\n<p>[\/crayon]<br \/>\nRollback segments<br \/>\n[crayon]select segment_name<\/p>\n<p>, status<\/p>\n<p>from dba_rollback_segs<\/p>\n<p>[\/crayon]<br \/>\n[crayon]alter system set undo_retention=500 scope=memory;<\/p>\n<p>[\/crayon]<br \/>\n[crayon]select tablespace_name<\/p>\n<p>, status<\/p>\n<p>, count(*) as HOW_MANY<\/p>\n<p>from dba_undo_extents<\/p>\n<p>group by tablespace_name<\/p>\n<p>, status[\/crayon]<br \/>\n[crayon]set lines 100 pages 999<\/p>\n<p>col username format a15<\/p>\n<p>col command format a20<\/p>\n<p>select ses.username &#8212; Session username<\/p>\n<p>, substr(ses.program, 1, 19) command<\/p>\n<p>, tra.used_ublk<\/p>\n<p>from v$session ses<\/p>\n<p>, v$transaction tra<\/p>\n<p>where ses.saddr = tra.ses_addr[\/crayon]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Undo TableSpace Resize (Recreate &#038; Drop)<\/p>\n","protected":false},"author":1,"featured_media":3701,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[350],"tags":[345],"class_list":["post-3168","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-miscellaneous-en","tag-oracle"],"_links":{"self":[{"href":"https:\/\/sysdba.org\/en\/wp-json\/wp\/v2\/posts\/3168","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sysdba.org\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sysdba.org\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sysdba.org\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sysdba.org\/en\/wp-json\/wp\/v2\/comments?post=3168"}],"version-history":[{"count":0,"href":"https:\/\/sysdba.org\/en\/wp-json\/wp\/v2\/posts\/3168\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sysdba.org\/en\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/sysdba.org\/en\/wp-json\/wp\/v2\/media?parent=3168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sysdba.org\/en\/wp-json\/wp\/v2\/categories?post=3168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sysdba.org\/en\/wp-json\/wp\/v2\/tags?post=3168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}