How to Shrink the Datafile of Temporary Tablespace (Doc ID 273276.1)

Last updated on DECEMBER 06, 2016

Applies to:

Oracle Database - Enterprise Edition - Version 8.1.7.4 to 11.2.0.2 [Release 8.1.7 to 11.2]
Information in this document applies to any platform.
***Checked for relevance on 26-Oct-2016***


Goal

The database has a program which performs a huge sort operation (e.g. end of the year reporting process).  This may cause the TEMP tablespace to grow and occupy most of the space on the file system.

In this example, the report process may run once or twice a year and there is no need to maintain/keep a huge tempfile.

The TEMP tablespace was created with datafiles (dictionary managed tablespace temporary) as AUTOEXTEND ON MAXSIZE UNLIMITED to avoid the Error:
  ORA-1652 Text: unable to extend temp segment by %s in tablespace %s.

Attempts have been made to "alter database datafile .. resize" which fail with:  

Error: ORA 3297 : file contains <> blocks of data beyond requested RESIZE value

You want to shrink the datafile to utilize the disk space for other tablespaces or other purposes.


Solution

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms