臨時表空間爆滿的處理辦法

2021-06-19 23:44:45 字數 1705 閱讀 3893

1這個是檢視當前占用臨時表空間的sql

select se.username,

se.sid,

su.extents,

su.blocks * to_number(rtrim(p.value)) as space,

tablespace,

segtype,

sql_text

from v$sort_usage su, v$parameter p, v$session se, v$sql s

where p.name = 'db_block_size'

and su.session_addr = se.saddr

and s.hash_value = su.sqlhash

and s.address = su.sqladdr

order by se.username, se.sid;

千萬注意,這個在rac環境下,db1和db2看到的東西是不一樣的,包括v$sort_segment和v$sort_usage

2.切換臨時表空間,沒有就建乙個新的

create temporary tablespace temp2 tempfile '+vgdata/boss/tempfile/temp2.dbf' size 32000m;

alter database default temporary tablespace temp2;

select * from database_properties where property_name='default_temp_tablespace';  --看看是不是這個

3再看所有程式切過去沒有,切了就把原來的臨時表空間drop掉

刪除表空間temp,但不刪除其檔案   用:drop tablespace temp;

刪除表空間temp同時刪除表空間的資料物件 用drop tablespace temp including contents;

刪除表空間temp及其包含資料物件以及資料檔案 用drop tablespace temp including contents and datafiles;

由於9i之後臨時表空間用指標,用這個才可以真正看到temp表空間的使用率,看v$sort_segment也可以

select a.tablespace_name, a.alloc_kb - nvl(b.used_kb, 0), round(nvl(b.used_kb / a.alloc_kb, 0) * 100, 2) 

from (select tablespace_name, sum(bytes) / 1024 alloc_kb

from dba_temp_files

group by tablespace_name) a,

(select tablespace, sum(blocks) * 8 used_kb

from v$sort_usage

group by tablespace) b

where a.tablespace_name = b.tablespace(+);

由於以上語句預設block大小為8k,僅當show parameter db_block_size為8192的時候正確。

select tablespace_name,total_extents,total_blocks,free_extents,free_blocks from v$sort_segment; 

這個看到空閒的塊

臨時表空間爆滿問題

參考 檢視臨時表空間 select temp used.tablespace name,total used as free total as total round nvl total used,0 100 total,3 free percent from select tablespace n...

TEMP表空間爆滿處理一例

fri jul 15 06 03 03 2011 ora 1652 unable to extend temp segment by 128 in tablespace temp fri jul 15 08 02 59 2011 ora 1652 unable to extend temp segm...

TEMP表空間爆滿處理一例

今早巡檢資料庫發現如下報錯 fri jul 15 06 03 03 2011 ora 1652 unable to extend temp segment by 128 in tablespace temp fri jul 15 08 02 59 2011 ora 1652 unable to ex...