1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 07:08:01 +00:00
Files
til/postgres/include-multiple-tables-in-a-pg-dump.md

909 B

Include Multiple Tables In A pg_dump

When the pg_dump command is given the -t flag, it will dump just the table named with that flag. If you want to include multiple tables in the dump, you just need to use the flag multiple times.

$ pg_dump -t users -t users_roles -t roles my_database > roles.dump.sql

Alternatively, you can specify a pattern when using the -t flag.

$ pg_dump -t 'users*|roles' my_database > roles.dump.sql

You have to be a little more mindful of what will and won't be included when crafting a pattern. It is a nice shortcut for a well-known or well-constrained data model.

See the pg_dump docs for more details, as well as some examples.