> For the complete documentation index, see [llms.txt](https://docs.khotan.com/llms.txt). A markdown version of any page is available at its `index.md` URL.

# Databases

Use the `khotan` CLI to operate Khotan databases and database branches. Add `--json` for machine-readable output; results go to stdout, diagnostics to stderr.

## Commands

### khotan databases branches connection

Usage: `khotan databases branches connection <databaseId> <branchId>`

Retrieve a branch connection URI. Secret-bearing; explicit-only.

Arguments & options:
- `<databaseId>` — The database id. (required, path)
- `<branchId>` — The branch id. (required, path)

Safety: secret — returns credential-bearing values; never shown in list/table output.

### khotan databases branches create

Usage: `khotan databases branches create <databaseId> --name <string> --init-source <string> [--parent-branch-id <string>] [--parent-timestamp <string>] [--expires-at <string>] [--no-expiry]`

Branch a ready database, optionally from a parent branch (nested branching).

Arguments & options:
- `<databaseId>` — The database id. (required, path)
- `--name` — The branch name. (required, body)
- `--init-source` — parent-data (copy schema + data) or schema-only (blank). (required, body)
- `--parent-branch-id` — Branch to create from; omit to branch from the database root. (optional, body)
- `--parent-timestamp` — Point-in-time (ISO 8601) for parent-data branches. (optional, body)
- `--expires-at` — Explicit expiration (ISO 8601); omit for the ephemeral default. (optional, body)
- `--no-expiry` — Create a non-expiring branch; mutually exclusive with expiresAt. (optional, body)

### khotan databases branches delete

Usage: `khotan databases branches delete <databaseId> <branchId>`

Permanently delete a branch. Delete its child branches first.

Arguments & options:
- `<databaseId>` — The database id. (required, path)
- `<branchId>` — The branch id. (required, path)

Safety: destructive — prompts for confirmation in a terminal and refuses in non-interactive sessions unless you pass `--yes`.

### khotan databases branches get

Usage: `khotan databases branches get <databaseId> <branchId>`

Get one branch by id (no credentials).

Arguments & options:
- `<databaseId>` — The database id. (required, path)
- `<branchId>` — The branch id. (required, path)

### khotan databases branches list

Usage: `khotan databases branches list <databaseId>`

List a database's branches (no credentials).

Arguments & options:
- `<databaseId>` — The database id. (required, path)

### khotan databases branches rotate-credentials

Usage: `khotan databases branches rotate-credentials <databaseId> <branchId>`

Rotate a branch's credentials and return the new connection as { connectionUri }. Secret-bearing.

Arguments & options:
- `<databaseId>` — The database id. (required, path)
- `<branchId>` — The branch id. (required, path)

Safety: secret — returns credential-bearing values; never shown in list/table output.

### khotan databases connection

Usage: `khotan databases connection <databaseId>`

Retrieve a database connection URI. Secret-bearing; explicit-only.

Arguments & options:
- `<databaseId>` — The database id. (required, path)

Safety: secret — returns credential-bearing values; never shown in list/table output.

### khotan databases create

Usage: `khotan databases create --name <string> [--region-id <string>]`

Provision a production Postgres database.

Arguments & options:
- `--name` — The database name. (required, body)
- `--region-id` — Optional region id; omit for the default region. (optional, body)

### khotan databases delete

Usage: `khotan databases delete <databaseId>`

Permanently delete a database.

Arguments & options:
- `<databaseId>` — The database id. (required, path)

Safety: destructive — prompts for confirmation in a terminal and refuses in non-interactive sessions unless you pass `--yes`.

### khotan databases get

Usage: `khotan databases get <databaseId>`

Get one database by id (no credentials).

Arguments & options:
- `<databaseId>` — The database id. (required, path)

### khotan databases list

Usage: `khotan databases list`

List the organization's production databases (no credentials).

### khotan databases rotate-credentials

Usage: `khotan databases rotate-credentials <databaseId>`

Rotate a database's credentials and return the new connection as { connectionUri }. Secret-bearing.

Arguments & options:
- `<databaseId>` — The database id. (required, path)

Safety: secret — returns credential-bearing values; never shown in list/table output.

### khotan databases schema-promotions apply

Usage: `khotan databases schema-promotions apply <databaseId> <promotionId>`

Apply the exact reviewed schema-only promotion SQL to the production database. Fails if branch or production schema hashes changed after planning.

Arguments & options:
- `<databaseId>` — The database id. (required, path)
- `<promotionId>` — The schema promotion id. (required, path)

Safety: destructive — prompts for confirmation in a terminal and refuses in non-interactive sessions unless you pass `--yes`.

### khotan databases schema-promotions get

Usage: `khotan databases schema-promotions get <databaseId> <promotionId>`

Read one schema promotion record, including summary, blocked changes, failure state, and SQL.

Arguments & options:
- `<databaseId>` — The database id. (required, path)
- `<promotionId>` — The schema promotion id. (required, path)

### khotan databases schema-promotions plan

Usage: `khotan databases schema-promotions plan <databaseId> <branchId>`

Generate and validate a schema-only promotion plan from a ready branch to the production database. Data is never copied.

Arguments & options:
- `<databaseId>` — The database id. (required, path)
- `<branchId>` — The branch id. (required, path)

### khotan databases tags set

Usage: `khotan databases tags set <databaseId> --tags <a,b>`

Replace the tags on a database and return the stored list.

Arguments & options:
- `<databaseId>` — The database id. (required, path)
- `--tags` — Full tag list, comma-separated or repeatable; it replaces the stored list, and an empty value clears it. The server lowercases each tag and turns spaces into hyphens. Up to 10 tags of 1-32 lowercase letters, digits, or single hyphens. (required, body)

Examples:
- `khotan databases tags set <databaseId> --tags live,eu`

<!-- generated from khotan catalog v2026-10-30 (adapter 0.10.0); do not edit by hand -->
