# ccp db



{/* Generated by scripts/sync-cli-reference.ts */}

Manage databases

```text
Usage: ccp db [OPTIONS] <COMMAND>
```

| Argument   | Type or values | Default | Parser environment variable | Description |
| ---------- | -------------- | ------- | --------------------------- | ----------- |
| --help, -h | flag           | —       | —                           | Print help  |

## `ccp db create` [#ccp-db-create]

Create a database

```text
Usage: ccp db create [OPTIONS]
```

| Argument        | Type or values   | Default | Parser environment variable | Description                                                                                          |
| --------------- | ---------------- | ------- | --------------------------- | ---------------------------------------------------------------------------------------------------- |
| --type          | postgres, sqlite | —       | —                           | Database type (prompts in a terminal, defaults to postgres in scripts)                               |
| --name          | text             | —       | —                           | Postgres database name                                                                               |
| --app, --app-id | text             | —       | —                           | App ID to bind to the managed database. Auto-detected from the active project config if not provided |
| --org-id        | text             | —       | —                           | Postgres organization ID (defaults to the linked project, `CCP_ORG_ID`, or picker)                   |
| --network       | text             | —       | —                           | Private overlay network for Postgres                                                                 |
| --help, -h      | flag             | —       | —                           | Print help                                                                                           |

## `ccp db attach-network` [#ccp-db-attach-network]

Attach an existing running database to its first private network

```text
Usage: ccp db attach-network [OPTIONS] <NETWORK>
```

| Argument   | Type or values | Default | Parser environment variable | Description                                  |
| ---------- | -------------- | ------- | --------------------------- | -------------------------------------------- |
| network    | text           | —       | —                           | Organization-scoped network name             |
| --db-id    | text           | —       | —                           | Database ID (defaults to the active project) |
| --help, -h | flag           | —       | —                           | Print help                                   |

## `ccp db list` [#ccp-db-list]

List Postgres and SQLite databases in an organization

```text
Usage: ccp db list [OPTIONS]
```

Aliases: `ls`.

| Argument   | Type or values | Default | Parser environment variable | Description                                                               |
| ---------- | -------------- | ------- | --------------------------- | ------------------------------------------------------------------------- |
| --org-id   | text           | —       | —                           | Organization ID (defaults to the linked project, `CCP_ORG_ID`, or picker) |
| --json     | flag           | false   | —                           | Emit complete, unstyled JSON                                              |
| --help, -h | flag           | —       | —                           | Print help                                                                |

## `ccp db get` [#ccp-db-get]

Show database details

```text
Usage: ccp db get [OPTIONS] [DB_ID]
```

| Argument   | Type or values | Default | Parser environment variable | Description                                                        |
| ---------- | -------------- | ------- | --------------------------- | ------------------------------------------------------------------ |
| --json     | flag           | false   | —                           | Emit structured JSON on stdout                                     |
| db\_id     | text           | —       | —                           | Database ID (defaults to the project config or .env HTTP database) |
| --help, -h | flag           | —       | —                           | Print help                                                         |

## `ccp db delete` [#ccp-db-delete]

Delete a Postgres database or a detached SQLite database

```text
Usage: ccp db delete [OPTIONS] <DB_ID>
```

Aliases: `rm`.

| Argument   | Type or values | Default | Parser environment variable | Description              |
| ---------- | -------------- | ------- | --------------------------- | ------------------------ |
| db\_id     | text           | —       | —                           | Database ID              |
| --yes, -y  | flag           | false   | —                           | Skip confirmation prompt |
| --help, -h | flag           | —       | —                           | Print help               |

## `ccp db migrate` [#ccp-db-migrate]

Run SQL migrations against a database

```text
Usage: ccp db migrate [OPTIONS]
```

| Argument   | Type or values | Default      | Parser environment variable | Description                                                      |
| ---------- | -------------- | ------------ | --------------------------- | ---------------------------------------------------------------- |
| --dir      | path           | ./migrations | —                           | Migrations directory (default: ./migrations)                     |
| --db-id    | text           | —            | —                           | Database ID (reads from the active project config if omitted)    |
| --token    | text           | —            | —                           | Database token (reads from the active project config if omitted) |
| --status   | flag           | false        | —                           | Show migration status without applying                           |
| --help, -h | flag           | —            | —                           | Print help                                                       |

## `ccp db connect` [#ccp-db-connect]

Open an interactive SQL shell

```text
Usage: ccp db connect [OPTIONS]
```

| Argument   | Type or values | Default | Parser environment variable | Description                                                      |
| ---------- | -------------- | ------- | --------------------------- | ---------------------------------------------------------------- |
| --db-id    | text           | —       | —                           | Database ID (reads from the active project config if omitted)    |
| --token    | text           | —       | —                           | Database token (reads from the active project config if omitted) |
| --help, -h | flag           | —       | —                           | Print help                                                       |

## `ccp db exec` [#ccp-db-exec]

Execute a SQL statement

```text
Usage: ccp db exec [OPTIONS] <SQL>
```

| Argument   | Type or values | Default | Parser environment variable | Description                                                      |
| ---------- | -------------- | ------- | --------------------------- | ---------------------------------------------------------------- |
| --json     | flag           | false   | —                           | Emit structured JSON on stdout                                   |
| sql        | text           | —       | —                           | SQL to execute                                                   |
| --db-id    | text           | —       | —                           | Database ID (reads from the active project config if omitted)    |
| --token    | text           | —       | —                           | Database token (reads from the active project config if omitted) |
| --help, -h | flag           | —       | —                           | Print help                                                       |

## `ccp db backup` [#ccp-db-backup]

Manage database backups

```text
Usage: ccp db backup [OPTIONS] <COMMAND>
```

| Argument   | Type or values | Default | Parser environment variable | Description |
| ---------- | -------------- | ------- | --------------------------- | ----------- |
| --help, -h | flag           | —       | —                           | Print help  |

### `ccp db backup create` [#ccp-db-backup-create]

Create a manual backup

```text
Usage: ccp db backup create [OPTIONS]
```

| Argument   | Type or values | Default | Parser environment variable | Description                                                   |
| ---------- | -------------- | ------- | --------------------------- | ------------------------------------------------------------- |
| --db-id    | text           | —       | —                           | Database ID (reads from the active project config if omitted) |
| --help, -h | flag           | —       | —                           | Print help                                                    |

### `ccp db backup list` [#ccp-db-backup-list]

List backups for a database

```text
Usage: ccp db backup list [OPTIONS]
```

Aliases: `ls`.

| Argument   | Type or values | Default | Parser environment variable | Description                                                   |
| ---------- | -------------- | ------- | --------------------------- | ------------------------------------------------------------- |
| --json     | flag           | false   | —                           | Emit a JSON array of backups                                  |
| --db-id    | text           | —       | —                           | Database ID (reads from the active project config if omitted) |
| --help, -h | flag           | —       | —                           | Print help                                                    |

### `ccp db backup restore` [#ccp-db-backup-restore]

Restore a database from a backup

```text
Usage: ccp db backup restore [OPTIONS] <BACKUP_ID>
```

| Argument   | Type or values | Default | Parser environment variable | Description                                                   |
| ---------- | -------------- | ------- | --------------------------- | ------------------------------------------------------------- |
| backup\_id | text           | —       | —                           | Backup ID to restore from                                     |
| --db-id    | text           | —       | —                           | Database ID (reads from the active project config if omitted) |
| --yes, -y  | flag           | false   | —                           | Skip confirmation prompt                                      |
| --help, -h | flag           | —       | —                           | Print help                                                    |

### `ccp db backup delete` [#ccp-db-backup-delete]

Delete a backup

```text
Usage: ccp db backup delete [OPTIONS] <BACKUP_ID>
```

Aliases: `rm`.

| Argument   | Type or values | Default | Parser environment variable | Description                                                   |
| ---------- | -------------- | ------- | --------------------------- | ------------------------------------------------------------- |
| backup\_id | text           | —       | —                           | Backup ID to delete                                           |
| --db-id    | text           | —       | —                           | Database ID (reads from the active project config if omitted) |
| --yes, -y  | flag           | false   | —                           | Skip confirmation prompt                                      |
| --help, -h | flag           | —       | —                           | Print help                                                    |

## `ccp db client-access` [#ccp-db-client-access]

Toggle client-access (JWT + anon auth) on a database

```text
Usage: ccp db client-access [OPTIONS] <COMMAND>
```

| Argument   | Type or values | Default | Parser environment variable | Description |
| ---------- | -------------- | ------- | --------------------------- | ----------- |
| --help, -h | flag           | —       | —                           | Print help  |

### `ccp db client-access enable` [#ccp-db-client-access-enable]

Enable client-access (JWT + anon auth) on a database

```text
Usage: ccp db client-access enable [OPTIONS] [DB_ID]
```

| Argument   | Type or values | Default | Parser environment variable | Description                                                   |
| ---------- | -------------- | ------- | --------------------------- | ------------------------------------------------------------- |
| db\_id     | text           | —       | —                           | Database ID (reads from the active project config if omitted) |
| --help, -h | flag           | —       | —                           | Print help                                                    |

### `ccp db client-access disable` [#ccp-db-client-access-disable]

Disable client-access on a database (restore master-token-only auth)

```text
Usage: ccp db client-access disable [OPTIONS] [DB_ID]
```

| Argument   | Type or values | Default | Parser environment variable | Description                                                   |
| ---------- | -------------- | ------- | --------------------------- | ------------------------------------------------------------- |
| db\_id     | text           | —       | —                           | Database ID (reads from the active project config if omitted) |
| --help, -h | flag           | —       | —                           | Print help                                                    |

## Example [#example]

```bash
ccp db list
```

## Global options [#global-options]

Set `CCP_CONTEXT` to choose a named context. An explicit `--context` takes precedence. See [organization selection](/docs/ccp/organizations) for organization defaults.

| Argument  | Type or values | Default | Parser environment variable | Description                                         |
| --------- | -------------- | ------- | --------------------------- | --------------------------------------------------- |
| --context | text           | —       | —                           | Select a developer context from \~/.ccp/config.toml |
