如何修复 SQL Server 中创建内存优化表中的错误消息 41337、级别 16、状态 100

2021-09-10 00:00:00 sql tsql sql-server

我想使用内存优化表,但出现以下错误 - 我该如何解决?任何想法都会有所帮助.

I want to use a memory optimize table and I got below error - how can I fix it? Any idea will be helpful.

消息 41337,级别 16,状态 100,第 1 行
无法创建内存优化表.要创建内存优化表,数据库必须有一个在线的 MEMORY_OPTIMIZED_FILEGROUP 并且至少有一个容器.

Msg 41337, Level 16, State 100, Line 1
Cannot create memory optimized tables. To create memory optimized tables, the database must have a MEMORY_OPTIMIZED_FILEGROUP that is online and has at least one container.

代码:

CREATE TABLE dbo.Account
(  
    AccountID INT IDENTITY(1, 1) PRIMARY KEY NONCLUSTERED
) WITH (MEMORY_OPTIMIZED=ON)

推荐答案

必须先创建一个文件组:

you must create a file Group first :

创建文件组:

imoltp 是一个示例数据库

imoltp is a sampledatabase

ALTER DATABASE imoltp ADD FILEGROUP imoltp_mod
    CONTAINS MEMORY_OPTIMIZED_DATA;

将数据库文件添加到您的文件组:

Add DatabaseFile To Your File Group :

ALTER DATABASE imoltp ADD FILE (
    name='imoltp_mod1', filename='c:\data\imoltp_mod1')
    TO FILEGROUP imoltp_mod;

创建内存优化表:

CREATE TABLE dbo.Account(   
    AccountID INT IDENTITY(1,1) PRIMARY KEY NONCLUSTERED
    ) WITH (MEMORY_OPTIMIZED=ON)

看看这个以获得更多信息:https://docs.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/creating-a-memory-优化表和本地编译存储过程?view=sql-server-ver15更多详情

take a look at this for get more Info : https://docs.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/creating-a-memory-optimized-table-and-a-natively-compiled-stored-procedure?view=sql-server-ver15 for more detail

相关文章