In-Memory DatabasesIntermediate
1Question 1 of 1
javascriptHow do in-memory databases work in SQLite?
Explanation & Concept
SQLite allows creating transient databases residing entirely in RAM by specifying `:memory:` as the database filename (or using memory URI filenames). In-memory databases are exceptionally fast and vanish completely when the connection closes.
Code Example
javascript
import Database from "better-sqlite3";
// Create in-memory SQLite database instance
const db = new Database(":memory:");
db.exec(`
CREATE TABLE benchmarks (id INTEGER PRIMARY KEY, score REAL);
INSERT INTO benchmarks (score) VALUES (98.6), (99.2);
`);
const rows = db.prepare("SELECT AVG(score) AS avgScore FROM benchmarks").get();
console.log("Memory DB Average:", rows.avgScore);How It Works & Key Takeaways
In-memory databases provide ideal test fixtures for CI/CD test suites: each test run gets an isolated, ephemeral database without disk I/O cleanup.
Mock Test · 1 Questions · Optional
Ready for Backup & Export?
Take a quick test to evaluate yourself, or move straight to the next module.
Intermediate1 questions