MSSQL 테이블별 용량 size 크기 확인 쿼리
페이지 정보
본문
1. 테이블별 사용 용량
SELECT CONVERT(VARCHAR(30), MIN(o.name)) AS t_name
, LTRIM(STR(SUM(reserved) * 8192.0 / 1024.0, 15, 0)) AS t_size
, 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 t_name ASC
2. 용량별 소팅
SELECT table_name = convert(varchar(30), min(o.name))
, table_size = convert(int, ltrim(str(sum(reserved) * 8.192 / 1024., 15, 0)))
, UNIT = 'MB'
FROMsysindexes 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 2 desc
SELECT CONVERT(VARCHAR(30), MIN(o.name)) AS t_name
, LTRIM(STR(SUM(reserved) * 8192.0 / 1024.0, 15, 0) + ' KB') AS t_size
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 SUM(reserved) * 8192.0 / 1024.0 DESC
3. 테이블별 Row 수
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
참고자료
http://bookk.tistory.com/57
http://akbory.tistory.com/2
SELECT CONVERT(VARCHAR(30), MIN(o.name)) AS t_name
, LTRIM(STR(SUM(reserved) * 8192.0 / 1024.0, 15, 0)) AS t_size
, 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 t_name ASC
2. 용량별 소팅
SELECT table_name = convert(varchar(30), min(o.name))
, table_size = convert(int, ltrim(str(sum(reserved) * 8.192 / 1024., 15, 0)))
, UNIT = 'MB'
FROMsysindexes 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 2 desc
SELECT CONVERT(VARCHAR(30), MIN(o.name)) AS t_name
, LTRIM(STR(SUM(reserved) * 8192.0 / 1024.0, 15, 0) + ' KB') AS t_size
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 SUM(reserved) * 8192.0 / 1024.0 DESC
3. 테이블별 Row 수
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
참고자료
http://bookk.tistory.com/57
http://akbory.tistory.com/2
댓글목록
등록된 댓글이 없습니다.