PG_DUMP(UNIX)

NAME
pg_dump - dumps out a Postgres database into a script file

SYNOPSIS
pg_dump [-a ] [-c ] [-d ] [-D ] [-f filename ] [-h hostname ] [-n ] [-o ] [-p port] [-s ] [-t table] [-u ] [-v ] [-x ] dbname

DESCRIPTION
pg_dump is a utility for dumping out a Postgres database into a script file containing query commands. The script files are in ASCII format and can be used to reconstruct the database, even on other machines and other architectures. pg_dump will produce the queries necessary to re-generate all user-defined types, functions, tables, indices, aggregates, and operators. In addition, all the data is copied out in ASCII format so that it can be readily copied in again, as well as imported into tools for textual editing.

pg_dump is useful for dumping out the contents of a database to move from one postgreSQL installation to another. After running pg_dump , one should examine the output script file for any warnings, especially in light of the limitations listed below.

pg_dump understands the following options:

-a  Dump out only the data, no schema

-c  Clean(drop) schema prior to create

-d  Dump data as proper insert strings

-D  Dump data as inserts with attribute names

-f filename
    Specifies the output file

-h hostname
    Specifies the server host name

-n  Suppress most double quotes around identifiers.

-o  Dump object id's (oids)

-p port
    Specifies the server port number

-s  Dump out only the schema, no data

-t table
    Dump for this table only

-u  Use password authentication. Prompts for username and password

-v  Specifies verbose mode

-x  Prevent dumping of ACLs (grant/revoke commands) and table ownership information

If dbname is not supplied, then the DATABASE environment variable value is used.

CAVEATS AND LIMITATIONS
pg_dump has a few limitations. The limitations mostly stem from difficulty in extracting certain meta-information from the system catalogs.

partial indices
    pg_dump does not understand partial indices. (The reason is the same as above. Partial index predicates are stored as plans)

large objects
    pg_dump does not handle large objects. Large objects are ignored and must be dealt with manually.

EXAMPLES
To dump a database:
	pg_dump >db.out
To reload it:
	psql -e database <db.out

SEE ALSO
copy(l).