Home Explore Blog CI



postgresql

48th chunk of `doc/src/sgml/ref/psql-ref.sgml`
fcd72de2a3e56a18f1a66ae547f82d76b54d701d2af373a30000000100000fa7
 which will enable or disable display of the table footer
          (the <literal>(<replaceable>n</replaceable> rows)</literal> count).
          If <replaceable class="parameter">value</replaceable> is omitted the
          command toggles footer display on or off.
          </para>
          </listitem>
          </varlistentry>

          <varlistentry id="app-psql-meta-command-pset-format">
          <term><literal>format</literal></term>
          <listitem>
          <para>
          Sets the output format to one of <literal>aligned</literal>,
          <literal>asciidoc</literal>,
          <literal>csv</literal>,
          <literal>html</literal>,
          <literal>latex</literal>,
          <literal>latex-longtable</literal>, <literal>troff-ms</literal>,
          <literal>unaligned</literal>, or <literal>wrapped</literal>.
          Unique abbreviations are allowed.
          </para>

          <para><literal>aligned</literal> format is the standard,
          human-readable, nicely formatted text output; this is the default.
          </para>

          <para><literal>unaligned</literal> format writes all columns of a row on one
          line, separated by the currently active field separator. This
          is useful for creating output that might be intended to be read
          in by other programs, for example, tab-separated or comma-separated
          format.  However, the field separator character is not treated
          specially if it appears in a column's value;
          so <acronym>CSV</acronym> format may be better suited for such
          purposes.
          </para>

          <para><literal>csv</literal> format
          <indexterm>
           <primary>CSV (Comma-Separated Values) format</primary>
           <secondary>in psql</secondary>
          </indexterm>
          writes column values separated by commas, applying the quoting
          rules described in
          <ulink url="https://datatracker.ietf.org/doc/html/rfc4180">RFC 4180</ulink>.
          This output is compatible with the CSV format of the server's
          <command>COPY</command> command.
          A header line with column names is generated unless
          the <literal>tuples_only</literal> parameter is
          <literal>on</literal>. Titles and footers are not printed.
          Each row is terminated by the system-dependent end-of-line character,
          which is typically a single newline (<literal>\n</literal>) for
          Unix-like systems or a carriage return and newline sequence
          (<literal>\r\n</literal>) for Microsoft Windows.
          Field separator characters other than comma can be selected with
          <command>\pset csv_fieldsep</command>.
          </para>

          <para><literal>wrapped</literal> format is like <literal>aligned</literal> but wraps
          wide data values across lines to make the output fit in the target
          column width.  The target width is determined as described under
          the <literal>columns</literal> option.  Note that <application>psql</application> will
          not attempt to wrap column header titles; therefore,
          <literal>wrapped</literal> format behaves the same as <literal>aligned</literal>
          if the total width needed for column headers exceeds the target.
          </para>

          <para>
          The <literal>asciidoc</literal>, <literal>html</literal>,
          <literal>latex</literal>, <literal>latex-longtable</literal>, and
          <literal>troff-ms</literal> formats put out tables that are intended
          to be included in documents using the respective mark-up
          language. They are not complete documents! This might not be
          necessary in <acronym>HTML</acronym>, but in
          <application>LaTeX</application> you must have a complete
          document wrapper.
          The <literal>latex</literal> format
          uses <application>LaTeX</application>'s <literal>tabular</literal>
          environment.

Title: psql Meta-Command \pset: Format Options (Aligned, Unaligned, CSV, Wrapped)
Summary
This section describes the `format` option of the `\pset` meta-command in psql, which is used to set the output format of query results. The described formats are: `aligned` (standard, human-readable), `unaligned` (columns on one line, separated by the field separator), `csv` (comma-separated values, RFC 4180 compatible), and `wrapped` (like aligned, but wraps wide data values across lines).