Database/SQL Server
MSSQL - SQL Server - SSMS 데이터베이스 용량, 테이블 당 건수 확인하기, 테이블당 데이터 개수 확인
청렴결백한 만능 재주꾼
2022. 1. 26. 06:19
반응형
--먼저 건수 Database에 있는 테이블당 건수 확인하기
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
-- 테이블당 용량 확인하기
select convert(varchar(30), min(o.name)) as table_name,
ltrim(str(sum(reserved) * 8192.00 / 1024.00 / 1024.00, 15, 0) + ' MB') as table_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.00 / 1024.00 desc
반응형