3초기억력

MS-SQL 테이블별 용량 조회 쿼리문 본문

쿼리_MSSQL

MS-SQL 테이블별 용량 조회 쿼리문

잠수콩 2014. 6. 25. 10:27



제목 : 



--테이블별 용량

SELECT table_name = convert(varchar(30), min(o.name))

 , table_size = ltrim(str(sum(cast(reserved as bigint)) * 8192 / 1024.,15,0) )

FROM sysindexes i

  INNER JOIN 

  sysobjects o 

  ON (o.id = i.id)

WHERE i.indid IN (0, 1, 255) 

AND  o.xtype = 'U'

GROUP BY i.id


--테이블 용량 SORT : DESC

SELECT table_name = convert(varchar(30), min(o.name))

 , table_size = convert(int, ltrim(str(sum(cast(reserved as bigint)) * 8192 / 1024., 15, 0))), UNIT = 'KB' 

FROM sysindexes i 

  INNER JOIN 

  sysobjects o

  ON (o.id = i.id) 

WHERE i.indid IN (0, 1, 255)

AND  o.xtype = 'U' 

GROUP BY i.id

ORDER BY table_size DESC 


--테이블별 ROWS 카운트

SELECT o.name

 , i.rows 

FROM sysindexes i

  INNER JOIN 

  sysobjects o 

  ON i.id = o.id

WHERE i.indid < 2 

AND  o.xtype = 'U'

ORDER BY i.rows  DESC



내용 :




 출처 :  


Comments