📄 psql-ref.sgml
字号:
wherever the <command>COPY</command> itself came from (for example, a script run with the <option>-f</option> option), and <literal>stdout</literal> refers to the query output stream (see <command>\o</command> meta-command below). </para> </note> </listitem> </varlistentry> <varlistentry> <term><literal>\copyright</literal></term> <listitem> <para> Shows the copyright and distribution terms of <application>PostgreSQL</application>. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\d</literal> [ <replaceable class="parameter">pattern</replaceable> ]</term> <listitem> <para> For each relation (table, view, index, or sequence) matching the <replaceable class="parameter">pattern</replaceable>, show all columns, their types, and any special attributes such as <literal>NOT NULL</literal> or defaults, if any. Associated indexes, constraints, rules, and triggers are also shown, as is the view definition if the relation is a view. (<quote>Matching the pattern</> is defined below.) </para> <para> The command form <literal>\d+</literal> is identical, but any comments associated with the table columns are shown as well. </para> <note> <para> If <command>\d</command> is used without a <replaceable class="parameter">pattern</replaceable> argument, it is equivalent to <command>\dtvs</command> which will show a list of all tables, views, and sequences. This is purely a convenience measure. </para> </note> </listitem> </varlistentry> <varlistentry> <term><literal>\da</literal> [ <replaceable class="parameter">pattern</replaceable> ]</term> <listitem> <para> Lists all available aggregate functions, together with the data type they operate on. If <replaceable class="parameter">pattern</replaceable> is specified, only aggregates whose names match the pattern are shown. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\dc</literal> [ <replaceable class="parameter">pattern</replaceable> ]</term> <listitem> <para> Lists all available conversions between character-set encodings. If <replaceable class="parameter">pattern</replaceable> is specified, only conversions whose names match the pattern are listed. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\dC</literal></term> <listitem> <para> Lists all available type casts. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\dd</literal> [ <replaceable class="parameter">pattern</replaceable> ]</term> <listitem> <para> Shows the descriptions of objects matching the <replaceable class="parameter">pattern</replaceable>, or of all visible objects if no argument is given. But in either case, only objects that have a description are listed. (<quote>Object</quote> covers aggregates, functions, operators, types, relations (tables, views, indexes, sequences, large objects), rules, and triggers.) For example:<programlisting>=> <userinput>\dd version</userinput> Object descriptions Schema | Name | Object | Description------------+---------+----------+--------------------------- pg_catalog | version | function | PostgreSQL version string(1 row)</programlisting> </para> <para> Descriptions for objects can be created with the <command>COMMENT</command> <acronym>SQL</acronym> command. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\dD</literal> [ <replaceable class="parameter">pattern</replaceable> ]</term> <listitem> <para> Lists all available domains. If <replaceable class="parameter">pattern</replaceable> is specified, only matching domains are shown. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\df [ <replaceable class="parameter">pattern</replaceable> ]</literal></term> <listitem> <para> Lists available functions, together with their argument and return types. If <replaceable class="parameter">pattern</replaceable> is specified, only functions whose names match the pattern are shown. If the form <literal>\df+</literal> is used, additional information about each function, including language and description, is shown. </para> <note> <para> To reduce clutter, <literal>\df</> does not show data type I/O functions. This is implemented by ignoring functions that accept or return type <type>cstring</>. </para> </note> </listitem> </varlistentry> <varlistentry> <term><literal>\distvS [ <replaceable class="parameter">pattern</replaceable> ]</literal></term> <listitem> <para> This is not the actual command name: the letters i, s, t, v, S stand for index, sequence, table, view, and system table, respectively. You can specify any or all of these letters, in any order, to obtain a listing of all the matching objects. The letter S restricts the listing to system objects; without S, only non-system objects are shown. If <literal>+</literal> is appended to the command name, each object is listed with its associated description, if any. </para> <para> If <replaceable class="parameter">pattern</replaceable> is specified, only objects whose names match the pattern are listed. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\dl</literal></term> <listitem> <para> This is an alias for <command>\lo_list</command>, which shows a list of large objects. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\dn</literal> [ <replaceable class="parameter">pattern</replaceable> ]</term> <listitem> <para> Lists all available schemas (namespaces). If <replaceable class="parameter">pattern</replaceable> (a regular expression) is specified, only schemas whose names match the pattern are listed. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\do [ <replaceable class="parameter">pattern</replaceable> ]</literal></term> <listitem> <para> Lists available operators with their operand and return types. If <replaceable class="parameter">pattern</replaceable> is specified, only operators whose names match the pattern are listed. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\dp</literal> [ <replaceable class="parameter">pattern</replaceable> ]</term> <listitem> <para> Produces a list of all available tables with their associated access privileges. If <replaceable class="parameter">pattern</replaceable> is specified, only tables whose names match the pattern are listed. </para> <para> The commands <xref linkend="SQL-GRANT"> and <xref linkend="SQL-REVOKE"> are used to set access privileges. See <xref linkend="SQL-GRANT"> for more information. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\dT [ <replaceable class="parameter">pattern</replaceable> ]</literal></term> <listitem> <para> Lists all data types or only those that match <replaceable class="parameter">pattern</replaceable>. The command form <literal>\dT+</literal> shows extra information. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\du [ <replaceable class="parameter">pattern</replaceable> ]</literal></term> <listitem> <para> Lists all database users or only those that match <replaceable class="parameter">pattern</replaceable>. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\edit</literal> (or <literal>\e</literal>) [ <replaceable class="parameter">filename</replaceable> ]</term> <listitem> <para> If <replaceable class="parameter">filename</replaceable> is specified, the file is edited; after the editor exits, its content is copied back to the query buffer. If no argument is given, the current query buffer is copied to a temporary file which is then edited in the same fashion. </para> <para> The new query buffer is then re-parsed according to the normal rules of <application>psql</application>, where the whole buffer is treated as a single line. (Thus you cannot make scripts this way. Use <command>\i</command> for that.) This means also that if the query ends with (or rather contains) a semicolon, it is immediately executed. In other cases it will merely wait in the query buffer. </para> <tip> <para> <application>psql</application> searches the environment variables <envar>PSQL_EDITOR</envar>, <envar>EDITOR</envar>, and <envar>VISUAL</envar> (in that order) for an editor to use. If all of them are unset, <filename>/bin/vi</filename> is run. </para> </tip> </listitem> </varlistentry> <varlistentry> <term><literal>\echo</literal> <replaceable class="parameter">text</replaceable> [ ... ]</term> <listitem> <para> Prints the arguments to the standard output, separated by one space and followed by a newline. This can be useful to intersperse information in the output of scripts. For example:<programlisting>=> <userinput>\echo `date`</userinput>Tue Oct 26 21:40:57 CEST 1999</programlisting> If the first argument is an unquoted <literal>-n</literal> the the trailing newline is not written. </para> <tip> <para> If you use the <command>\o</command> command to redirect your query output you may wish to use <command>\qecho</command> instead of this command. </para> </tip> </listitem> </varlistentry> <varlistentry> <term><literal>\encoding</literal> [ <replaceable class="parameter">encoding</replaceable> ]</term> <listitem> <para> Sets the client character set encoding. Without an argument, this command shows the current encoding. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\f</literal> [ <replaceable class="parameter">string</replaceable> ]</term> <listitem> <para> Sets the field separator for unaligned query output. The default is the vertical bar (<literal>|</literal>). See also <command>\pset</command> for a generic way of setting output options. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\g</literal> [ { <replaceable class="parameter">filename</replaceable> | <literal>|</literal><replaceable class="parameter">command</replaceable> } ]</term> <listitem> <para> Sends the current query input buffer to the server and optionally saves the output in <replaceable class="parameter">filename</replaceable> or pipes the output into a separate Unix shell to execute <replaceable class="parameter">command</replaceable>. A bare <literal>\g</literal> is virtually equivalent to a semicolon. A <literal>\g</literal> with argument is a <quote>one-shot</quote> alternative to the <command>\o</command> command. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\help</literal> (or <literal>\h</literal>) [ <replaceable class="parameter">command</replaceable> ]</term> <listitem> <para> Gives syntax help on the specified <acronym>SQL</acronym> command. If <replaceable class="parameter">command</replaceable> is not specified, then <application>psql</application> will list all the commands for which syntax help is available. If <replaceable class="parameter">command</replaceable> is an asterisk (<literal>*</literal>), then syntax help on all <acronym>SQL</acronym> commands is shown. </para> <note> <para> To simplify typing, commands that consists of several words do not have to be quoted. Thus it is fine to type <userinput>\help
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -