---
title: Exclude Table Data from PostgreSQL Database Dump
description: You may want to exclude table data from specific tables during a pg_dump, here are the simple commands.
date: 2021-05-04
tags: Postgres
source: https://brianchildress.co/blog/exclude-table-data-postgres-dump
---

# Exclude Table Data from PostgreSQL Database Dump

There are many reasons why you may want to exclude table data from specific tables during a `pg_dump`. Tables might contain sensitive data (umm encryption!!), table size, unnecessary for things like local development, etc. 

If you want to export a database include all table schemas and some, but not all, table data, use the `--exclude-table-data` flag when executing `pg_dump`.

```sh
pg_dump -c -s -U <Database User> -h <Database Host> -p <Database Port>
-d <Database Name> -f <Database Dump File>
--exclude-table-data 'public.*audit`
--exclude-table-data 'schema.some_*_pattern`
```

`--exclude-table-data` will accept specific schemas and tables or will allow for wildcards (*) for more flexibility.
