How to Shrink the Datafile of Temporary Tablespace
2013-01-31 21:14
591 查看
In this Document
Goal
Solution
Information in this document applies to any platform.
***Checked for relevance on 16-Dec-2011***
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:
You want to shrink the datafile to utilize the disk space for other tablespaces or other purposes.
2) If the original tablespace is a default temporary tablespace, set the new tablespace as default temporary tablespace for all users in the database:
3) If necessary, explicitly re-assign specific users to the new tablespace:
4) Drop the old tablespace:
Note:
In Oracle 9i and higher, the drop command can 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.
Goal
Solution
Applies to:
Oracle Server - Enterprise Edition - Version: 8.1.7.4 to 11.2.0.2 - Release: 8.1.7 to 11.2Information in this document applies to any platform.
***Checked for relevance on 16-Dec-2011***
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
1) Create a 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 <username> temporary tablespace TEMP1;
4) Drop the old tablespace:
SQL> drop tablespace temp including contents;
Note:
In Oracle 9i and higher, the drop command can also drop datafiles at OS level:
SQL> drop tablespace temp INCLUDING CONTENTS AND DATAFILES;
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.
相关文章推荐
- How-to find the SQL that using lots of temp tablespace in Oracle
- What if a data file of the Non-System tablespace is missing?
- How to get the Diagnostic data and debug file of Sales Order pick release
- Unable to Drop a Datafile From the Tablespace Using Alter Tablespace Command (Doc ID 1050261.1)
- How to Get the Frequency Table of a Categorical Variable as a Data Frame in R
- Linux - How to remove the new line at the end of file when using vim
- 144.You execute the following command to change the status of the SALES tablespace: SQL> ALTER TABLE
- 14.5.5 Creating a File-Per-Table Tablespace Outside the Data Directory
- 转:How to submit the rows of a repeating table in InfoPath to a SharePoint list
- How to choose the SIZE and HASHKEYS of hash cluster table?
- Oracle table fragmentation how to calculate or get the actual used blocks of the table
- How to fix the dreaded "java.lang.OutOfMemoryError: PermGen space" exception (classloader leaks)
- 14.5.5 Creating a File-Per-Table Tablespace Outside the Data Directory
- HOW TO: Change the Owner of a User-Defined Data Type That Is in Use in SQL Server 2000
- How to avoid adding repeat submit the same data if you click the 'Refresh' button of Browser?
- How To Reclaim Wasted Space on The Segment (Table, Index and LOB) and Tablespace Levels (文档 ID 16827
- How to redirect the output of DBMS_OUTPUT.PUT_LINE to a file
- How to get the field descriptions of a table
- How to delete the log file of log4j dynamically
- How can I set the background of UITableView (the tableview style is "Grouped") to use an image?