不能创建Memory Optimized Table
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了不能创建Memory Optimized Table相关的知识,希望对你有一定的参考价值。
为DBTest增加了一个Memory Table FileGroup,但是在创建Memory Optimized Table时,出现error
Cannot create memory optimized tables in a database that does not have an online and non-empty MEMORY_OPTIMIZED_DATA filegroup.
USE [master] GO ALTER DATABASE [DBTest] ADD FILEGROUP [MemoryTableGroup] CONTAINS MEMORY_OPTIMIZED_DATA; GO USE [DBTest] GO --Drop table if it already exists. IF OBJECT_ID(‘dbo.MemoryTable_test‘,‘U‘) IS NOT NULL DROP TABLE dbo.MemoryTable_test GO CREATE TABLE dbo.MemoryTable_test ( ID int not null , name varchar(11) not null, age int not null, constraint PK__MemoryTable_Test primary key nonclustered hash(ID) with (bucket_count=1024) ) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA ) GO
查看MemoryTableGroup,其FileStream files的数量是0,需要为该FileGroup 添加File。
为MemoryTableGroup 添加一个File,Memory Table创建成功。
ALTER DATABASE [DBTest] ADD FILE (name=‘DBTest_file1‘, filename=‘D:\\MSSQLServerData\\MSSQL12.MSSQLSERVER\\MSSQL\\DATA\\DBTest_file1‘) TO FILEGROUP [MemoryTableGroup] GO
参考doc:
The Memory Optimized Filegroup
Cannot create memory optimized tables in a database on SQL Server 2014
以上是关于不能创建Memory Optimized Table的主要内容,如果未能解决你的问题,请参考以下文章