G

CREATE TABLE

Creates a new table. Supports standard column definitions plus the EMBEDDING MODEL extension for automatic vector computation.

Syntax

SQL
CREATE TABLE [IF NOT EXISTS] table_name (
    column_name data_type [PRIMARY KEY] [NOT NULL]
        [EMBEDDING MODEL 'huggingface-model-id' DIM n],
    ...
);

Embedding Column

Add EMBEDDING MODEL 'model-id' DIM n to any TEXT column to enable automatic embedding computation. When you insert a row, the sidecar computes the embedding vector and stores it alongside the text value.

SQL
CREATE TABLE docs (
    id   INT PRIMARY KEY,
    body TEXT EMBEDDING MODEL 'sentence-transformers/all-MiniLM-L6-v2' DIM 384
);

The DIM value must match the model's output dimension:

  • sentence-transformers/all-MiniLM-L6-v2 → DIM 384
  • sentence-transformers/all-mpnet-base-v2 → DIM 768
  • BAAI/bge-small-en-v1.5 → DIM 384

Warning

The server must be started with --sidecar and --model flags to use embedding columns. Without the sidecar, INSERT into embedding columns returns a SidecarUnavailable error.

Data Types

TypeDescriptionExample
INT64-bit signed integer42, -100, 0
TEXTVariable-length UTF-8 string'hello world'
FLOAT64-bit floating point3.14, -0.5
BOOLBooleantrue, false
BLOBBinary datax'deadbeef'

Examples

Simple table

SQL
CREATE TABLE users (
    id    INT PRIMARY KEY,
    name  TEXT NOT NULL,
    email TEXT,
    age   INT
);

Table with embedding column

SQL
CREATE TABLE articles (
    id         INT PRIMARY KEY,
    title      TEXT NOT NULL,
    content    TEXT EMBEDDING MODEL 'sentence-transformers/all-MiniLM-L6-v2' DIM 384,
    created_at INT
);

Multiple embedding columns

SQL
CREATE TABLE products (
    id          INT PRIMARY KEY,
    name        TEXT NOT NULL,
    description TEXT EMBEDDING MODEL 'sentence-transformers/all-MiniLM-L6-v2' DIM 384,
    category    TEXT,
    price       FLOAT
);

IF NOT EXISTS

SQL
-- No error if table already exists
CREATE TABLE IF NOT EXISTS docs (
    id   INT PRIMARY KEY,
    body TEXT EMBEDDING MODEL 'sentence-transformers/all-MiniLM-L6-v2' DIM 384
);