SQL Server has in-memory OLTP. This feature is quite close to what you are looking into. Starting SQL Server 2016 SP1 it is possible in all editions, including sql express.
Obviously I don't need persistence
The option DURABILITY=SCHEMA_ONLY
preserves only the metadata. Such a scenario can be optimal for staging tables because it results in a lock/latch/log free way of data load. Obviously, the table will not survive instance/service restart.
CREATE DATABASE [Test]
GO
-- Memory Optimized FG
ALTER DATABASE [Test] ADD FILEGROUP [MemoryOptimizedFG] CONTAINS MEMORY_OPTIMIZED_DATA
ALTER DATABASE [Test] ADD FILE (name='Test1', filename='D:\SQLData\TestInMemory') TO FILEGROUP [MemoryOptimizedFG]
GO
CREATE TABLE dbo.[TestTable] (
ID int NOT NULL IDENTITY (1, 1) PRIMARY KEY NONCLUSTERED,
ColumnID int NOT NULL,
Description varchar(100) NOT NULL,
dateAndTime datetime NOT NULL
) WITH (MEMORY_OPTIMIZED=ON, DURABILITY=SCHEMA_ONLY)
GO
References:
DROP DATABASE
and RESTORE would work just fine though. Using a script would work just fine too. In fact, even it if was in-memory, you wouldn't be able to tell the difference until the server restarted – Duumvirtempdb
and all of them would be gone the next time you restarted the server. An "in-memory database" though would require its owndrop database
statement to get deleted without a restart – DuumvirATTACH DATABASE
. This will be faster than RESTORE because it won't have a recovery phase – Duumvir