Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > main-testing > by-pkgid > bab02a23fa9f3df8d66a9a3231b50245 > files > 18

postgresql8.3-docs-8.3.6-2mdv2008.1.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>pg_dumpall</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 8.3.6 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="PostgreSQL Client Applications"
HREF="reference-client.html"><LINK
REL="PREVIOUS"
TITLE="pg_dump"
HREF="app-pgdump.html"><LINK
REL="NEXT"
TITLE="pg_restore"
HREF="app-pgrestore.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2009-02-03T04:34:16"></HEAD
><BODY
CLASS="REFENTRY"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
>PostgreSQL 8.3.6 Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="app-pgdump.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="app-pgdump.html"
>Fast Backward</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="app-pgrestore.html"
>Fast Forward</A
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="app-pgrestore.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="APP-PG-DUMPALL"
></A
><SPAN
CLASS="APPLICATION"
>pg_dumpall</SPAN
></H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN63437"
></A
><H2
>Name</H2
>pg_dumpall&nbsp;--&nbsp;extract a <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> database cluster into a script file</DIV
><A
NAME="AEN63441"
></A
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN63443"
></A
><H2
>Synopsis</H2
><P
><TT
CLASS="COMMAND"
>pg_dumpall</TT
> [<TT
CLASS="REPLACEABLE"
><I
>option</I
></TT
>...]</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="APP-PG-DUMPALL-DESCRIPTION"
></A
><H2
>Description</H2
><P
>   <SPAN
CLASS="APPLICATION"
>pg_dumpall</SPAN
> is a utility for writing out
   (<SPAN
CLASS="QUOTE"
>"dumping"</SPAN
>) all <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> databases
   of a cluster into one script file.  The script file contains
   <ACRONYM
CLASS="ACRONYM"
>SQL</ACRONYM
> commands that can be used as input to <A
HREF="app-psql.html"
><SPAN
CLASS="APPLICATION"
>psql</SPAN
></A
> to restore the databases.  It does this by
   calling <A
HREF="app-pgdump.html"
>pg_dump</A
> for each database in a cluster.
   <SPAN
CLASS="APPLICATION"
>pg_dumpall</SPAN
> also dumps global objects
   that are common to all databases.
   (<SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> does not save these objects.)
   This currently includes information about database users and
   groups, and access permissions that apply to databases as a whole.
  </P
><P
>   Since <SPAN
CLASS="APPLICATION"
>pg_dumpall</SPAN
> reads tables from all
   databases you will most likely have to connect as a database
   superuser in order to produce a complete dump.  Also you will need
   superuser privileges to execute the saved script in order to be
   allowed to add users and groups, and to create databases.
  </P
><P
>   The SQL script will be written to the standard output.  Shell
   operators should be used to redirect it into a file.
  </P
><P
>  <SPAN
CLASS="APPLICATION"
>pg_dumpall</SPAN
> needs to connect several
  times to the <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> server (once per
  database).  If you use password authentication it will ask for
  a password each time. It is convenient to have a
  <TT
CLASS="FILENAME"
>~/.pgpass</TT
> file in such cases. See <A
HREF="libpq-pgpass.html"
>Section 30.13</A
> for more information.
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN63467"
></A
><H2
>Options</H2
><P
>    The following command-line options control the content and
    format of the output.

    <P
></P
></P><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="OPTION"
>-a</TT
><BR><TT
CLASS="OPTION"
>--data-only</TT
></DT
><DD
><P
>        Dump only the data, not the schema (data definitions).
       </P
></DD
><DT
><TT
CLASS="OPTION"
>-c</TT
><BR><TT
CLASS="OPTION"
>--clean</TT
></DT
><DD
><P
>        Include SQL commands to clean (drop) databases before
        recreating them.  <TT
CLASS="COMMAND"
>DROP</TT
> commands for roles and
        tablespaces are added as well.
       </P
></DD
><DT
><TT
CLASS="OPTION"
>-d</TT
><BR><TT
CLASS="OPTION"
>--inserts</TT
></DT
><DD
><P
>        Dump data as <TT
CLASS="COMMAND"
>INSERT</TT
> commands (rather
        than <TT
CLASS="COMMAND"
>COPY</TT
>).  This will make restoration very slow;
        it is mainly useful for making dumps that can be loaded into
        non-<SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> databases.  Note that
        the restore might fail altogether if you have rearranged column order.
        The <TT
CLASS="OPTION"
>-D</TT
> option is safer, though even slower.
       </P
></DD
><DT
><TT
CLASS="OPTION"
>-D</TT
><BR><TT
CLASS="OPTION"
>--column-inserts</TT
><BR><TT
CLASS="OPTION"
>--attribute-inserts</TT
></DT
><DD
><P
>        Dump data as <TT
CLASS="COMMAND"
>INSERT</TT
> commands with explicit
        column names (<TT
CLASS="LITERAL"
>INSERT INTO
        <TT
CLASS="REPLACEABLE"
><I
>table</I
></TT
>
        (<TT
CLASS="REPLACEABLE"
><I
>column</I
></TT
>, ...) VALUES
        ...</TT
>).  This will make restoration very slow; it is mainly
        useful for making dumps that can be loaded into
        non-<SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> databases.
       </P
></DD
><DT
><TT
CLASS="OPTION"
>-f <TT
CLASS="REPLACEABLE"
><I
>filename</I
></TT
></TT
><BR><TT
CLASS="OPTION"
>--file=<TT
CLASS="REPLACEABLE"
><I
>filename</I
></TT
></TT
></DT
><DD
><P
>        Send output to the specified file.  If this is omitted, the
        standard output is used.
       </P
></DD
><DT
><TT
CLASS="OPTION"
>-g</TT
><BR><TT
CLASS="OPTION"
>--globals-only</TT
></DT
><DD
><P
>        Dump only global objects (roles and tablespaces), no databases.
       </P
></DD
><DT
><TT
CLASS="OPTION"
>-i</TT
><BR><TT
CLASS="OPTION"
>--ignore-version</TT
></DT
><DD
><P
>        Ignore version mismatch between
        <SPAN
CLASS="APPLICATION"
>pg_dumpall</SPAN
> and the database server.
       </P
><P
>        <SPAN
CLASS="APPLICATION"
>pg_dumpall</SPAN
> can handle databases
        from previous releases of <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
>, but very
        old versions are not supported anymore (currently prior to
        7.0).  Use this option if you need to override the version
        check (and if <SPAN
CLASS="APPLICATION"
>pg_dumpall</SPAN
> then
        fails, don't say you weren't warned).
       </P
></DD
><DT
><TT
CLASS="OPTION"
>-o</TT
><BR><TT
CLASS="OPTION"
>--oids</TT
></DT
><DD
><P
>        Dump object identifiers (<ACRONYM
CLASS="ACRONYM"
>OID</ACRONYM
>s) as part of the
        data for every table.  Use this option if your application references
        the <ACRONYM
CLASS="ACRONYM"
>OID</ACRONYM
>
        columns in some way (e.g., in a foreign key constraint).
        Otherwise, this option should not be used.
       </P
></DD
><DT
><TT
CLASS="OPTION"
>-O</TT
><BR><TT
CLASS="OPTION"
>--no-owner</TT
></DT
><DD
><P
>        Do not output commands to set
        ownership of objects to match the original database.
        By default, <SPAN
CLASS="APPLICATION"
>pg_dumpall</SPAN
> issues
        <TT
CLASS="COMMAND"
>ALTER OWNER</TT
> or 
        <TT
CLASS="COMMAND"
>SET SESSION AUTHORIZATION</TT
>
        statements to set ownership of created schema elements.
        These statements
        will fail when the script is run unless it is started by a superuser
        (or the same user that owns all of the objects in the script).
        To make a script that can be restored by any user, but will give
        that user ownership of all the objects, specify <TT
CLASS="OPTION"
>-O</TT
>.
       </P
></DD
><DT
><TT
CLASS="OPTION"
>-r</TT
><BR><TT
CLASS="OPTION"
>--roles-only</TT
></DT
><DD
><P
>        Dump only roles, no databases or tablespaces.
       </P
></DD
><DT
><TT
CLASS="OPTION"
>-s</TT
><BR><TT
CLASS="OPTION"
>--schema-only</TT
></DT
><DD
><P
>        Dump only the object definitions (schema), not data.
       </P
></DD
><DT
><TT
CLASS="OPTION"
>-S <TT
CLASS="REPLACEABLE"
><I
>username</I
></TT
></TT
><BR><TT
CLASS="OPTION"
>--superuser=<TT
CLASS="REPLACEABLE"
><I
>username</I
></TT
></TT
></DT
><DD
><P
>        Specify the superuser user name to use when disabling triggers.
        This is only relevant if <TT
CLASS="OPTION"
>--disable-triggers</TT
> is used.
        (Usually, it's better to leave this out, and instead start the
        resulting script as superuser.)
       </P
></DD
><DT
><TT
CLASS="OPTION"
>-t</TT
><BR><TT
CLASS="OPTION"
>--tablespaces-only</TT
></DT
><DD
><P
>        Dump only tablespaces, no databases or roles.
       </P
></DD
><DT
><TT
CLASS="OPTION"
>-v</TT
><BR><TT
CLASS="OPTION"
>--verbose</TT
></DT
><DD
><P
>        Specifies verbose mode.  This will cause
        <SPAN
CLASS="APPLICATION"
>pg_dumpall</SPAN
> to output start/stop
        times to the dump file, and progress messages to standard error.
        It will also enable verbose output in <SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
>.
       </P
></DD
><DT
><TT
CLASS="OPTION"
>-x</TT
><BR><TT
CLASS="OPTION"
>--no-privileges</TT
><BR><TT
CLASS="OPTION"
>--no-acl</TT
></DT
><DD
><P
>        Prevent dumping of access privileges (grant/revoke commands).
       </P
></DD
><DT
><TT
CLASS="OPTION"
>--disable-dollar-quoting</TT
></DT
><DD
><P
>        This option disables the use of dollar quoting for function bodies,
        and forces them to be quoted using SQL standard string syntax.
       </P
></DD
><DT
><TT
CLASS="OPTION"
>--disable-triggers</TT
></DT
><DD
><P
>        This option is only relevant when creating a data-only dump.
        It instructs <SPAN
CLASS="APPLICATION"
>pg_dumpall</SPAN
> to include commands
        to temporarily disable triggers on the target tables while
        the data is reloaded.  Use this if you have referential
        integrity checks or other triggers on the tables that you
        do not want to invoke during data reload.
       </P
><P
>        Presently, the commands emitted for <TT
CLASS="OPTION"
>--disable-triggers</TT
>
        must be done as superuser.  So, you should also specify
        a superuser name with <TT
CLASS="OPTION"
>-S</TT
>, or preferably be careful to
        start the resulting script as a superuser.
       </P
></DD
><DT
><TT
CLASS="OPTION"
>--use-set-session-authorization</TT
></DT
><DD
><P
>        Output SQL-standard <TT
CLASS="COMMAND"
>SET SESSION AUTHORIZATION</TT
> commands
        instead of <TT
CLASS="COMMAND"
>ALTER OWNER</TT
> commands to determine object
        ownership.  This makes the dump more standards compatible, but
        depending on the history of the objects in the dump, might not restore
        properly.
       </P
></DD
></DL
></DIV
><P>
   </P
><P
>   The following command-line options control the database connection parameters.

   <P
></P
></P><DIV
CLASS="VARIABLELIST"
><DL
><DT
>-h <TT
CLASS="REPLACEABLE"
><I
>host</I
></TT
><BR>--host=<TT
CLASS="REPLACEABLE"
><I
>host</I
></TT
></DT
><DD
><P
>        Specifies the host name of the machine on which the database
        server is running.  If the value begins with a slash, it is
        used as the directory for the Unix domain socket.  The default
        is taken from the <TT
CLASS="ENVAR"
>PGHOST</TT
> environment variable,
        if set, else a Unix domain socket connection is attempted.
       </P
></DD
><DT
>-l <TT
CLASS="REPLACEABLE"
><I
>dbname</I
></TT
><BR>--database=<TT
CLASS="REPLACEABLE"
><I
>dbname</I
></TT
></DT
><DD
><P
>         Specifies the name of the database to connect to to dump global
         objects and discover what other databases should be dumped. If
         not specified, the <SPAN
CLASS="QUOTE"
>"postgres"</SPAN
> database will be used,
         and if that does not exist, <SPAN
CLASS="QUOTE"
>"template1"</SPAN
> will be used.
       </P
></DD
><DT
>-p <TT
CLASS="REPLACEABLE"
><I
>port</I
></TT
><BR>--port=<TT
CLASS="REPLACEABLE"
><I
>port</I
></TT
></DT
><DD
><P
>        Specifies the TCP port or local Unix domain socket file
        extension on which the server is listening for connections.
        Defaults to the <TT
CLASS="ENVAR"
>PGPORT</TT
> environment variable, if
        set, or a compiled-in default.
       </P
></DD
><DT
>-U <TT
CLASS="REPLACEABLE"
><I
>username</I
></TT
><BR>--username=<TT
CLASS="REPLACEABLE"
><I
>username</I
></TT
></DT
><DD
><P
>        User name to connect as.
       </P
></DD
><DT
>-W<BR>--password</DT
><DD
><P
>        Force <SPAN
CLASS="APPLICATION"
>pg_dumpall</SPAN
> to prompt for a
        password before connecting to a database.  
       </P
><P
>        This option is never essential, since
        <SPAN
CLASS="APPLICATION"
>pg_dumpall</SPAN
> will automatically prompt
        for a password if the server demands password authentication.
        However, <SPAN
CLASS="APPLICATION"
>pg_dumpall</SPAN
> will waste a
        connection attempt finding out that the server wants a password.
        In some cases it is worth typing <TT
CLASS="OPTION"
>-W</TT
> to avoid the extra
        connection attempt.
       </P
><P
>        Note that the password prompt will occur again for each database
        to be dumped.  Usually, it's better to set up a
        <TT
CLASS="FILENAME"
>~/.pgpass</TT
> file than to rely on manual password entry.
       </P
></DD
></DL
></DIV
><P>
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN63675"
></A
><H2
>Environment</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="ENVAR"
>PGHOST</TT
><BR><TT
CLASS="ENVAR"
>PGPORT</TT
><BR><TT
CLASS="ENVAR"
>PGUSER</TT
></DT
><DD
><P
>      Default connection parameters
     </P
></DD
></DL
></DIV
><P
>   This utility, like most other <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> utilities,
   also uses the environment variables supported by <SPAN
CLASS="APPLICATION"
>libpq</SPAN
>
   (see <A
HREF="libpq-envars.html"
>Section 30.12</A
>).
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN63691"
></A
><H2
>Notes</H2
><P
>   Since <SPAN
CLASS="APPLICATION"
>pg_dumpall</SPAN
> calls
   <SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> internally, some diagnostic
   messages will refer to <SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
>.
  </P
><P
>   Once restored, it is wise to run <TT
CLASS="COMMAND"
>ANALYZE</TT
> on each
   database so the optimizer has useful statistics. You
   can also run <TT
CLASS="COMMAND"
>vacuumdb -a -z</TT
> to analyze all
   databases.
  </P
><P
>   <SPAN
CLASS="APPLICATION"
>pg_dumpall</SPAN
> requires all needed
   tablespace directories to exist before the restore or
   database creation will fail for databases in non-default
   locations.
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="APP-PG-DUMPALL-EX"
></A
><H2
>Examples</H2
><P
>   To dump all databases:

</P><PRE
CLASS="SCREEN"
><SAMP
CLASS="PROMPT"
>$</SAMP
> <KBD
CLASS="USERINPUT"
>pg_dumpall &gt; db.out</KBD
></PRE
><P>
  </P
><P
>   To reload this database use, for example:
</P><PRE
CLASS="SCREEN"
><SAMP
CLASS="PROMPT"
>$</SAMP
> <KBD
CLASS="USERINPUT"
>psql -f db.out postgres</KBD
></PRE
><P>
   (It is not important to which database you connect here since the
   script file created by <SPAN
CLASS="APPLICATION"
>pg_dumpall</SPAN
> will
   contain the appropriate commands to create and connect to the saved
   databases.)
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN63713"
></A
><H2
>See Also</H2
><P
>    Check <A
HREF="app-pgdump.html"
>pg_dump</A
> for details on possible
    error conditions.
  </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="app-pgdump.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="app-pgrestore.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>pg_dump</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="reference-client.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>pg_restore</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>