oracle查詢用戶下表總數、表字段總數、表記錄總數

--查詢用戶下的表數量
SELECT COUNT(1) FROM USER_TABLES;

--查詢用戶下的表的字段數量
SELECT COUNT(1)
  FROM USER_COL_COMMENTS C
 WHERE EXISTS
 (SELECT 1 FROM USER_TABLES T WHERE T.TABLE_NAME = C.TABLE_NAME);
 
--查詢表記錄數量
SELECT T.TABLE_NAME, T.NUM_ROWS, T.BLOCKS, T.EMPTY_BLOCKS
  FROM USER_TABLES T;

--查詢表備註
SELECT TABLE_NAME, TABLE_TYPE, COMMENTS
  FROM USER_TAB_COMMENTS
 WHERE COMMENTS LIKE '%字典%'


----查詢表所佔空間
analyze table T_DATA compute statistics;

SELECT NUM_ROWS , AVG_ROW_LEN
  FROM USER_TABLES
 WHERE TABLE_NAME = 'T_DATA';

SELECT SEGMENT_NAME, SUM(BYTES) / 1024 / 1024
  FROM USER_EXTENTS
 GROUP BY SEGMENT_NAME;
相關文章
相關標籤/搜索