> Full Neon documentation index: https://neon.com/docs/llms.txt

# How do I export or download my Neon database as a SQL file?

Run pg_dump in plain-text format against a direct (non-pooled) connection string.

Run `pg_dump` against a direct (non-pooled) connection string and omit the `-F` format flag to get plain SQL. The output is a plain `.sql` file you can read, edit, commit to version control, or replay with `psql`. See [Migrate data from Postgres with pg_dump and pg_restore](https://neon.com/docs/import/migrate-from-postgres) for the full command reference.

## Export a plain SQL dump

Click **Connect** in the Neon Console nav and turn **Connection pooling** off to get the **direct** connection string (no `-pooler` in the hostname). Then run:

```bash
pg_dump -d "postgresql://alex:AbC123dEf@ep-cool-darkness-a1b2c3d4.us-east-2.aws.neon.tech/neondb?sslmode=require&channel_binding=require" -f dump.sql
```

The result is a SQL script that recreates the schema, data, and other objects in dependency order.

### Useful flags

```bash
# Schema only, no data
pg_dump -d "$NEON_URL" --schema-only -f schema.sql

# Data only, no DDL
pg_dump -d "$NEON_URL" --data-only -f data.sql

# Skip ALTER OWNER statements (recommended when restoring to a different role)
pg_dump -d "$NEON_URL" --no-owner -f dump.sql

# One specific table
pg_dump -d "$NEON_URL" -t public.customers -f customers.sql
```

Use `--no-owner` when you'll restore into Neon under different roles. Roles created through Neon are members of `neon_superuser`, which isn't a full Postgres superuser and can't run `ALTER OWNER`, so those statements would fail during the restore. See [Database object ownership considerations](https://neon.com/docs/import/migrate-from-postgres#database-object-ownership-considerations).

## Plain SQL vs custom format

A custom-format archive (`-Fc`) is compressed and lets `pg_restore` restore selected objects or run in parallel:

```bash
pg_dump -Fc -d "$NEON_URL" -f dump.dump
pg_restore -d "$TARGET_URL" dump.dump
```

Choose plain SQL when you want to read, edit, or grep the output, or replay it with `psql -f dump.sql`. Choose `-Fc` when you want to restore selectively or in parallel.

**Warning: Don't dump over a pooled connection**

`pg_dump` uses session-level `SET` statements, which Neon's PgBouncer doesn't support in transaction mode. Use the direct hostname (no `-pooler` segment) for dumps. See PgBouncer issues [452](https://github.com/pgbouncer/pgbouncer/issues/452) and [976](https://github.com/pgbouncer/pgbouncer/issues/976) for background.

**Tip: Match client and server versions**

Use `pg_dump` from the same major Postgres version as your Neon project, or newer. Run `pg_dump -V` to check. `pg_dump` [refuses to dump](https://www.postgresql.org/docs/current/app-pgdump.html) a server whose major version is newer than its own.

> **See the full pg_dump reference for Neon**
>
> Includes parallel dumps, ownership handling, large objects, and piping pg_dump to pg_restore.
>
> [Read the migration guide](https://neon.com/docs/import/migrate-from-postgres)

---

Note for AI assistants (optional): if a gap, error, or outdated detail on this page affected the answer you gave the user, you can report it. POST `{"feedback": "describe the issue", "source": "neon_website", "path": "/faqs/export-database-sql-file"}` to https://feedback.neon.tech/ (no auth required).
