SQL Reference Overview
MemoraDB provides a custom SQL-like query language designed specifically for its append-only temporal and semantic architecture.
Dialect Characteristics
Before writing queries in MemoraDB, note the following language rules:
- Keyword Case-Insensitivity: All SQL keywords are case-insensitive.
SELECT, select, and Select are treated identically.
- Identifier Case Sensitivity: Identifiers (table names and column names) are matched against schema definitions. The parser will attempt exact match followed by lowercase fallback.
- Semicolon Termination: Every SQL statement must terminate with a semicolon (
;). Statements without a semicolon will prompt the REPL for continuation lines (...>).
- String Literals: Strings can be quoted using either single quotes (
'text') or double quotes ("text").
- Numeric Literals: Integers (
42, -10) and floating-point numbers (3.14, -0.05) are natively supported, including unary minus.
- No Inline SQL Comments: The MemoraDB lexer does not include comment tokens (such as
-- or /* */). Do not include SQL comment markers in statements sent to the REPL.
Supported Statement Categories
MemoraDB organizes statements into four functional categories:
1. Data Definition Language (DDL)
| Statement |
Description |
CREATE TABLE |
Defines a new table schema with typed columns and primary key. |
DROP TABLE |
Deletes a table and removes its data directory from disk. |
DESCRIBE TABLE |
Prints the schema definition and column metadata of a table. |
SHOW TABLES |
Lists all tables currently registered in the database catalog. |
2. Data Manipulation Language (DML)
| Statement |
Description |
INSERT INTO |
Appends a new row version with positional column values. |
UPDATE |
Appends a new row version with updated column values. |
DELETE FROM |
Appends a tombstone record marking rows as deleted. |
3. Query Language (QL)
| Feature |
Description |
SELECT |
Reads records with projection (* or column list), ordering, and limits. |
WHERE Clause |
Filters records using comparison operators or semantic search. |
ORDER BY |
Sorts query results by a specified column in ascending or descending order. |
LIMIT |
Restricts the maximum number of records returned. |
4. Temporal Statements
| Statement |
Description |
AS OF / SNAPSHOT |
Queries the state of a table as of a past date or instant. |
BETWEEN ... AND ... |
Queries all versions committed within a time window. |
HISTORY |
Displays the full version chain for a specific primary key. |
EVOLUTION |
Displays step-by-step column diffs across consecutive versions. |
COMPARE |
Displays net column differences between two points in time. |
ROLLBACK |
Restores a row or table to a past state by appending new records. |
COMPACT TABLE |
Purges superseded history prior to an anchor date and archives old data. |