# dflow db:postgres:create

> Provision one PostgreSQL database in the current environment.

Web page: /docs/cli/data/db-postgres-create/

This creates one PostgreSQL database in the current environment. `--database` is the name inside PostgreSQL. `--app` can attach it to an application. There is no `--engine` flag. PostgreSQL is the engine.

```bash
dflow db:postgres:create NAME
```

## Flags

`--database` is required. It is the database name inside PostgreSQL, which can differ from the service name.

`--storage` defaults to `20Gi`. A size from `1Gi` through `100Gi` is accepted. `--version` is `16`, `17`, or `18`. Leave it off for `18`. `--app` is an optional application name or id to attach. `--wait` and `--wait-timeout` wait for the database to become ready. `--idempotency-key` makes a retry safe. The usual global flags still apply. There is no `--engine` flag.

When the object store driver is `s3`, the new database gets a daily backup at 02:00 UTC, five-field cron `0 2 * * *`, kept 7 days. Point-in-time restore is on. Linking writes `DFLOW_DATABASE_*`.

## What you see

The terminal prints `id`, `name`, `status`, and `operation_id`. The service name has to match the name pattern, in the current workspace, project, and environment. Exit 0 means the database is ready.

## When it fails

Exit 1: validation. Exit 2: auth. Exit 3: the project or environment was not found. Exit 4: that name already exists. Exit 5: the operation failed. Exit 6: no cluster is connected, or PostgreSQL is not available there. Exit 7: the wait ended first. Exit 10: the API could not be reached.
