Types, keys, constraints, collation, and schema management. Deep dives:
docs/features/AUTO_ROWID.md·docs/collation/COLLATION_GUIDE.md·docs/serialization/README.md
| SQL type | .NET type | Notes |
|---|---|---|
TEXT |
string |
UTF-8, collation-aware |
INTEGER |
int |
32-bit; INTEGER PRIMARY KEY acts as rowid alias (SQLite-compatible) |
LONG |
long |
64-bit |
REAL |
double |
IEEE-754 |
DECIMAL |
decimal |
28-digit fixed point |
BOOLEAN |
bool |
stored as 0/1 |
DATETIME |
DateTime |
UTC, tick precision |
GUID |
Guid |
16-byte |
ULID |
Ulid |
16-byte sortable ID |
BLOB |
byte[] |
binary payloads |
ROWREF |
internal | row reference/pointer |
-- SQLite-style rowid alias (INTEGER PRIMARY KEY)
CREATE TABLE t1 (id INTEGER PRIMARY KEY, name TEXT);
-- Integer auto-increment (persisted across restarts)
CREATE TABLE t2 (id INTEGER PRIMARY KEY AUTO, name TEXT);
-- Hidden _rowid: when a table has NO explicit PRIMARY KEY,
-- SharpCoreDB injects a hidden _rowid (ULID, AUTO, PRIMARY KEY, NOT NULL)
-- exactly like SQLite's rowid — but ULID-based instead of monotonic integer:
CREATE TABLE t3 (name TEXT, email TEXT); -- _rowid ULID auto-PK added automatically
-- Explicit ULID key (set values yourself, or leave null to auto-generate)
CREATE TABLE t4 (id ULID PRIMARY KEY, name TEXT);_rowidis a hidden auto-generated primary key of type ULID (Ulid.NewUlid()) — sortable by time, collision-free across nodes, and index-friendly.id INTEGER PRIMARY KEY AUTOgives the classic monotonic integer counter, persisted across restarts.- Explicit
GUID/ULIDcolumns auto-generate their value when inserted with a null/missing key.
See docs/features/AUTO_ROWID.md.
CREATE TABLE orders (
id LONG PRIMARY KEY,
customer LONG NOT NULL,
total REAL DEFAULT 0,
status TEXT CHECK (status IN ('open','closed')),
created DATETIME DEFAULT current_timestamp,
UNIQUE (customer, created)
);Foreign keys, ON DELETE/ON UPDATE cascade rules, and deferrable constraints are supported.
| Collation | Behavior |
|---|---|
BINARY |
byte-wise (default, fastest) |
NOCASE |
ASCII case-insensitive |
RTRIM |
ignores trailing spaces |
UNICODE_CI |
Unicode case-insensitive |
LOCALE("xx_XX") |
ICU/OS locale-aware |
CREATE TABLE users (name TEXT COLLATE NOCASE);
SELECT * FROM users WHERE name = 'ADA' COLLATE NOCASE; -- matches 'ada'⚡
BINARYcollation is the only one that can be matched via pure SIMD byte compares. Prefer it on hot lookup columns. Seedocs/collation/COLLATION_GUIDE.md.
db.CreateTable(...),db.DropTable(...),db.RenameTable(...),db.AlterTable(...)db.AddColumn,db.DropColumn,db.RenameColumndb.GetTableMetadata(name)for column/index introspectiondb.GetTables()enumerates the catalog