Home > Database > Mysql Tutorial > body text

SQL Server 计算表记录数、当前自增值和占用空间

WBOY
Release: 2016-06-07 14:56:38
Original
1517 people have browsed it

SQL Server 计算表记录数、当前自增值和占用空间 无 SELECTTableName = obj.name,TotalRows = prt.rows,Identity_Current=IDENT_CURRENT(obj.name),[SpaceUsed(KB)] = SUM(alloc.used_pages)*8FROM sys.objects objJOIN sys.indexes idx on obj.object_id = i

SQL Server 计算表记录数、当前自增值和占用空间
SELECT
TableName = obj.name,
TotalRows = prt.rows,Identity_Current=IDENT_CURRENT(obj.name),
[SpaceUsed(KB)] = SUM(alloc.used_pages)*8
FROM sys.objects obj
JOIN sys.indexes idx on obj.object_id = idx.object_id
JOIN sys.partitions prt on obj.object_id = prt.object_id
JOIN sys.allocation_units alloc on alloc.container_id = prt.partition_id
WHERE
obj.type = 'U' AND idx.index_id IN (0, 1)
GROUP BY obj.name, prt.rows
ORDER BY TableName
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template