Computer Science


PG_DUMP(1)                                             PG_DUMP(1)

NAME
       pg_dump - Extract a Postgres database into a script file

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

   INPUTS
       pg_dump accepts the following command line arguments:

       dbname Specifies the name of the database to be extracted.
              dbname defaults to the value of the  USER  environ-
              ment variable.

       -a     Dump out only the data, no schema (definitions).

       -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. Defaults to stdout.

       -n     Suppress  double  quotes  around identifiers unless
              absolutely necessary.  This may cause trouble load-
              ing  this  dumped  data if there are reserved words
              used for identifiers.  This was the default  behav-
              ior in pre-v6.4 pg_dump.

       -N     Include  double quotes around identifiers.  This is
              the default.

       -o     Dump object identifiers (OIDs) for every table.

       -s     Dump out only the schema (definitions), no data.

       -t table
              Dump data for 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.

       pg_dump also accepts the following command line  arguments
       for connection parameters:

       -h host
              Specifies  the hostname of the machine on which the
              postmaster is running. Defaults to  using  a  local
              Unix domain socket rather than an IP connection..

       -p port
              Specifies  the  Internet  TCP/IP port or local Unix
              domain socket file extension on which the  postmas-
              ter  is  listening for connections. The port number
              defaults to 5432, or the value of the PGPORT  envi-
              ronment variable (if set).

       -u     Use  password authentication.  Prompts for username
              and password.

   OUTPUTS
       pg_dump will create a file or write to stdout.

       Connection to database 'template1' failed.
              pg_dump could not attach to the postmaster  process
              on  the  specified  host  and port. If you see this
              message, ensure that the postmaster is  running  on
              the  proper  host  and  that you have specified the
              proper port. If your site  uses  an  authentication
              system,  ensure that you have obtained the required
              authentication credentials.

       Connection to database 'dbname' failed.
              You do not have  a  valid  entry  in  the  relation
              pg_shadow  and  and  will  not be allowed to access
              Postgres.  Contact your Postgres administrator.

       dumpSequence(table): SELECT failed
              You do not have permission to  read  the  database.
              Contact your Postgres site administrator.

              Note:  pg_dump  internally  executes  SELECT state-
              ments. If you have problems running  pg_dump,  make
              sure  you  are  able to select information from the
              database using, for example, psql.

DESCRIPTION
       pg_dump is a utility for dumping out a  Postgres  database
       into  a  script file containing query commands. The script
       files are in text format and can be  used  to  reconstruct
       the  database,  even on other machines and other architec-
       tures.  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 text format so that it can be read-
       ily copied in again, as well as imported  into  tools  for
       editing.

       pg_dump  is  useful  for  dumping  out  the  contents of a
       database  to  move  from  one  Postgres  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.

NOTES
       pg_dump  has  a  few  limitations.  The limitations mostly
       stem from difficulty in extracting  certain  meta-informa-
       tion from the system catalogs.

       o pg_dump  does not understand partial indices. The reason
         is the same  as  above;  partial  index  predicates  are
         stored as plans.

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

USAGE
       To dump a database of the same name as the user:

       % pg_dump > db.out

       To reload this database:

       % psql -e database < db.out

Application               15 August 1999                        1

Back to the index


Apply now!


Handbook

Postgraduate study options

Computer Science Blog



Please give us your feedback or ask us a question

This message is...


My feedback or question is...


My email address is...

(Only if you need a reply)

A to Z Directory | Site map | Accessibility | Copyright | Privacy | Disclaimer | Feedback on this page