Getting startedInstall CobaltDB and run your first SQL query in Go.SQL & JSONTables, indexes, parameterized queries, JSON and transactions.ArchitectureExplore disk-paged B+trees, bounded memory and crash recovery.Server & clientsConnect MySQL 8.4 clients and ORMs to the standalone server.Production guidePlan TLS, security, backups, observability and deployment boundaries.Performance benchmarksPaged storage, memory measurements and benchmark methodology.FeaturesSQL, transactions, encryption and a pure Go runtime.Brand assetsDownload the CobaltDB SVG logo and icon.
K to open ESC to close
Documentation

SQL & JSON

Tables, indexes, parameterized queries, JSON and transactions.

MySQL 8.4 semantics

Version 0.7.0 targets MySQL 8.4 SQL behavior: strict sql_mode, collations, exact DECIMAL values, canonical JSON, temporal types, window functions and recursive CTEs. Stored routines, triggers, events, generated columns and partitioning are supported too.

Known differences remain. INTEGER is 64-bit; ONLY_FULL_GROUP_BY is reported but not enforced. FULLTEXT queries scan rows rather than using the index to accelerate MATCH.

Tables & indexes

Start with familiar relational structures. CobaltDB supports SQL tables, primary keys, constraints and indexes. Use explicit IDs in this example so you can run each statement in sequence.

SchemaSQL
CREATE TABLE projects (
    id INTEGER PRIMARY KEY,
    name TEXT NOT NULL,
    language TEXT,
    stars INTEGER,
    metadata JSON
);

CREATE INDEX idx_language ON projects(language);

INSERT INTO projects VALUES
    (1, 'cobaltdb', 'Go', 1280, '{"region":"eu-west"}'),
    (2, 'atlas', 'Go', 864, '{"region":"us-east"}');

The names and numbers in these examples are illustrative data, not repository statistics.

Queries & parameters

Find projectsSQL
SELECT name, language, stars
FROM projects
WHERE language = 'Go'
ORDER BY stars DESC
LIMIT 10;

In Go, bind values using ? placeholders. Keep user input out of SQL string concatenation.

Parameterized queryGo
rows, err := db.Query(ctx,
    "SELECT name FROM projects WHERE stars > ?", 100)
if err != nil { log.Fatal(err) }
defer rows.Close()

for rows.Next() {
    var name string
    if err := rows.Scan(&name); err != nil { log.Fatal(err) }
    fmt.Println(name)
}

JSON, alongside your tables

Use a JSON column for fields that vary by record. Extract nested values while keeping the rest of the query relational.

Read JSON fieldsSQL
SELECT name,
    JSON_EXTRACT(metadata, '$.region') AS region
FROM projects;

UPDATE projects
SET metadata = JSON_SET(metadata, '$.active', true)
WHERE id = 1;

Transactions

Group related statements with BEGIN and COMMIT. Use ROLLBACK when you need to discard the transaction.

Atomic transferSQL
CREATE TABLE accounts (id INTEGER PRIMARY KEY, balance INTEGER);
INSERT INTO accounts VALUES (1, 1000), (2, 1000);

BEGIN;
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
UPDATE accounts SET balance = balance + 100 WHERE id = 2;
COMMIT;

For application code, the engine also exposes db.Begin(), tx.Exec(), tx.Commit() and tx.Rollback(). Review the transaction settings for your workload before deployment.

Writes use row locks with deadlock detection (1213) and lock wait timeouts (1205). FOR UPDATE, FOR SHARE, NOWAIT and SKIP LOCKED are available. The default isolation is read committed with lost-update prevention; WITH CONSISTENT SNAPSHOT gives a transaction one read snapshot. SERIALIZABLE is refused.

Keep the reference close

Read the upstream SQL reference for types and basic statements, and the compatibility matrix for tested SQL forms and protocol behavior.

Source-aligned guide · CobaltDB v0.7.0Suggest an improvement