【发布时间】:2013-01-21 01:48:34
【问题描述】:
我在共享主机上有一个 MS SQL Server 2008 数据库,我需要尽可能减少使用的存储空间。我最大的表有以下定义:
CREATE TABLE [stage](
[station_id] [smallint] NOT NULL,
[time_utc] [smalldatetime] NOT NULL,
[stage_mm] [smallint] NOT NULL,
CONSTRAINT [PK_stage] PRIMARY KEY CLUSTERED ([station_id] ASC,[time_utc] ASC)
我试图找出表中每条记录的平均字节数。 根据理论大小应该是:4B(行标题)+ 2B(smallint)+ 4B(smalldatetime)+ 2B(smallint),即12字节。
但是,当我运行命令时:
dbcc showcontig ('stage') with tableresults
它显示:MinimumRecordSize=15,MaximumRecordSize=15 所以根据 SQL Server,每条记录的字节数是 15 而不是 12 当我查看表占用的总磁盘空间并将其除以行数时,每条记录 15 字节的数字似乎也是正确的。
什么占用了额外的 3 个字节???
【问题讨论】:
标签: sql-server database sql-server-2008 sqldatatypes