首页 > 解决方案 > azure SQL 中 'CLUSTERED 附近的语法不正确

问题描述

嗨,我是分区概念的新手

在 azure SQL 中使用列存储索引创建表时,我遇到了类似的错误

消息 102,级别 15,状态 1,第 15 行 'CLUSTERED' 附近的语法不正确。

请找到我在 azure SQL 中运行的以下脚本

CREATE TABLE [dbo].[FactInternetSales]
(
    [ProductKey]            int          NOT NULL
  ,[OrderDateKey]          int          NOT NULL
,   [CustomerKey]           int          NOT NULL
,   [PromotionKey]          int          NOT NULL
,   [SalesOrderNumber]      nvarchar(20) NOT NULL
,   [OrderQuantity]         smallint     NOT NULL
,   [UnitPrice]             money        NOT NULL
,   [SalesAmount]           money        NOT NULL

)
WITH
(   CLUSTERED COLUMNSTORE INDEX
,   DISTRIBUTION = HASH([ProductKey])
,   PARTITION   (   [OrderDateKey] RANGE RIGHT FOR VALUES
                    (20000101,20010101,20020101
                    ,20030101,20040101,20050101
                    )
                )
)
;

标签: sql-serversql-server-2012azure-sql-databasepartitioningazure-sql-server

解决方案


以下内容仅适用于标准 S3 层及更高版本。我无法设置分布和分区。

CREATE TABLE [dbo].[FactInternetSales]
(
    [ProductKey]            int          NOT NULL
  ,[OrderDateKey]          int          NOT NULL
,   [CustomerKey]           int          NOT NULL
,   [PromotionKey]          int          NOT NULL
,   [SalesOrderNumber]      nvarchar(20) NOT NULL
,   [OrderQuantity]         smallint     NOT NULL
,   [UnitPrice]             money        NOT NULL
,   [SalesAmount]           money        NOT NULL

)
GO
CREATE CLUSTERED COLUMNSTORE index ProductKey on FactInternetSales

推荐阅读