<!--
doc/src/sgml/ref/pg_amcheck.sgml
PostgreSQL documentation
-->
<refentry id="app-pgamcheck">
<indexterm zone="app-pgamcheck">
<primary>pg_amcheck</primary>
</indexterm>
<refmeta>
<refentrytitle><application>pg_amcheck</application></refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo>Application</refmiscinfo>
</refmeta>
<refnamediv>
<refname>pg_amcheck</refname>
<refpurpose>checks for corruption in one or more
<productname>PostgreSQL</productname> databases</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>pg_amcheck</command>
<arg rep="repeat"><replaceable>option</replaceable></arg>
<arg><replaceable>dbname</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<application>pg_amcheck</application> supports running
<xref linkend="amcheck"/>'s corruption checking functions against one or
more databases, with options to select which schemas, tables and indexes to
check, which kinds of checking to perform, and whether to perform the checks
in parallel, and if so, the number of parallel connections to establish and
use.
</para>
<para>
Only ordinary and toast table relations, materialized views, sequences, and
btree indexes are currently supported. Other relation types are silently
skipped.
</para>
<para>
If <literal>dbname</literal> is specified, it should be the name of a
single database to check, and no other database selection options should
be present. Otherwise, if any database selection options are present,
all matching databases will be checked. If no such options are present,
the default database will be checked. Database selection options include
<option>--all</option>, <option>--database</option> and
<option>--exclude-database</option>. They also include
<option>--relation</option>, <option>--exclude-relation</option>,
<option>--table</option>, <option>--exclude-table</option>,
<option>--index</option>, and <option>--exclude-index</option>,
but only when such options are used with a three-part pattern
(e.g. <option>mydb*.myschema*.myrel*</option>). Finally, they include
<option>--schema</option> and <option>--exclude-schema</option>
when such options are used with a two-part pattern
(e.g. <option>mydb*.myschema*</option>).
</para>
<para>
<replaceable>dbname</replaceable> can also be a
<link linkend="libpq-connstring">connection string</link>.
</para>
</refsect1>
<refsect1>
<title>Options</title>
<para>
The following command-line options control what is checked:
<variablelist>
<varlistentry>
<term><option>-a</option></term>
<term><option>--all</option></term>
<listitem>
<para>
Check all databases, except for any excluded via
<option>--exclude-database</option>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-d <replaceable class="parameter">pattern</replaceable></option></term>
<term><option>--database=<replaceable class="parameter">pattern</replaceable></option></term>
<listitem>
<para>
Check databases matching the specified
<link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link>,
except for any excluded by <option>--exclude-database</option>.
This option can be specified more than once.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-D <replaceable class="parameter">pattern</replaceable></option></term>
<term><option>--exclude-database=<replaceable class="parameter">pattern</replaceable></option></term>
<listitem>
<para>
Exclude databases matching the given
<link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link>.
This option can be specified more than once.
</para>
</listitem>
</varlistentry>
<varlistentry>