⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pg_dump.sgml

📁 postgresql8.3.4源码,开源数据库
💻 SGML
📖 第 1 页 / 共 3 页
字号:
        whereas <command>ALTER OWNER</> requires lesser privileges.       </para>      </listitem>     </varlistentry>     <varlistentry>      <term><option>-Z <replaceable class="parameter">0..9</replaceable></option></term>      <term><option>--compress=<replaceable class="parameter">0..9</replaceable></option></term>      <listitem>       <para>        Specify the compression level to use.  Zero means no compression.        For the custom archive format, this specifies compression of        individual table-data segments, and the default is to compress        at a moderate level.        For plain text output, setting a nonzero compression level causes        the entire output file to be compressed, as though it had been        fed through <application>gzip</>; but the default is not to compress.        The tar archive format currently does not support compression at all.       </para>      </listitem>     </varlistentry>    </variablelist>   </para>   <para>    The following command-line options control the database connection parameters.    <variablelist>     <varlistentry>      <term><option>-h <replaceable class="parameter">host</replaceable></option></term>      <term><option>--host=<replaceable class="parameter">host</replaceable></option></term>      <listitem>       <para>        Specifies the host name of the machine on which the 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 <envar>PGHOST</envar> environment variable, if set,        else a Unix domain socket connection is attempted.       </para>      </listitem>     </varlistentry>     <varlistentry>      <term><option>-p <replaceable class="parameter">port</replaceable></option></term>      <term><option>--port=<replaceable class="parameter">port</replaceable></option></term>      <listitem>       <para>        Specifies the TCP port or local Unix domain socket file        extension on which the server is listening for connections.        Defaults to the <envar>PGPORT</envar> environment variable, if        set, or a compiled-in default.       </para>      </listitem>     </varlistentry>     <varlistentry>      <term><option>-U <replaceable>username</replaceable></option></term>      <term><option>--username=<replaceable class="parameter">username</replaceable></option></term>      <listitem>       <para>        User name to connect as.       </para>      </listitem>     </varlistentry>     <varlistentry>      <term><option>-W</option></term>      <term><option>--password</option></term>      <listitem>       <para>        Force <application>pg_dump</application> to prompt for a        password before connecting to a database.         </para>       <para>        This option is never essential, since        <application>pg_dump</application> will automatically prompt        for a password if the server demands password authentication.        However, <application>pg_dump</application> will waste a        connection attempt finding out that the server wants a password.        In some cases it is worth typing <option>-W</> to avoid the extra        connection attempt.       </para>      </listitem>     </varlistentry>    </variablelist>   </para> </refsect1> <refsect1>  <title>Environment</title>  <variablelist>   <varlistentry>    <term><envar>PGDATABASE</envar></term>    <term><envar>PGHOST</envar></term>    <term><envar>PGPORT</envar></term>    <term><envar>PGUSER</envar></term>    <listitem>     <para>      Default connection parameters.     </para>    </listitem>   </varlistentry>  </variablelist>  <para>   This utility, like most other <productname>PostgreSQL</> utilities,   also uses the environment variables supported by <application>libpq</>   (see <xref linkend="libpq-envars">).  </para> </refsect1> <refsect1 id="app-pgdump-diagnostics">  <title>Diagnostics</title>  <para>   <application>pg_dump</application> internally executes   <command>SELECT</command> statements. If you have problems running   <application>pg_dump</application>, make sure you are able to   select information from the database using, for example, <xref   linkend="app-psql">.  Also, any default connection settings and environment   variables used by the <application>libpq</application> front-end   library will apply.  </para> </refsect1> <refsect1 id="pg-dump-notes">  <title>Notes</title>  <para>   If your database cluster has any local additions to the <literal>template1</> database,   be careful to restore the output of <application>pg_dump</application> into a   truly empty database; otherwise you are likely to get errors due to   duplicate definitions of the added objects.  To make an empty database   without any local additions, copy from <literal>template0</> not <literal>template1</>,   for example:<programlisting>CREATE DATABASE foo WITH TEMPLATE template0;</programlisting>  </para>  <para>   <application>pg_dump</application> has a limitation; when a   data-only dump is chosen and the option <option>--disable-triggers</>   is used, <application>pg_dump</application> emits commands   to disable triggers on user tables before inserting the data   and commands to re-enable them after the data has been   inserted.  If the restore is stopped in the middle, the system   catalogs might be left in the wrong state.  </para>  <para>   Members of tar archives are limited to a size less than 8 GB.   (This is an inherent limitation of the tar file format.)  Therefore   this format cannot be used if the textual representation of any one table   exceeds that size.  The total size of a tar archive and any of the   other output formats is not limited, except possibly by the   operating system.  </para>  <para>   The dump file produced by <application>pg_dump</application>   does not contain the statistics used by the optimizer to make   query planning decisions.  Therefore, it is wise to run   <command>ANALYZE</command> after restoring from a dump file   to ensure good performance.  The dump file also does not   contain any <command>ALTER DATABASE ... SET</> commands;   these settings are dumped by <xref linkend="app-pg-dumpall">,   along with database users and other installation-wide settings.  </para>  <para>   Because <application>pg_dump</application> is used to transfer data   to newer versions of <productname>PostgreSQL</>, the output of   <application>pg_dump</application> can be loaded into   newer <productname>PostgreSQL</> databases.  It also can read older   <productname>PostgreSQL</> databases.  However, it usually cannot   read newer <productname>PostgreSQL</> databases or produce dump output   that can be loaded into older database versions.  To do this, manual   editing of the dump file might be required.  </para> </refsect1> <refsect1 id="pg-dump-examples">  <title>Examples</title>  <para>   To dump a database called <literal>mydb</> into a SQL-script file:<screen><prompt>$</prompt> <userinput>pg_dump mydb &gt; db.sql</userinput></screen>  </para>  <para>   To reload such a script into a (freshly created) database named   <literal>newdb</>:<screen><prompt>$</prompt> <userinput>psql -d newdb -f db.sql</userinput></screen>  </para>  <para>   To dump a database into a custom-format archive file:<screen><prompt>$</prompt> <userinput>pg_dump -Fc mydb &gt; db.dump</userinput></screen>  </para>  <para>   To reload an archive file into a (freshly created) database named   <literal>newdb</>:<screen><prompt>$</prompt> <userinput>pg_restore -d newdb db.dump</userinput></screen>  </para>  <para>   To dump a single table named <literal>mytab</>:<screen><prompt>$</prompt> <userinput>pg_dump -t mytab mydb &gt; db.sql</userinput></screen>  </para>  <para>   To dump all tables whose names start with <literal>emp</> in the   <literal>detroit</> schema, except for the table named   <literal>employee_log</literal>:<screen><prompt>$</prompt> <userinput>pg_dump -t 'detroit.emp*' -T detroit.employee_log mydb &gt; db.sql</userinput></screen>  </para>  <para>   To dump all schemas whose names start with <literal>east</> or   <literal>west</> and end in <literal>gsm</>, excluding any schemas whose   names contain the word <literal>test</>:<screen><prompt>$</prompt> <userinput>pg_dump -n 'east*gsm' -n 'west*gsm' -N '*test*' mydb &gt; db.sql</userinput></screen>  </para>  <para>   The same, using regular expression notation to consolidate the switches:<screen><prompt>$</prompt> <userinput>pg_dump -n '(east|west)*gsm' -N '*test*' mydb &gt; db.sql</userinput></screen>  </para>  <para>   To dump all database objects except for tables whose names begin with   <literal>ts_</literal>:<screen><prompt>$</prompt> <userinput>pg_dump -T 'ts_*' mydb &gt; db.sql</userinput></screen>  </para>  <para>   To specify an upper-case or mixed-case name in <option>-t</> and related   switches, you need to double-quote the name; else it will be folded to   lower case (see <xref   linkend="APP-PSQL-patterns" endterm="APP-PSQL-patterns-title">).  But   double quotes are special to the shell, so in turn they must be quoted.   Thus, to dump a single table with a mixed-case name, you need something   like<screen><prompt>$</prompt> <userinput>pg_dump -t '"MixedCaseName"' mydb &gt; mytab.sql</userinput></screen>  </para> </refsect1> <refsect1>  <title>See Also</title>  <simplelist type="inline">   <member><xref linkend="app-pg-dumpall"></member>   <member><xref linkend="app-pgrestore"></member>   <member><xref linkend="app-psql"></member>  </simplelist> </refsect1></refentry>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -