How to Shrink the datafile of Temporary Tablespace

Applies to:

Oracle Server - Enterprise Edition - Version: to
Information in this document applies to any platform.


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 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 as AUTOEXTEND ON MAXSIZE UNLIMITED to avoid Error: ORA-1652 Text: unable to extend temp segment by %s in tablespace %s

Attempts have been made to "alter database datafile .. resize" which always fails 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.


1) Create new temporary tablespace with desired smaller  size:

SQL> create temporary tablespace TEMP1 tempfile 'c:\temp01.dbf' size 100M extent management local uniform size 128K;

2) If the original tablespace is a default temporary tablespace, set the new tablespace as default temporary tablespace for all users in the database:

SQL> alter database default temporary tablespace TEMP1;
3) If necessary, explicitly re-assign specific users to the new tablespace:
SQL> alter user temporary tablespace TEMP1;

4) Drop the old tablespace.

SQL> drop tablespace temp including contents.
Note: In Oracle 9i and on,  the drop command  will also drop datafiles at OS level:


Note:  Temporary tablespaces should appear "full" after a while in a normally running database. Extents are allocated once and then managed by the system. Rather than doing the rather expensive operation of "space management" (data dictionary updates), the system will allocate an extent in TEMP and then keep it and manage it itself.  This is normal and to be expected and is not an indication that there is a lack of  temporary space.

Reference Note: How to Shrink the datafile of Temporary Tablespace


  1. Notwithstanding, you can the degree without hiring somebody.
    Also, you need to also find the pot setup by just a professional person that you can be sure of a the best unit installation to
    forestall sincere incidents at some point. Generally toaster rival other types of gear including the
    microwave oven and your oven/stove good, nonetheless it is advantages and benefits
    greatly over-shadow which currently the cooktop or even a micro
    wave. Moreover they has various herbal antioxidants that aren't found in dietary supplement health supplements.

    Also visit my blog post :: ge profile conventional oven