> ## Documentation Index
> Fetch the complete documentation index at: https://toradb.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# SQL DDL

> CREATE, DROP, INDEX, COMPACT, ALTER

## CREATE TABLE

```sql theme={null}
CREATE TABLE articles USING text
CREATE TABLE papers (id uuid, title text, embedding vector[4]) USING hybrid
```

## CREATE INDEX

```sql theme={null}
CREATE INDEX text_idx ON articles (text) USING BM25
CREATE INDEX ann_idx ON papers (embedding) USING HNSW
CREATE INDEX disk_idx ON ann_corpus (embedding) USING DISKANN
```

Common `USING` values: `BM25`, `HNSW`, `DISKANN`.

## DROP TABLE

```sql theme={null}
DROP TABLE logs
```

## DESCRIBE

```sql theme={null}
DESCRIBE articles
```

Returns row count, vector dimension, segment count, segment workers, and index sidecars.

## COMPACT TABLE

```sql theme={null}
COMPACT TABLE articles
COMPACT TABLE articles FULL
```

Merges small Parquet segments. `FULL` forces a more aggressive merge policy.

## ALTER segment workers

```sql theme={null}
ALTER TABLE articles SET SEGMENT_WORKERS = 4
```

## ALTER column type

Assign or change a metadata column type on an existing table:

```sql theme={null}
ALTER TABLE articles ALTER COLUMN year TYPE int
ALTER TABLE papers ALTER COLUMN embedding TYPE vector(384)
ALTER TABLE articles ALTER COLUMN year TYPE int REWRITE
```

`REWRITE` chains `COMPACT TABLE … FULL` after updating the manifest. Without it, run compact manually when segments still use the legacy four-column layout.

See [Typed metadata columns](/guides/typed-columns) for supported types, compound `WHERE`, and filter behavior.

## WITH + JOIN

CTEs can be combined with metadata joins:

```sql theme={null}
WITH cited AS (SELECT id, paper_id FROM papers)
SELECT id FROM cited
JOIN citations ON cited.paper_id = citations.paper_id
SPARSE SEARCH body BM25('query') LIMIT 10
```

## SHOW TABLES

```sql theme={null}
SHOW TABLES
```

Returns table names with row counts (analytics shape in Python).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.