0

刚刚安装了 SQL Server 2014。

直接来自文档的语法失败。

这失败了Sales

CREATE TYPE [Sales].[SalesOrderDetailType_inmem] AS TABLE(
  [OrderQty] [smallint] NOT NULL,
  [ProductID] [int] NOT NULL,
  [SpecialOfferID] [int] NOT NULL,
  [LocalID] [int] NOT NULL,

  INDEX [IX_ProductID] HASH ([ProductID]) WITH ( BUCKET_COUNT = 8),
  INDEX [IX_SpecialOfferID] NONCLUSTERED 
)
WITH ( MEMORY_OPTIMIZED = ON )

但如果我删除Sales它仍然失败

CREATE TYPE [SalesOrderDetailType_inmem] AS TABLE(
  [OrderQty] [smallint] NOT NULL,
  [ProductID] [int] NOT NULL,
  [SpecialOfferID] [int] NOT NULL,
  [LocalID] [int] NOT NULL,

  INDEX [IX_ProductID] HASH ([ProductID]) WITH ( BUCKET_COUNT = 8),
  INDEX [IX_SpecialOfferID] NONCLUSTERED 
)
WITH ( MEMORY_OPTIMIZED = ON )

出现以下错误

消息 8135,级别 16,状态 0,行 10
表级别约束未指定列列表,表 'SalesOrderDetailType_inmem'。

如何创建内存优化表类型?

4

1 回答 1

1

以下语法似乎有效。我已经为dbo模式编写了脚本。建议将其BUCKET_COUNT设置为将要保存的唯一值的 ~1x-2x。

CREATE TYPE [SalesOrderDetailType_inmem] AS TABLE(
  [OrderQty] [smallint] NOT NULL,
  [ProductID] [int] NOT NULL 
    INDEX [IX_ProductID] HASH ([ProductID]) WITH ( BUCKET_COUNT = 8),
  [SpecialOfferID] [int] NOT NULL 
    INDEX [IX_SpecialOfferID] NONCLUSTERED ,
  [LocalID] [int] NOT NULL

)
WITH ( MEMORY_OPTIMIZED = ON )
于 2014-05-13T04:40:55.400 回答