[In a previous question @Morawski说的是“具有1,000列和44,000行]的表”,它约为330 MB;这是浏览器仅用于几个打开的选项卡的量”。
表应该告诉表的大小为多少列和行是> 10 GB
(假设表只有双精度值)。@ Morawski是如何得出结论的[[1,000列和44,000是330MB
?是否有任何脚本可以在SQL中说明这一点?[在上一个问题中,@ Morawski曾说过:“一个包含1,000列和44,000行的表,大约330 MB;这就是浏览器仅用于几个打开的选项卡的数量”。多少列和行...
-- Measures tables size (in kilobytes)
-- Tested in MS SQL Server 2008 R2
declare @t table (
name nvarchar(100), [rows] int, [reserved] nvarchar(100), [data] nvarchar(100), [index_size] nvarchar(100), [unused] nvarchar(100)
)
declare @name nvarchar(100)
declare tt cursor for
Select name from sys.tables
open tt
fetch next from tt into @name
while @@FETCH_STATUS = 0
begin
insert into @t
exec sp_spaceused @name
fetch next from tt into @name
end
close tt
deallocate tt
select name as table_name, [rows] as rows_count, data + [index] as total_size, data as data_size, [index] as index_size
from (select name,
[rows],
cast (LEFT(data, LEN(data)-3) as int) data,
cast (LEFT(index_size, LEN(index_size)-3) as int) [index]
from @t
) x
order by 3 desc, 1