---
title: "Database (Live Tables) in the CLI"
canonical: https://trickest.com/docs/developer-tools/cli/database
description: "List Live Tables, inspect schemas, and query data with TQL from the trickest CLI."
---

# Database (Live Tables) in the CLI

The **`database`** family manages **Live Tables** — structured datasets populated
by workflow runs and solutions. From the CLI you list tables, inspect schemas,
preview rows, and run **TQL** (Trickest Query Language) filters.

<Info>
**TQL in the UI:** The Query tab in the app uses the same filter language. See
[Querying](/docs/using-the-app/database-management/querying) for UI-focused
examples and operator tables.
**Concepts:** [Solutions & Database](/docs/key-concepts/solutions-database).
</Info>

## Command summary

| Subcommand | Description |
|---|---|
| `database ls` | List tables |
| `database get <table>` | Table detail view |
| `database schema <table>` | Column types and constraints |
| `database preview <table>` | First N rows |
| `database query <expr>` | Run a TQL filter |
| `database live <table>` | Create a live table connection |
| `database detect` | Scan latest run outputs for JSONL tables |
| `database rm <table>` | Delete a table |

## Listing and inspecting

### `database ls`

```bash
trickest database ls
```
```json
[{"id":"1a66b80e-…","name":"merge-all_merge-all","status":"live","schema":{"fields":[{"name":"id","type":"int64","is_key":true}, …]}}]
```

### `database schema` / `preview` / `get`

```bash
trickest database schema 1a66b80e-…
trickest database preview 1a66b80e-… --limit 10
trickest database get 1a66b80e-…
```

## Querying with TQL

`database query` runs a **filter-only** expression — not SQL `SELECT`.

### Syntax

- **Operators:** `=`, `!=`, `>`, `<`, `~` (contains), `!~` (not contains)
- **Combine with:** `AND`, `OR`
- **No** `SELECT`, `JOIN`, `GROUP BY`, aggregates, or wildcards

Examples:

```text
severity = "critical"
port > 443 AND service = "http"
hostname ~ ".*staging.*"
```

### Running a query

```bash
trickest database query "id > 0" --table 1a66b80e-… --limit 10
trickest database query "severity = critical" --table 1a66b80e-… --limit 1 --select id,name,severity
```

| Flag | Description |
|---|---|
| `--table <id>` | Table ID (required) |
| `--limit <n>` | Max rows returned |
| `--offset <n>` | Pagination offset |
| `--select <cols>` | Comma-separated columns |
| `--order-by <expr>` | e.g. `"severity DESC"` |

### Row shape

Each row includes system columns prefixed with `_` (`_id`, `_status`,
`_is_active`, `_first_seen`, `_last_seen`, `_timestamp`, `_execution_id`,
`_user`) plus your dataset fields. Filter on **user** fields; `_` columns are
platform bookkeeping.

### Counting rows

There is no `COUNT(*)`. Run the same filter with `--limit 1` and read
`total_count` from the response.

<Warning>
`--limit 0` is rejected by the platform API. Do not use it for counts.
</Warning>

## Related

<CardGroup cols={2}>
  <Card title="Solutions" icon="gem" href="/docs/developer-tools/cli/solutions">
    Solutions own the datasets that back Live Tables.
  </Card>
  <Card title="Querying (UI)" icon="database" href="/docs/using-the-app/database-management/querying">
    Write and run TQL from the Live Table Query tab.
  </Card>
</CardGroup>

---
_Markdown source of https://trickest.com/docs/developer-tools/cli/database._
