Home Explore Blog CI



postgresql

37th chunk of `doc/src/sgml/ref/psql-ref.sgml`
29ee31414323af162a5c242392c5c394f540b1dac56e14c90000000100000fa0
 remainder of the line is
        always taken to be the argument(s) of <command>\ev</command>, and neither
        variable interpolation nor backquote expansion are performed in the
        arguments.
        </para>
        </listitem>
      </varlistentry>


      <varlistentry id="app-psql-meta-command-f">
        <term><literal>\f [ <replaceable class="parameter">string</replaceable> ]</literal></term>

        <listitem>
        <para>
        Sets the field separator for unaligned query output. The default
        is the vertical bar (<literal>|</literal>). It is equivalent to
        <command>\pset fieldsep</command>.
        </para>
        </listitem>
      </varlistentry>


      <varlistentry id="app-psql-meta-command-g">
        <term><literal>\g [ (<replaceable class="parameter">option</replaceable>=<replaceable class="parameter">value</replaceable> [...]) ] [ <replaceable class="parameter">filename</replaceable> ]</literal></term>
        <term><literal>\g [ (<replaceable class="parameter">option</replaceable>=<replaceable class="parameter">value</replaceable> [...]) ] [ |<replaceable class="parameter">command</replaceable> ]</literal></term>
        <listitem>
        <para>
        Sends the current query buffer to the server for execution.
        </para>
        <para>
        If parentheses appear after <literal>\g</literal>, they surround a
        space-separated list
        of <replaceable class="parameter">option</replaceable><literal>=</literal><replaceable class="parameter">value</replaceable>
        formatting-option clauses, which are interpreted in the same way
        as <literal>\pset</literal>
        <replaceable class="parameter">option</replaceable>
        <replaceable class="parameter">value</replaceable> commands, but take
        effect only for the duration of this query.  In this list, spaces are
        not allowed around <literal>=</literal> signs, but are required
        between option clauses.
        If <literal>=</literal><replaceable class="parameter">value</replaceable>
        is omitted, the
        named <replaceable class="parameter">option</replaceable> is changed
        in the same way as for
        <literal>\pset</literal> <replaceable class="parameter">option</replaceable>
        with no explicit <replaceable class="parameter">value</replaceable>.
        </para>
        <para>
        If a <replaceable class="parameter">filename</replaceable>
        or <literal>|</literal><replaceable class="parameter">command</replaceable>
        argument is given, the query's output is written to the named
        file or piped to the given shell command, instead of displaying it as
        usual.  The file or command is written to only if the query
        successfully returns zero or more tuples, not if the query fails or
        is a non-data-returning SQL command.
        </para>
        <para>
        If the current query buffer is empty, the most recently sent query is
        re-executed instead.  Except for that behavior, <literal>\g</literal>
        without any arguments is essentially equivalent to a semicolon.
        With arguments, <literal>\g</literal> provides
        a <quote>one-shot</quote> alternative to the <command>\o</command>
        command, and additionally allows one-shot adjustments of the
        output formatting options normally set by <literal>\pset</literal>.
        </para>
        <para>
        When the last argument begins with <literal>|</literal>, the entire
        remainder of the line is taken to be
        the <replaceable class="parameter">command</replaceable> to execute,
        and neither variable interpolation nor backquote expansion are
        performed in it.  The rest of the line is simply passed literally to
        the shell.
        </para>
        </listitem>
      </varlistentry>


      <varlistentry id="app-psql-meta-command-gdesc">
        <term><literal>\gdesc</literal></term>

        <listitem>
        <para>
   

Title: psql Meta-Commands: \f and \g
Summary
This section details the `psql` meta-commands `\f` and `\g`. * `\f`: Sets the field separator for unaligned query output. It's equivalent to `\pset fieldsep`. * `\g`: Sends the current query buffer to the server for execution. It allows specifying formatting options via parentheses (similar to `\pset`) that apply only to the current query. The output can be written to a file or piped to a shell command. If the query buffer is empty, the most recent query is re-executed. When the last argument begins with `|`, the rest of the line is taken to be the command to execute.