📄 psql-ref.sgml
字号:
<quote>Aligned</quote> mode is the standard, human-readable, nicely formatted text output that is default. The <quote><acronym>HTML</acronym></quote> and <quote>LaTeX</quote> modes 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 so dramatic in <acronym>HTML</acronym>, but in LaTeX you must have a complete document wrapper.) </para> </listitem> </varlistentry> <varlistentry> <term><literal>border</literal></term> <listitem> <para> The second argument must be a number. In general, the higher the number the more borders and lines the tables will have, but this depends on the particular format. In <acronym>HTML</acronym> mode, this will translate directly into the <literal>border=...</literal> attribute, in the others only values 0 (no border), 1 (internal dividing lines), and 2 (table frame) make sense. </para> </listitem> </varlistentry> <varlistentry> <term><literal>expanded</literal> (or <literal>x</literal>)</term> <listitem> <para> Toggles between regular and expanded format. When expanded format is enabled, query results are displayed in two columns, with the column name on the left and the data on the right. This mode is useful if the data wouldn't fit on the screen in the normal <quote>horizontal</quote> mode. </para> <para> Expanded mode is supported by all four output formats. </para> </listitem> </varlistentry> <varlistentry> <term><literal>null</literal></term> <listitem> <para> The second argument is a string that should be printed whenever a column is null. The default is not to print anything, which can easily be mistaken for, say, an empty string. Thus, one might choose to write <literal>\pset null '(null)'</literal>. </para> </listitem> </varlistentry> <varlistentry> <term><literal>fieldsep</literal></term> <listitem> <para> Specifies the field separator to be used in unaligned output mode. That way one can create, for example, tab- or comma-separated output, which other programs might prefer. To set a tab as field separator, type <literal>\pset fieldsep '\t'</literal>. The default field separator is <literal>'|'</literal> (a vertical bar). </para> </listitem> </varlistentry> <varlistentry> <term><literal>footer</literal></term> <listitem> <para> Toggles the display of the default footer <literal>(x rows)</literal>. </para> </listitem> </varlistentry> <varlistentry> <term><literal>numericlocale</literal></term> <listitem> <para> Toggles the display of a locale-aware character to separate groups of digits to the left of the decimal marker. It also enables a locale-aware decimal marker. </para> </listitem> </varlistentry> <varlistentry> <term><literal>recordsep</literal></term> <listitem> <para> Specifies the record (line) separator to use in unaligned output mode. The default is a newline character. </para> </listitem> </varlistentry> <varlistentry> <term><literal>tuples_only</literal> (or <literal>t</literal>)</term> <listitem> <para> Toggles between tuples only and full display. Full display may show extra information such as column headers, titles, and various footers. In tuples only mode, only actual table data is shown. </para> </listitem> </varlistentry> <varlistentry> <term><literal>title [ <replaceable class="parameter">text</replaceable> ]</literal></term> <listitem> <para> Sets the table title for any subsequently printed tables. This can be used to give your output descriptive tags. If no argument is given, the title is unset. </para> </listitem> </varlistentry> <varlistentry> <term><literal>tableattr</literal> (or <literal>T</literal>) <literal>[ <replaceable class="parameter">text</replaceable> ]</literal></term> <listitem> <para> Allows you to specify any attributes to be placed inside the <acronym>HTML</acronym> <sgmltag>table</sgmltag> tag. This could for example be <literal>cellpadding</literal> or <literal>bgcolor</literal>. Note that you probably don't want to specify <literal>border</literal> here, as that is already taken care of by <literal>\pset border</literal>. </para> </listitem> </varlistentry> <varlistentry> <term><literal>pager</literal></term> <listitem> <para> Controls use of a pager for query and <application>psql</> help output. If the environment variable <envar>PAGER</envar> is set, the output is piped to the specified program. Otherwise a platform-dependent default (such as <filename>more</filename>) is used. </para> <para> When the pager is off, the pager is not used. When the pager is on, the pager is used only when appropriate, i.e. the output is to a terminal and will not fit on the screen. (<application>psql</> does not do a perfect job of estimating when to use the pager.) <literal>\pset pager</> turns the pager on and off. Pager can also be set to <literal>always</>, which causes the pager to be always used. </para> </listitem> </varlistentry> </variablelist> </para> <para> Illustrations on how these different formats look can be seen in the <xref linkend="APP-PSQL-examples" endterm="APP-PSQL-examples-title"> section. </para> <tip> <para> There are various shortcut commands for <command>\pset</command>. See <command>\a</command>, <command>\C</command>, <command>\H</command>, <command>\t</command>, <command>\T</command>, and <command>\x</command>. </para> </tip> <note> <para> It is an error to call <command>\pset</command> without arguments. In the future this call might show the current status of all printing options. </para> </note> </listitem> </varlistentry> <varlistentry> <term><literal>\q</literal></term> <listitem> <para> Quits the <application>psql</application> program. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\qecho <replaceable class="parameter">text</replaceable> [ ... ] </literal></term> <listitem> <para> This command is identical to <command>\echo</command> except that the output will be written to the query output channel, as set by <command>\o</command>. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\r</literal></term> <listitem> <para> Resets (clears) the query buffer. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\s [ <replaceable class="parameter">filename</replaceable> ]</literal></term> <listitem> <para> Print or save the command line history to <replaceable class="parameter">filename</replaceable>. If <replaceable class="parameter">filename</replaceable> is omitted, the history is written to the standard output. This option is only available if <application>psql</application> is configured to use the <acronym>GNU</acronym> <application>Readline</application> library. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\set [ <replaceable class="parameter">name</replaceable> [ <replaceable class="parameter">value</replaceable> [ ... ] ] ]</literal></term> <listitem> <para> Sets the internal variable <replaceable class="parameter">name</replaceable> to <replaceable class="parameter">value</replaceable> or, if more than one value is given, to the concatenation of all of them. If no second argument is given, the variable is just set with no value. To unset a variable, use the <command>\unset</command> command. </para> <para> Valid variable names can contain characters, digits, and underscores. See the section <xref linkend="APP-PSQL-variables" endterm="APP-PSQL-variables-title"> below for details. Variable names are case-sensitive. </para> <para> Although you are welcome to set any variable to anything you want, <application>psql</application> treats several variables as special. They are documented in the section about variables. </para> <note> <para> This command is totally separate from the <acronym>SQL</acronym> command <xref linkend="SQL-SET" endterm="SQL-SET-title">. </para> </note> </listitem> </varlistentry> <varlistentry> <term><literal>\t</literal></term> <listitem> <para> Toggles the display of output column name headings and row count footer. This command is equivalent to <literal>\pset tuples_only</literal> and is provided for convenience. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\T <replaceable class="parameter">table_options</replaceable></literal></term> <listitem> <para> Allows you to specify attributes to be placed within the <sgmltag>table</sgmltag> tag in <acronym>HTML</acronym> tabular output mode. This command is equivalent to <literal>\pset tableattr <replaceable class="parameter">table_options</replaceable></literal>. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\timing</literal></term> <listitem> <para> Toggles a display of how long each SQL statement takes, in milliseconds. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\w</literal> {<replaceable class="parameter">filename</replaceable> | <replaceable class="parameter">|command</replaceable>}</term> <listitem> <para> Outputs the current query buffer to the file <replaceable class="parameter">filename</replaceable> or pipes it to the Unix command <replaceable class="parameter">command</replaceable>. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\x</literal></term> <listitem> <para> Toggles expanded table formatting mode. As such it is equivalent to <literal>\pset expanded</literal>. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\z [ <replaceable class="parameter">pattern</replaceable> ]</literal></term> <listitem> <para> Produces a list of all available tables, views and sequences with their associated access privileges. If a <replaceable class="parameter">pattern</replaceable> is specified, only tables,views and sequences whose names match the pattern are listed. </para> <para> The commands <command>GRANT</command> and <command>REVOKE</command> are used to set access privileges. See <xref linkend="sql-grant" endterm="sql-grant-title"> for more information. </para>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -