docs:postgres:pg_dump

This is an old revision of the document!


pg_dump

  • you may need to specify the -i flag, to ignore differences in the database version and pg_dump executable; if this is done, it might be best to use a plain text format for the dump to be safe
  • the -d flag does not specify a database, but rather specifies that you want INSERT statements instead of COPY statements

Dump all tables, with acl/permissions, with create table scripts, to a plain text file (note that -d means to use INSERT statements instead of COPY statements, not to specify a db) with sql commands:

pg_dump --file=/path/to/output/file.sql --no-owner --format=p \
--disable-triggers -h hostname -d database

Dump a single table, without create table script, without ownerships, to a compressed format suitable for pg_restore:

pg_dump --data-only --file=/path/to/output/file.sql --no-owner --format=t \
--table=sometable --no-privileges --disable-triggers -h hostname database
  • docs/postgres/pg_dump.1205881172.txt.gz
  • Last modified: 2008/08/03 00:25
  • (external edit)