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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.