format options can be set for just one query by using
<literal>\g</literal>:
<programlisting>
peter@localhost testdb=> <userinput>SELECT * FROM my_table</userinput>
peter@localhost testdb-> <userinput>\g (format=aligned tuples_only=off expanded=on)</userinput>
-[ RECORD 1 ]-
first | 1
second | one
-[ RECORD 2 ]-
first | 2
second | two
-[ RECORD 3 ]-
first | 3
second | three
-[ RECORD 4 ]-
first | 4
second | four
</programlisting>
</para>
<para>
Here is an example of using the <command>\df</command> command to
find only functions with names matching <literal>int*pl</literal>
and whose second argument is of type <type>bigint</type>:
<programlisting>
testdb=> <userinput>\df int*pl * bigint</userinput>
List of functions
Schema | Name | Result data type | Argument data types | Type
------------+---------+------------------+---------------------+------
pg_catalog | int28pl | bigint | smallint, bigint | func
pg_catalog | int48pl | bigint | integer, bigint | func
pg_catalog | int8pl | bigint | bigint, bigint | func
(3 rows)
</programlisting>
</para>
<para>
Here, the <literal>+</literal> option is used to display additional
information about one of these functions, and <literal>x</literal> is used
to display the results in expanded mode:
<programlisting>
testdb=> <userinput>\df+x int*pl integer bigint</userinput>
List of functions
-[ RECORD 1 ]-------+-----------------------------
Schema | pg_catalog
Name | int48pl
Result data type | bigint
Argument data types | integer, bigint
Type | func
Volatility | immutable
Parallel | safe
Owner | postgres
Security | invoker
Leakproof? | no
Access privileges |
Language | internal
Internal name | int48pl
Description | implementation of + operator
</programlisting>
</para>
<para>
When suitable, query results can be shown in a crosstab representation
with the <command>\crosstabview</command> command:
<programlisting>
testdb=> <userinput>SELECT first, second, first > 2 AS gt2 FROM my_table;</userinput>
first | second | gt2
-------+--------+-----
1 | one | f
2 | two | f
3 | three | t
4 | four | t
(4 rows)
testdb=> <userinput>\crosstabview first second</userinput>
first | one | two | three | four
-------+-----+-----+-------+------
1 | f | | |
2 | | f | |
3 | | | t |
4 | | | | t
(4 rows)
</programlisting>
This second example shows a multiplication table with rows sorted in reverse
numerical order and columns with an independent, ascending numerical order.
<programlisting>
testdb=> <userinput>SELECT t1.first as "A", t2.first+100 AS "B", t1.first*(t2.first+100) as "AxB",</userinput>
testdb-> <userinput>row_number() over(order by t2.first) AS ord</userinput>
testdb-> <userinput>FROM my_table t1 CROSS JOIN my_table t2 ORDER BY 1 DESC</userinput>
testdb-> <userinput>\crosstabview "A" "B" "AxB" ord</userinput>
A | 101 | 102 | 103 | 104
---+-----+-----+-----+-----
4 | 404 | 408 | 412 | 416
3 | 303 | 306 | 309 | 312
2 | 202 | 204 | 206 | 208
1 | 101 | 102 | 103 | 104
(4 rows)
</programlisting></para>
</refsect1>
</refentry>