oracle臨時表空間

--查看臨時表文件大小和已使用空間
select t1."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
(
select tablespace_name "Tablespace", to_char((sum(bytes/1024/1024/1024)),'99,999,990.900') "Total (G)" 
from dba_temp_files
group by tablespace_name
union
select tablespace_name "Tablespace", to_char((sum(bytes/1024/1024/1024)),'99,999,990.900') "Total (G)"
from dba_data_files
where tablespace_name like'TEMP%'
group by tablespace_name
) t1,
(
select tablespace, round(sum(blocks)*8/1024) "Used (G)" from v$sort_usage
group by tablespace
) t2
where t1."Tablespace"=t2.tablespace(+)


--查看當前臨時表使用空間大小與正在佔用臨時表空間的sql語句
select sess.SID, segtype, blocks*8/1000 "MB" ,sql_text
from v$sort_usage sort, v$session sess,v$sql sql
where sort.SESSION_ADDR = sess.SADDR
and sql.ADDRESS = sess.SQL_ADDRESS
order by blocks 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 (select d.tablespace_name tablespace_name,
               nvl(sum(used_blocks), 0) tot_used_blocks,
               sum(blocks) total_blocks
          from v$sort_segment v, dba_temp_files d
         where d.tablespace_name = v.tablespace_name(+)
         group by d.tablespace_name) s,
       v$database;
--查看臨時表物理位置
SELECT * from dba_temp_files;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章