Creating memory-optimized tables and indexes

Now that we have looked at the theory behind the storage of memory-optimized tables, we want to get to the real fun and create some of these objects.

Laying the foundation

Before we can start creating our memory-optimized objects, we need to create a database with a filegroup designed for memory-optimized objects. This can be achieved as follows:

CREATE DATABASE InMemoryTest ON PRIMARY(NAME = [InMemoryTest_disk], FILENAME = 'C:\temp\InMemoryTest_disk.mdf', size=100MB), FILEGROUP [InMemoryTest_inmem] CONTAINS MEMORY_OPTIMIZED_DATA (NAME = [InMemoryTest_inmem], FILENAME = 'C:\temp\InMemoryTest_inmem') LOG ON (name = [InMemoryTest_log], Filename='c:\temp\InMemoryTest_log.ldf', size=100MB) COLLATE Latin1_General_100_BIN2; ...

Get SQL Server 2016 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.