1. 程式人生 > >db2使用sql語句查詢表空間使用率(直接顯示百分比)

db2使用sql語句查詢表空間使用率(直接顯示百分比)

 

----檢查表空間使用率1----
select char(TBSP_NAME,50) as TBSP_NAME, TBSP_USABLE_PAGES, TBSP_USED_PAGES, rtrim(100*TBSP_USED_PAGES/TBSP_USABLE_PAGES)||'%' as USED_RATE from sysibmadm.SNAPTBSP_PART where TBSP_USABLE_PAGES>0 order by TBSP_NAME,DBPARTITIONNUM

測試結果:


----檢查表空間使用率2----
SELECT TOTAL_PAGES, USED_PAGES, FREE_PAGES, rtrim(char(USED_PAGES*100/TOTAL_PAGES))||'%' as USED_RATE, rtrim(char(FREE_PAGES*100/TOTAL_PAGES))||'%' as Free_RATE FROM table (SNAPSHOT_TBS_CFG('sample', -1)) t

實驗結果2:



---檢查使用率3---
SELECT substr(tbsp_name,1,20) as TABLESPACE_NAME, substr(tbsp_content_type,1,10) as TABLESPACE_TYPE, sum(tbsp_total_size_kb)/1024 as TOTAL_MB, sum(tbsp_used_size_kb)/1024 as USED_MB, sum(tbsp_free_size_kb)/1024 as FREE_MB, tbsp_page_size AS PAGE_SIZE, TBSP_UTILIZATION_PERCENT as percent FROM SYSIBMADM.TBSP_UTILIZATION GROUP BY tbsp_name, tbsp_content_type, tbsp_page_size, TBSP_UTILIZATION_PERCENT ORDER BY TBSP_UTILIZATION_PERCENT;