<!-- GENERATED by scripts/build-docs.mjs from the live Commander tree (src/cli/program.ts). Do not edit by hand. -->

# pai db

> Database inspection: query, tables, schema (sqlite or postgres)

## Synopsis

```
pai db <subcommand> [options]
```

## Subcommands

| Command | Description |
|---------|-------------|
| [`pai db query <sql>`](#pai-db-query-sql) | Run a SQL query against the selected database |
| [`pai db tables`](#pai-db-tables) | List all tables in the selected database |
| [`pai db schema <table>`](#pai-db-schema-table) | Show column schema for a table |

### pai db query <sql>

Run a SQL query against the selected database

**Arguments**

| Argument | Kind |
|----------|------|
| `<sql>` | required |

**Options**

| Option | Description | Default |
|--------|-------------|---------|
| `--db <target>` | Database target: sqlite (default) or postgres | `sqlite` |
| `--json` | Output results as JSON array |  |


### pai db tables

List all tables in the selected database

**Options**

| Option | Description | Default |
|--------|-------------|---------|
| `--db <target>` | Database target: sqlite (default) or postgres | `sqlite` |
| `--json` | Output as JSON array |  |


### pai db schema <table>

Show column schema for a table

**Arguments**

| Argument | Kind |
|----------|------|
| `<table>` | required |

**Options**

| Option | Description | Default |
|--------|-------------|---------|
| `--db <target>` | Database target: sqlite (default) or postgres | `sqlite` |
| `--json` | Output as JSON array |  |


## See also

[`pai audit`](audit.md) · [`pai backup`](backup.md) · [`pai clear-names`](clear-names.md) · [`pai config`](config.md) · [`pai daemon`](daemon.md) · [`pai end`](end.md) · [`pai help`](help.md) · [`pai identity`](identity.md) · [`pai kg`](kg.md) · [`pai launch`](launch.md) · [`pai mcp`](mcp.md) · [`pai memory`](memory.md) · [`pai notify`](notify.md) · [`pai observation`](observation.md) · [`pai obsidian`](obsidian.md) · [`pai pause`](pause.md) · [`pai project`](project.md) · [`pai projects`](projects.md) · [`pai registry`](registry.md) · [`pai restore`](restore.md) · [`pai session`](session.md) · [`pai sessions`](sessions.md) · [`pai setup`](setup.md) · [`pai shell-init`](shell-init.md) · [`pai skill`](skill.md) · [`pai task`](task.md) · [`pai topic`](topic.md) · [`pai update`](update.md) · [`pai worker`](worker.md) · [`pai zettel`](zettel.md)

Run `pai help <area>` to read any of these in the terminal.

