My Oracle Support Banner

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

Last updated on JULY 05, 2023

Applies to:

Oracle Database - Enterprise Edition - Version 8.1.7.4 and later
Oracle Database Cloud Schema Service - Version N/A and later
Gen 1 Exadata Cloud at Customer (Oracle Exadata Database Cloud Machine) - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Oracle Database Exadata Express Cloud Service - Version N/A and later
Information in this document applies to any platform.

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

To view full details, sign in with your My Oracle Support account.

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


In this Document
Goal
Solution

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.