2

we use a oracle db (11g release2) and the undo tablespase exists of two datafiles and requires 48 GB. But we just need this size for the boot and the import. Currently we just use 10 % from the datafiles...

Is it possible to minimize the datafiles online to the needed size ??

migrated from stackoverflow.com Jan 7 '14 at 21:07

This question came from our site for professional and enthusiast programmers.

4

-- create a new UNDO tablespace named UNDOTBS2

CREATE UNDO TABLESPACE undotbs2
DATAFILE '/01/oradata/dbname/undotbs201.dbf'
SIZE 50M AUTOEXTEND ON NEXT 5M;

Tablespace created.

-- Switch the database to the new UNDO tablespace.

ALTER SYSTEM SET UNDO_TABLESPACE=UNDOTBS2 SCOPE=BOTH;

-- Drop the old one

DROP TABLESPACE undotbs1 INCLUDING CONTENTS AND DATAFILES;

-- If Undo is still in use

*
ERROR at line 1:
ORA-30013: undo tablespace 'UNDOTBS1' is currently in use

I would try this out first on a test database:

(Following from dead link) from original answer:

SELECT a.name,b.status 
FROM   v$rollname a,v$rollstat b
WHERE  a.usn = b.usn
AND    a.name IN ( 
          SELECT segment_name
          FROM dba_segments 
          WHERE tablespace_name = 'UNDOTBS1'
         );

The above query shows the name of the UNDO segment in the UNDOTBS1 tablespace and its status. See which users/sessions are running this pending transaction:

SELECT a.name,b.status , d.username , d.sid , d.serial#
FROM   v$rollname a,v$rollstat b, v$transaction c , v$session d
WHERE  a.usn = b.usn
AND    a.usn = c.xidusn
AND    c.ses_addr = d.saddr
AND    a.name IN ( 
          SELECT segment_name
          FROM dba_segments 
          WHERE tablespace_name = 'UNDOTBS1'
         );

You can then kill the session; the following assumes a SID of 147 and a SERIAL# of 4:

alter system kill session '147,4' immediate;
0

To supplement Robert's answer, if after you create a new UNDO tablespace, and are unable to drop the old one, after trying those queries with no results, and the undo_retention period has elapsed, you can try this: (It worked for me when querying dba_undo_extents showed unexpired status for some rows):

SYS@ecs01> alter tablespace undotbs1 offline;

Tablespace altered.
SYS@ecs01> DROP TABLESPACE undotbs1 INCLUDING CONTENTS AND DATAFILES;

Tablespace dropped.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy