假如我们使用的临时表空间是temoprary的,就会在v$sort_segment中显示,假如临时表空是permanent的话,就不会在这个表中进行显示了.
Code: [Copy to clipboard]
SQL> select tablespace_name,extent_size,total_extents,total_blocks from
v$sort_segment;
TABLESPACE_NAME EXTENT_SIZE TOTAL_EXTENTS TOTAL_BLOCKS
------------------------------- ----------- ------------- ------------
TEMP 128 5999 767872
视图v$sort_usage显示Oracle在如何使用和分配临时段的.
Code: [Copy to clipboard]
SQL> select username,session_addr,sqladdr,sqlhash,segtype,
2 segfile#,segblk#,extents,blocks
3 from v$sort_usage
4 /
USERNAME SESSION_ADDR SQLADDR SQLHASH
------------------------------ ---------------- ---------------- ----------
SEGTYPE SEGFILE# SEGBLK# EXTENTS BLOCKS
--------- ---------- ---------- ---------- ----------
AICBS C0000000D7EF99E8 C0000000E1BFE970 4053158416
SORT 1001 379145 231 29568
可以根据session_addr查询v$session得到当前登录用户的session信息,
可以通过sqladdr和sqlhash查询v$sqltext查询这条语句的具体信息
下面的语句可以比较好的监控正在使用的临时段的信息
Code: [Copy to clipboard]
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
/