一危壱 | 觜-ろる危 | ろる危 | NULL覦焔 |
bit | 0.125 | 4.125 | 98% |
tinyint | 1 | 5 | 86% |
smallint | 2 | 6 | 76% |
int | 4 | 8 | 64% |
bigint | 8 | 12 | 52% |
real | 4 | 8 | 64% |
float | 8 | 12 | 52% |
smallmoney | 4 | 8 | 64% |
money | 8 | 12 | 52% |
smalldatetime | 4 | 8 | 64% |
datetime | 8 | 12 | 52% |
uniqueidentifier | 16 | 20 | 43% |
date | 3 | 7 | 69% |
一危 | 觜-ろ 覦危 | ろ 覦危 | NULL 覦焔 |
datetime2(0) | 6 | 10 | 57% |
datetime2(7) | 8 | 12 | 52% |
time(0) | 3 | 7 | 69% |
time(7) | 5 | 9 | 60% |
datetimetoffset(0) | 8 | 12 | 52% |
datetimetoffset (7) | 10 | 14 | 49% |
decimal/numeric(1,s) | 5 | 9 | 60% |
decimal/numeric(38,s) | 17 | 21 | 42% |
vardecimal(p,s) | decimal 朱 豺襦 |
一危壱 | 觜-ろる危 | ろる危 | NULL覦焔 |
sql_variant | 蠍磯蓋一危壱磯朱る | ||
varcharchar | 4+蠏一危 | 2+蠏一危 | 60% |
nvarcharnchar | 4+蠏一危 | 2+蠏一危 | 60% |
varbinarybinary | 4+蠏一危 | 2+蠏一危 | 60% |
xml | 4+蠏一危 | 2+蠏一危 | 60% |
hierarchyId | 4+蠏一危 | 2+蠏一危 | 60% |
--drop table sparse_table create table sparse_table ( sparse_col nchar(4) sparse null ); --drop table non_sparse_table create table non_sparse_table ( non_sparse_col nchar(4) null ); with temp(num) as ( select 1 num union all select num + 1 from temp where num + 1 <= 10 ) insert sparse_table(sparse_col) select N'覘°蟾?' -- 100000蟇 from temp a, temp b, temp c, temp d, temp e union all select NULL -- 100000蟇 from temp a, temp b, temp c, temp d, temp e; with temp(num) as ( select 1 num union all select num + 1 from temp where num + 1 <= 10 ) insert non_sparse_table(non_sparse_col) select N'覘°蟾?' -- 100000蟇 from temp a, temp b, temp c, temp d, temp e union all select NULL -- 100000蟇 from temp a, temp b, temp c, temp d, temp e; exec sp_spaceused 'sparse_table' exec sp_spaceused 'non_sparse_table' /* name rows reserved data index_size unused ------------ ------ -------- ------- ---------- ------ sparse_table 200000 3720 KB 3664 KB 8 KB 48KB name rows reserved data index_size unused ------------ ------ -------- ------- ---------- ------ sparse_table 200000 3400 KB 3368 KB 8 KB 48KB */
--drop table column_sets create table column_sets ( sparse1 int primary key , sparse2 int sparse null , sparse3 nvarchar(20) sparse null , cs xml column_set FOR ALL_SPARSE_COLUMNS ); insert column_sets(sparse1, sparse2, sparse3) values (1, 1, N'願唄覘?') , (2, null, N'覘螳襷?'); select * from column_sets; select sparse1, sparse2, sparse3, cs from column_sets
CREATE TABLE t ( i int SPARSE , cs xml column_set FOR ALL_SPARSE_COLUMNS ); INSERT t(cs) VALUES ('<i/>'); SELECT i FROM t; SELECT * FROM t;