/****** Object: Table [dbo].[NoNComPRessed Table] Script Date: 05/27/2009 02:24:23 ******/ IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[NoNCompressed Table]') AND type in (N'U')) DROP TABLE [dbo].[NoNCompressed Table] GO CREATE TABLE [NoNCompressed Table] (id int, FName varchar(100), LName varchar(100)) --增加10,000行 declare @n int set @n=0 while @n<=10000 begin insert into [NoNCompressed Table] values (1,'Adam','Smith'),(2,'Maria','carter'),(3,'Walter','zenegger') set @n=@n+1 end GO 然后使用下面的SQL语句查询这个表占用的空间大小:
/****** Object: Table [dbo].[Compressed Table] Script Date: 05/27/2009 02:24:57 ******/ IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Compressed Table]') AND type in (N'U')) DROP TABLE [dbo].[Compressed Table] GO CREATE TABLE [Compressed Table] (id int, FName varchar(100), LName varchar(100)) with (Data_compression = ROW) declare @n int set @n=0 --添加10,000行 while @n<=10000 begin insert into [Compressed Table] values (1,'Adam','Smith'),(2,'Maria','carter'),(3,'Walter','zenegger') set @n=@n+1 end GO 使用下面的SQL语句查询表的空间占用情况:
/****** Object: Table [dbo].[NoNCompressed Table] Script Date: 05/27/2009 02:24:23 ******/ IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[NoNCompressed Table2]') AND type in (N'U')) DROP TABLE [dbo].[NoNCompressed Table2] GO CREATE TABLE [NoNCompressed Table2] (id int, FName varchar(100), LName varchar(100)) declare @n int set @n=0 while @n<=10000 begin insert into [NoNCompressed Table2] values (1,'Adam','Smith'),(2,'Maria','carter'),(3,'Walter','zenegger') set @n=@n+1 end GO 使用下面的SQL语句查询该表占用的空间大小: