查詢Oracle數據庫中帶有lob字段的某一個表的大小
注意:由於lob字段有獨立的lob segment來存儲,故對於帶有lob字段的表,不能僅僅查詢dba_segments.
以下腳本來自:
How to Compute the Size of a Table containing Outline CLOBs and BLOBs[Article ID 118531.1]
經過修改:改為了NVL(SUM(S.BYTES),0)
SQL> col "TOTAL TABLE SIZE" format 99999999999999
---注意:以下sql可以直接執行。為了方便復制該腳本,因此不貼SQL語句的log,而是放上了執行時的SQL語句。
SELECT
(SELECT NVL(SUM(S.BYTES),0) -- The Table Segment size
FROM DBA_SEGMENTS S
WHERE S.OWNER = UPPER('LC0019999') AND
(S.SEGMENT_NAME = UPPER('ZWPZK'))) +
(SELECT NVL(SUM(S.BYTES),0) -- The Lob Segment Size
FROM DBA_SEGMENTS S, DBA_LOBS L
WHERE S.OWNER = UPPER('LC0019999') AND
(L.SEGMENT_NAME = S.SEGMENT_NAME AND L.TABLE_NAME = UPPER('ZWPZK') AND L.OWNER = UPPER('LC0019999'))) +
(SELECT NVL(SUM(S.BYTES),0) -- The Lob Index size
FROM DBA_SEGMENTS S, DBA_INDEXES I
WHERE S.OWNER = UPPER('LC0019999') AND
(I.INDEX_NAME = S.SEGMENT_NAME AND I.TABLE_NAME = UPPER('ZWPZK') AND INDEX_TYPE = 'LOB' AND I.OWNER = UPPER('LC0019999')))
"TOTAL TABLE SIZE"
FROM DUAL;
TOTAL TABLE SIZE
----------------
3571869286
SQL> select 3571869286/1024/1024/1024 from dual;
3571869286/1024/1024/1024
--------------------------
3.3265625