Role of temporary Oracle tablespace

Source: Internet
Author: User
Oracle temporary tablespace is mainly used to query and store some buffer data. Temporary tablespace consumption is mainly caused by sorting the intermediate query results. Restarting the database can release temporary tablespace. If the instance cannot be restarted, the temp tablespace will continue to grow as the problematic SQL statement is executed. Until the hard disk space is exhausted. Someone on the Internet speculated that Oracle uses the greedy algorithm to allocate disk space. If the disk space consumption reached 1 GB last time, the temporary tablespace would be 1 GB. That is to say, the size of the temporary tablespace file is the largest in history. Temporary tablespace: Index create, rebuildorder by, or group bydistinct operation union, intersect, or minussort-merge joinsanalyze View the temporary tablespace size View the temporary table file size and used space SelectT1. "tablespace" "tablespace ",
T1. "Total (g)" "Total (g )",
Nvl (t2. "used (g)", 0) "used (g )",
T1. "Total (g)"-nvl (t2. "used (g)", 0) "free (g )"
From
(
SelectTablespace_name "tablespace", to_char (( Sum(Bytes/1024/1024/1024), '20140901') "Total (g )"
FromDba_temp_files
Group ByTablespace_name
Union
SelectTablespace_name "tablespace", to_char (( Sum(Bytes/1024/1024/1024), '20140901') "Total (g )"
FromDba_data_files
WhereTablespace_name Like'Temp %'
Group ByTablespace_name
) T1,
(
Select Tablespace, Round ( Sum(Blocks) * 8/1024) "used (g )" FromV $ sort_usage
Group By Tablespace
) T2
WhereT1. "tablespace" = T2. Tablespace(+) Check the space used by the dead table and the SQL statement that is occupying the temporary tablespace. SelectSess. Sid, segtype, blocks * 8/1000 "MB", SQL _text
FromV $ sort_usage Sort, V $ session sess, V $ SQL SQL
Where Sort. Session_addr = sess. saddr
And SQL. Address = sess. SQL _address
Order ByBlocks Desc; Select'The' | Name| 'Temp tablespaces' | tablespace_name |
'Idle' |
Round (100-(S. tot_used_blocks/S. total_blocks) * 100, 3) |
'% At' | to_char ( Sysdate, 'Yyyymmddhh24miss ')
From( SelectD. tablespace_name,
Nvl ( Sum(Used_blocks), 0) tot_used_blocks,
Sum(Blocks) total_blocks
FromV $ sort_segment V, dba_temp_files d
WhereD. tablespace_name = V. tablespace_name (+)
Group ByD. tablespace_name) s,
V $ database; Modify temporary file size Select'Alter database tempfile' | file_name | 'resize 100 m ;'
FromDba_temp_files
WhereTablespace_name = 'onlydwtemp '; Alter database tempfile'/oradata/onlydwtemp06.dbf 'resize 100 m; Alter database tempfile'/oradata/onlydwtemp07.dbf' resize 100 m; alter database tempfile '/oradata/onlydwtemp08.dbf' resize 100 m; Alter database tempfile '/oradata/comment 'resize 100 m; Alter database tempfile'/oradata/onlydwtemp10.dbf' resize 100 m; alter database tempfile '/oradata/onlydwtemp01.dbf' resize 100 m; Alter database tempfile'/oradata/comment 'resize 100 m; Alter database tempfile'/oradata/onlydwtemp03.dbf 'resize 100 m; alter database tempfile '/oradata/onlydwtemp04.dbf 'resize 100 m; Alter database tempfile'/oradata/onlydwtemp05.dbf' resize 100 m; SQL> alter database tempfile '/oradata/onlydwtemp09.dbf 'resize 100 m; Alter database tempfile'/oradata/onlydwtemp09.dbf' resize 100mora-03297: file contains used data beyond requested resize Value Create a new temporary tablespaceSQL> create temporary tablespace temp1 tempfile '/oradata/temp1_01.dbf' size 100 m; tablespace createdsql> create temporary tablespace tempfile'/oradata/temp2_01.dbf 'size 100 m; tablespace created Specify the current temporary tablespace as the new temporary tablespace.SQL> alter database default temporary tablespace temp1; database altered

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.