Tôi có một bảng như:
CREATE TABLE grid_rows(
[grid_row_id] [int] NOT NULL,
[grid_column_id] [smallint] NOT NULL,
[decimal_val] [decimal](18, 6) NULL,
[datetime_val] [datetime] NULL,
[integer_val] [int] NULL,
[string_val] [varchar](1024) NULL
)
Bảng này có một số 1,037,560 rows
exec sp_spaceused "grid_rows" gives:
rows reserved data
1,037,560 461,768KB 302,648KB`
Sau khi thay đổi độ chính xác từ (18, 6) thành (24,6), tức là
ALTER TABLE grid_rows ALTER COLUMN decimal_val decimal(24, 6)
exec sp_spaceused "grid_rows" gives:
rows reserved data
1,037,560 641,352KB 560,832KB
Các không gian được phân bổ bởi decimal(18,6)là 9 bytesvà của (24, 6)là 13 bytes. Tham chiếu MSDN
The reserved space has increased by around 179,584 KB and data space by 260,000KB. Shouldn't it be increased by 1,037,560 * 4/1024 = 4052 KB
decimal(24, 6)ngay từ đầu: đối với một bảng chứa 1024 hàng, tôi nhận được 48KB decimal(18, 6), 56KB với decimal(24, 6)và 72KB với decimal(18, 6) then alter to decimal(24, 6). Tôi không có lời giải thích cho điều này, mặc dù.
