📄 psql-ref.sgml
字号:
<listitem> <para> If the current table output format is unaligned, it is switched to aligned. If it is not unaligned, it is set to unaligned. This command is kept for backwards compatibility. See <command>\pset</command> for a more general solution. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\cd [ <replaceable>directory</replaceable> ]</literal></term> <listitem> <para> Changes the current working directory to <replaceable>directory</replaceable>. Without argument, changes to the current user's home directory. </para> <tip> <para> To print your current working directory, use <literal>\!pwd</literal>. </para> </tip> </listitem> </varlistentry> <varlistentry> <term><literal>\C [ <replaceable class="parameter">title</replaceable> ]</literal></term> <listitem> <para> Sets the title of any tables being printed as the result of a query or unset any such title. This command is equivalent to <literal>\pset title <replaceable class="parameter">title</replaceable></literal>. (The name of this command derives from <quote>caption</quote>, as it was previously only used to set the caption in an <acronym>HTML</acronym> table.) </para> </listitem> </varlistentry> <varlistentry> <term><literal>\connect</literal> (or <literal>\c</literal>) <literal>[ <replaceable class="parameter">dbname</replaceable> [ <replaceable class="parameter">username</replaceable> ] [ <replaceable class="parameter">host</replaceable> ] [ <replaceable class="parameter">port</replaceable> ] ]</literal></term> <listitem> <para> Establishes a new connection to a <productname>PostgreSQL</> server. If the new connection is successfully made, the previous connection is closed. If any of <replaceable class="parameter">dbname</replaceable>, <replaceable class="parameter">username</replaceable>, <replaceable class="parameter">host</replaceable> or <replaceable class="parameter">port</replaceable> are omitted or specified as <literal>-</literal>, the value of that parameter from the previous connection is used. If there is no previous connection, the <application>libpq</application> default for the parameter's value is used. </para> <para> If the connection attempt failed (wrong user name, access denied, etc.), the previous connection will only be kept if <application>psql</application> is in interactive mode. When executing a non-interactive script, processing will immediately stop with an error. This distinction was chosen as a user convenience against typos on the one hand, and a safety mechanism that scripts are not accidentally acting on the wrong database on the other hand. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\copy { <replaceable class="parameter">table</replaceable> [ ( <replaceable class="parameter">column_list</replaceable> ) ] | ( <replaceable class="parameter">query</replaceable> ) } { <literal>from</literal> | <literal>to</literal> } { <replaceable class="parameter">filename</replaceable> | stdin | stdout | pstdin | pstdout } [ with ] [ binary ] [ oids ] [ delimiter [ as ] '<replaceable class="parameter">character</replaceable>' ] [ null [ as ] '<replaceable class="parameter">string</replaceable>' ] [ csv [ header ] [ quote [ as ] '<replaceable class="parameter">character</replaceable>' ] [ escape [ as ] '<replaceable class="parameter">character</replaceable>' ] [ force quote <replaceable class="parameter">column_list</replaceable> ] [ force not null <replaceable class="parameter">column_list</replaceable> ] ]</literal> </term> <listitem> <para> Performs a frontend (client) copy. This is an operation that runs an <acronym>SQL</acronym> <xref linkend="SQL-COPY" endterm="SQL-COPY-title"> command, but instead of the server reading or writing the specified file, <application>psql</application> reads or writes the file and routes the data between the server and the local file system. This means that file accessibility and privileges are those of the local user, not the server, and no SQL superuser privileges are required. </para> <para> The syntax of the command is similar to that of the <acronym>SQL</acronym> <xref linkend="sql-copy" endterm="sql-copy-title"> command. Note that, because of this, special parsing rules apply to the <command>\copy</command> command. In particular, the variable substitution rules and backslash escapes do not apply. </para> <para> <literal>\copy ... from stdin | to stdout</literal> reads/writes based on the command input and output respectively. All rows are read from the same source that issued the command, continuing until <literal>\.</literal> is read or the stream reaches <acronym>EOF</>. Output is sent to the same place as command output. To read/write from <application>psql</application>'s standard input or output, use <literal>pstdin</> or <literal>pstdout</>. This option is useful for populating tables in-line within a SQL script file. </para> <tip> <para> This operation is not as efficient as the <acronym>SQL</acronym> <command>COPY</command> command because all data must pass through the client/server connection. For large amounts of data the <acronym>SQL</acronym> command might be preferable. </para> </tip> </listitem> </varlistentry> <varlistentry> <term><literal>\copyright</literal></term> <listitem> <para> Shows the copyright and distribution terms of <productname>PostgreSQL</productname>. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\d [ <replaceable class="parameter">pattern</replaceable> ]</literal></term> <term><literal>\d+ [ <replaceable class="parameter">pattern</replaceable> ]</literal></term> <listitem> <para> For each relation (table, view, index, or sequence) matching the <replaceable class="parameter">pattern</replaceable>, show all columns, their types, the tablespace (if not the default) 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, except that more information is displayed: any comments associated with the columns of the table are shown, as is the presence of OIDs in the table. </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 [ <replaceable class="parameter">pattern</replaceable> ]</literal></term> <listitem> <para> Lists all available aggregate functions, together with their return type and the data types 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>\db [ <replaceable class="parameter">pattern</replaceable> ]</literal></term> <term><literal>\db+ [ <replaceable class="parameter">pattern</replaceable> ]</literal></term> <listitem> <para> Lists all available tablespaces. If <replaceable class="parameter">pattern</replaceable> is specified, only tablespaces whose names match the pattern are shown. If <literal>+</literal> is appended to the command name, each object is listed with its associated permissions. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\dc [ <replaceable class="parameter">pattern</replaceable> ]</literal></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 [ <replaceable class="parameter">pattern</replaceable> ]</literal></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 <xref linkend="sql-comment" endterm="sql-comment-title"> <acronym>SQL</acronym> command. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\dD [ <replaceable class="parameter">pattern</replaceable> ]</literal></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> <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 volatility, language, source code and description, is shown. </para> <note> <para> To look up functions taking argument or returning values of a specific type, use your pager's search capability to scroll through the <literal>\df</> output. </para> <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>\dF [ <replaceable class="parameter">pattern</replaceable> ]</literal></term> <term><literal>\dF+ [ <replaceable class="parameter">pattern</replaceable> ]</literal></term> <listitem> <para> Lists available text search configurations. If <replaceable class="parameter">pattern</replaceable> is specified, only configurations whose names match the pattern are shown. If the form <literal>\dF+</literal> is used, a full description of each configuration is shown, including the underlying text search parser and the dictionary list for each parser token type. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\dFd [ <replaceable class="parameter">pattern</replaceable> ]</literal></term> <term><literal>\dFd+ [ <replaceable class="parameter">pattern</replaceable> ]</literal></term> <listitem> <para> Lists available text search dictionaries. If <replaceable class="parameter">pattern</replaceable> is specified, only dictionaries whose names match the pattern are shown. If the form <literal>\dFd+</literal> is used, additional information is shown about each selected dictionary, including the underlying text search template and the option values. </para> </listitem> </varlistentry> <varlistentry> <term><literal>\dFp [ <replaceable class="parameter">pattern</replaceable> ]</literal></term>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -