0

如您所见,我创建了此文件组:

创建数据库 AdventureWorksDW

ALTER DATABASE AdventureWorksDW ADD FILEGROUP [Filegroup_2001]  
GO  
ALTER DATABASE AdventureWorksDW ADD FILEGROUP [Filegroup_2002]  
GO  
ALTER DATABASE AdventureWorksDW ADD FILEGROUP [Filegroup_2003]  
GO  
ALTER DATABASE AdventureWorksDW ADD FILEGROUP [Filegroup_2004]  
GO

使用这些文件:

ALTER DATABASE AdventureWorksDW
  ADD FILE
  (NAME = N'data_2001',
  FILENAME = N'C:\FileGroupFile\data_2001.ndf',
  SIZE = 5000MB,
  MAXSIZE = 10000MB,
  FILEGROWTH = 500MB)
  TO FILEGROUP [Filegroup_2001]  
GO  
ALTER DATABASE AdventureWorksDW
  ADD FILE
  (NAME = N'data_2002',
  FILENAME = N'C:\FileGroupFile\data_2002.ndf',
  SIZE = 5000MB,
  MAXSIZE = 10000MB,
  FILEGROWTH = 500MB)
  TO FILEGROUP [Filegroup_2002]
GO  
ALTER DATABASE AdventureWorksDW
  ADD FILE
  (NAME = N'data_2003',    
  FILENAME = N'C:\FileGroupFile\data_2003.ndf',    
  SIZE = 5000MB,    
  MAXSIZE = 10000MB,    
  FILEGROWTH = 500MB)  
  TO FILEGROUP [Filegroup_2003]  
GO  
ALTER DATABASE AdventureWorksDW
  ADD FILE  
  (NAME = N'data_2004',
  FILENAME = N'C:\FileGroupFile\data_2004.ndf',
  SIZE = 5000MB,
  MAXSIZE = 10000MB,
  FILEGROWTH = 500MB)
  TO FILEGROUP [Filegroup_2004]
GO

使用这些分区函数和架构:

CREATE PARTITION FUNCTION FullOrderDateKeyRangePFN(int)  AS
  RANGE LEFT FOR VALUES 
  (  1,2,3,4  )

  CREATE PARTITION SCHEME FullOrderDateRangePScheme  AS
  PARTITION FullOrderDateKeyRangePFN  TO 
  ([Filegroup_2001],
  [Filegroup_2002],
  [Filegroup_2003],
  [Filegroup_2004],
  [PRIMARY]  )

最后我创建了我的表:

CREATE TABLE [DBO].[FACTINTERNETSALES_PARTITIONED] (
  [CUSTOMERPONUMBER]      [NVARCHAR](25)   NULL,
  [asl]              [int]   NULL)
  ON FullOrderDateRangePScheme  (asl)

我在我的表中插入了 1000000 条 asl=1 的记录,但是当我运行这个查询时:

SELECT $PARTITION.FullOrderDateKeyRangePFN(4)  AS PARTITIONID,
       COUNT(*)                                   AS ROW_COUNT
FROM     DBO.FACTINTERNETSALES_PARTITIONED

它为所有分区返回 1000000 条记录我的意思是 1 返回 1000000 和 2 返回 1000000 和...为什么?

4

0 回答 0