↑↓ 选择↵ 打开⌫ 切换范围完整搜索

PG.CENTER 连接 PostgreSQL 文档、百科与生态知识。由 Pigsty 维护。

Wiki / psql 命令

PostgreSQL 版本定义:18

当前阅读 PG 18·选择有来源记录的版本

130 / 130 条已记录定义实心方块表示该版本有定义;选择方块可阅读对应版本。
  • \!Scripting and assistance10 – 20

    With no argument, escapes to a sub-shell; psql resumes when the sub-shell exits. With an argument, executes the shell command command .

    此定义以英文显示

  • \;Query execution11 – 20

    Backslash-semicolon is not a meta-command in the same way as the preceding commands; rather, it simply causes a semicolon to be added to the query buffer without any further processing.

    此定义以英文显示

  • \?Scripting and assistance10 – 20

    Shows help information. The optional topic parameter (defaulting to commands ) selects which part of psql is explained: commands describes psql 's backslash commands; options describes the command-line options that can be passed to psql ; and variables shows help about psql configuration variables.

    此定义以英文显示

  • \COutput and formatting10 – 20

    Sets the title of any tables being printed as the result of a query or unset any such title. This command is equivalent to \pset title title . (The name of this command derives from “ caption ” , as it was previously only used to set the caption in an HTML table.)

    此定义以英文显示

  • \HOutput and formatting10 – 20

    Turns on HTML query output format. If the HTML format is already on, it is switched back to the default aligned text format. This command is for compatibility and convenience, but see \pset about setting other output options.

    此定义以英文显示

  • \TOutput and formatting10 – 20

    Specifies attributes to be placed within the table tag in HTML output format. This command is equivalent to \pset tableattr table_options .

    此定义以英文显示

  • \aOutput and formatting10 – 20

    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 \pset for a more general solution.

    此定义以英文显示

  • \bindQuery execution16 – 20

    Sets query parameters for the next query execution, with the specified parameters passed for any parameter placeholders ( $1 etc.).

    此定义以英文显示

    1011121314151617181920
  • \bind_namedQuery execution18 – 20

    \bind_named is equivalent to \bind , except that it takes the name of an existing prepared statement as first parameter. An empty string denotes the unnamed prepared statement.

    此定义以英文显示

    1011121314151617181920
  • \cConnections and sessions10 – 20

    Establishes a new connection to a PostgreSQL server. The connection parameters to use can be specified either using a positional syntax (one or more of database name, user, host, and port), or using a conninfo connection string as detailed in Section 32.1.1 . If no arguments are given, a new connection is made using the same parameters as before.

    此定义以英文显示

  • \cdScripting and assistance10 – 20

    Changes the current working directory to directory . Without argument, changes to the current user's home directory. For details on how home directories are found, see Section 32.16 .

    此定义以英文显示

  • \close_preparedQuery execution18 – 20

    Closes the specified prepared statement. An empty string denotes the unnamed prepared statement. If no prepared statement exists with this name, the operation is a no-op.

    此定义以英文显示

    1011121314151617181920
  • \connectConnections and sessions10 – 20

    Establishes a new connection to a PostgreSQL server. The connection parameters to use can be specified either using a positional syntax (one or more of database name, user, host, and port), or using a conninfo connection string as detailed in Section 32.1.1 . If no arguments are given, a new connection is made using the same parameters as before.

    此定义以英文显示

  • \conninfoConnections and sessions10 – 20

    Outputs information about the current database connection, including SSL-related information if SSL is in use.

    此定义以英文显示

  • \copyData transfer and large objects10 – 20

    Performs a frontend (client) copy. This is an operation that runs an SQL COPY command, but instead of the server reading or writing the specified file, psql 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.

    此定义以英文显示

  • \copyrightScripting and assistance10 – 20

    Shows the copyright and distribution terms of PostgreSQL .

    此定义以英文显示

  • \crosstabviewOutput and formatting10 – 20

    Executes the current query buffer (like \g ) and shows the results in a crosstab grid. The query must return at least three columns. The output column identified by colV becomes a vertical header and the output column identified by colH becomes a horizontal header. colD identifies the output column to display within the grid. sortcolH identifies an optional sort column for the horizontal header.

    此定义以英文显示

  • \dDescribe database objects10 – 20

    For each relation (table, view, materialized view, index, sequence, or foreign table) or composite type matching the pattern , show all columns, their types, the tablespace (if not the default) and any special attributes such as NOT NULL or defaults. Associated indexes, constraints, rules, and triggers are also shown. For foreign tables, the associated foreign server is shown as well. ( “ Matching the pattern ” is defined in Patterns below.)

    此定义以英文显示

  • \dADescribe database objects10 – 20

    Lists access methods. If pattern is specified, only access methods whose names match the pattern are shown. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each access method is listed with its associated handler function and description.

    此定义以英文显示

  • \dAcDescribe database objects13 – 20

    Lists operator classes (see Section 36.16.1 ). If access-method-pattern is specified, only operator classes associated with access methods whose names match that pattern are listed. If input-type-pattern is specified, only operator classes associated with input types whose names match that pattern are listed. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each operator class is listed with its associated operator family and owner.

    此定义以英文显示

  • \dAfDescribe database objects13 – 20

    Lists operator families (see Section 36.16.5 ). If access-method-pattern is specified, only operator families associated with access methods whose names match that pattern are listed. If input-type-pattern is specified, only operator families associated with input types whose names match that pattern are listed. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each operator family is listed with its owner.

    此定义以英文显示

  • \dAoDescribe database objects13 – 20

    Lists operators associated with operator families (see Section 36.16.2 ). If access-method-pattern is specified, only members of operator families associated with access methods whose names match that pattern are listed. If operator-family-pattern is specified, only members of operator families whose names match that pattern are listed. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each operator is listed with its sort operator family (if it is an ordering operator), and whether its underlying function is leakproof.

    此定义以英文显示

  • \dApDescribe database objects13 – 20

    Lists support functions associated with operator families (see Section 36.16.3 ). If access-method-pattern is specified, only functions of operator families associated with access methods whose names match that pattern are listed. If operator-family-pattern is specified, only functions of operator families whose names match that pattern are listed. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, functions are displayed verbosely, with their actual parameter lists.

    此定义以英文显示

  • \dCDescribe database objects10 – 20

    Lists type casts. If pattern is specified, only casts whose source or target types match the pattern are listed. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, additional information about each cast is shown, including whether its underlying function is leakproof, and the cast's description.

    此定义以英文显示

  • \dDDescribe database objects10 – 20

    Lists domains. If pattern is specified, only domains whose names match the pattern are shown. By default, only user-created objects are shown; supply a pattern or the S modifier to include system objects. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each object is listed with its associated permissions and description.

    此定义以英文显示

  • \dEDescribe database objects10 – 20

    In this group of commands, the letters E , i , m , s , t , and v stand for foreign table, index, materialized view, sequence, table, and view, respectively. You can specify any or all of these letters, in any order, to obtain a listing of objects of these types. For example, \dti lists tables and indexes. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each object is listed with its persistence status (permanent, temporary, or unlogged), physical size on disk, and associated description if any. If pattern is specified, only objects whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the S modifier to include system objects.

    此定义以英文显示

  • \dFDescribe database objects10 – 20

    Lists text search configurations. If pattern is specified, only configurations whose names match the pattern are shown. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, a full description of each configuration is shown, including the underlying text search parser and the dictionary list for each parser token type.

    此定义以英文显示

  • \dFdDescribe database objects10 – 20

    Lists text search dictionaries. If pattern is specified, only dictionaries whose names match the pattern are shown. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, additional information is shown about each selected dictionary, including the underlying text search template and the option values.

    此定义以英文显示

  • \dFpDescribe database objects10 – 20

    Lists text search parsers. If pattern is specified, only parsers whose names match the pattern are shown. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, a full description of each parser is shown, including the underlying functions and the list of recognized token types.

    此定义以英文显示

  • \dFtDescribe database objects10 – 20

    Lists text search templates. If pattern is specified, only templates whose names match the pattern are shown. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, additional information is shown about each template, including the underlying function names.

    此定义以英文显示

  • \dLDescribe database objects10 – 20

    Lists procedural languages. If pattern is specified, only languages whose names match the pattern are listed. By default, only user-created languages are shown; supply the S modifier to include system objects. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each language is listed with its call handler, validator, access privileges, and whether it is a system object.

    此定义以英文显示

  • \dODescribe database objects10 – 20

    Lists collations. If pattern is specified, only collations whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the S modifier to include system objects. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each collation is listed with its associated description, if any. Note that only collations usable with the current database's encoding are shown, so the results may vary in different databases of the same installation.

    此定义以英文显示

  • \dPDescribe database objects12 – 20

    Lists partitioned relations. If pattern is specified, only entries whose name matches the pattern are listed. The modifiers t (tables) and i (indexes) can be appended to the command, filtering the kind of relations to list. By default, partitioned tables and indexes are listed.

    此定义以英文显示

  • \dRpDescribe database objects10 – 20

    Lists replication publications. If pattern is specified, only those publications whose names match the pattern are listed. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, the tables and schemas associated with each publication are shown as well.

    此定义以英文显示

  • \dRsDescribe database objects10 – 20

    Lists replication subscriptions. If pattern is specified, only those subscriptions whose names match the pattern are listed. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, additional properties of the subscriptions are shown.

    此定义以英文显示

  • \dTDescribe database objects10 – 20

    Lists data types. If pattern is specified, only types whose names match the pattern are listed. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each type is listed with its internal name and size, its allowed values if it is an enum type, and its associated permissions. By default, only user-created objects are shown; supply a pattern or the S modifier to include system objects.

    此定义以英文显示

  • \dXDescribe database objects14 – 20

    Lists extended statistics. If pattern is specified, only those extended statistics whose names match the pattern are listed. If x is appended to the command name, the results are displayed in expanded mode.

    此定义以英文显示

  • \daDescribe database objects10 – 20

    Lists aggregate functions, together with their return type and the data types they operate on. If pattern is specified, only aggregates whose names match the pattern are shown. By default, only user-created objects are shown; supply a pattern or the S modifier to include system objects. If x is appended to the command name, the results are displayed in expanded mode.

    此定义以英文显示

  • \dbDescribe database objects10 – 20

    Lists tablespaces. If pattern is specified, only tablespaces whose names match the pattern are shown. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each tablespace is listed with its associated options, on-disk size, permissions and description.

    此定义以英文显示

  • \dcDescribe database objects10 – 20

    Lists conversions between character-set encodings. If pattern is specified, only conversions whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the S modifier to include system objects. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each object is listed with its associated description.

    此定义以英文显示

  • \dconfigDescribe database objects15 – 20

    Lists server configuration parameters and their values. If pattern is specified, only parameters whose names match the pattern are listed. Without a pattern , only parameters that are set to non-default values are listed. (Use \dconfig * to see all parameters.) If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each parameter is listed with its data type, context in which the parameter can be set, and access privileges (if non-default access privileges have been granted).

    此定义以英文显示

    1011121314151617181920
  • \ddDescribe database objects10 – 20

    Shows the descriptions of objects of type constraint , operator class , operator family , rule , and trigger . All other comments may be viewed by the respective backslash commands for those object types.

    此定义以英文显示

  • \ddpDescribe database objects10 – 20

    Lists default access privilege settings. An entry is shown for each role (and schema, if applicable) for which the default privilege settings have been changed from the built-in defaults. If pattern is specified, only entries whose role name or schema name matches the pattern are listed. If x is appended to the command name, the results are displayed in expanded mode.

    此定义以英文显示

  • \desDescribe database objects10 – 20

    Lists foreign servers (mnemonic: “ external servers ” ). If pattern is specified, only those servers whose name matches the pattern are listed. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, a full description of each server is shown, including the server's access privileges, type, version, options, and description.

    此定义以英文显示

  • \detDescribe database objects10 – 20

    Lists foreign tables (mnemonic: “ external tables ” ). If pattern is specified, only entries whose table name or schema name matches the pattern are listed. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, generic options and the foreign table description are also displayed.

    此定义以英文显示

  • \deuDescribe database objects10 – 20

    Lists user mappings (mnemonic: “ external users ” ). If pattern is specified, only those mappings whose user names match the pattern are listed. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, additional information about each mapping is shown.

    此定义以英文显示

  • \dewDescribe database objects10 – 20

    Lists foreign-data wrappers (mnemonic: “ external wrappers ” ). If pattern is specified, only those foreign-data wrappers whose name matches the pattern are listed. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, the access privileges, options, and description of the foreign-data wrapper are also shown.

    此定义以英文显示

  • \dfDescribe database objects10 – 20

    Lists functions, together with their result data types, argument data types, and function types, which are classified as “ agg ” (aggregate), “ normal ” , “ procedure ” , “ trigger ” , or “ window ” . To display only functions of specific type(s), add the corresponding letters a , n , p , t , or w to the command. If pattern is specified, only functions whose names match the pattern are shown. Any additional arguments are type-name patterns, which are matched to the type names of the first, second, and so on arguments of the function. (Matching functions can have more arguments than what you specify. To prevent that, write a dash - as the last arg_pattern .) By default, only user-created objects are shown; supply a pattern or the S modifier to include system objects. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, additional information about each function is shown, including volatility, parallel safety, owner, security classification, whether it is leakproof, access privileges, language, internal name (for C and internal functions only), and description. Source code for a specific function can be seen using \sf .

    此定义以英文显示

  • \dgDescribe database objects10 – 20

    Lists database roles. (Since the concepts of “ users ” and “ groups ” have been unified into “ roles ” , this command is now equivalent to \du .) By default, only user-created roles are shown; supply the S modifier to include system roles. If pattern is specified, only those roles whose names match the pattern are listed. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, additional information is shown about each role; currently this adds the comment for each role.

    此定义以英文显示

  • \diDescribe database objects10 – 20

    In this group of commands, the letters E , i , m , s , t , and v stand for foreign table, index, materialized view, sequence, table, and view, respectively. You can specify any or all of these letters, in any order, to obtain a listing of objects of these types. For example, \dti lists tables and indexes. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each object is listed with its persistence status (permanent, temporary, or unlogged), physical size on disk, and associated description if any. If pattern is specified, only objects whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the S modifier to include system objects.

    此定义以英文显示

  • \dlDescribe database objects10 – 20

    This is an alias for \lo_list , which shows a list of large objects. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each large object is listed with its associated permissions, if any.

    此定义以英文显示

  • \dmDescribe database objects10 – 20

    In this group of commands, the letters E , i , m , s , t , and v stand for foreign table, index, materialized view, sequence, table, and view, respectively. You can specify any or all of these letters, in any order, to obtain a listing of objects of these types. For example, \dti lists tables and indexes. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each object is listed with its persistence status (permanent, temporary, or unlogged), physical size on disk, and associated description if any. If pattern is specified, only objects whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the S modifier to include system objects.

    此定义以英文显示

  • \dnDescribe database objects10 – 20

    Lists schemas (namespaces). If pattern is specified, only schemas whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the S modifier to include system objects. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each object is listed with its associated permissions and description, if any.

    此定义以英文显示

  • \doDescribe database objects10 – 20

    Lists operators with their operand and result types. If pattern is specified, only operators whose names match the pattern are listed. If one arg_pattern is specified, only prefix operators whose right argument's type name matches that pattern are listed. If two arg_pattern s are specified, only binary operators whose argument type names match those patterns are listed. (Alternatively, write - for the unused argument of a unary operator.) By default, only user-created objects are shown; supply a pattern or the S modifier to include system objects. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, additional information about each operator is shown, including the name of the underlying function, and whether it is leakproof.

    此定义以英文显示

  • \dpDescribe database objects10 – 20

    Lists tables, views and sequences with their associated access privileges. If pattern is specified, only tables, views and sequences whose names match the pattern are listed. By default only user-created objects are shown; supply a pattern or the S modifier to include system objects. If x is appended to the command name, the results are displayed in expanded mode.

    此定义以英文显示

  • \drdsDescribe database objects10 – 20

    Lists defined configuration settings. These settings can be role-specific, database-specific, or both. role-pattern and database-pattern are used to select specific roles and databases to list, respectively. If omitted, or if * is specified, all settings are listed, including those not role-specific or database-specific, respectively. If x is appended to the command name, the results are displayed in expanded mode.

    此定义以英文显示

  • \drgDescribe database objects16 – 20

    Lists information about each granted role membership, including assigned options ( ADMIN , INHERIT and/or SET ) and grantor. See the GRANT command for information about role memberships.

    此定义以英文显示

    1011121314151617181920
  • \dsDescribe database objects10 – 20

    In this group of commands, the letters E , i , m , s , t , and v stand for foreign table, index, materialized view, sequence, table, and view, respectively. You can specify any or all of these letters, in any order, to obtain a listing of objects of these types. For example, \dti lists tables and indexes. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each object is listed with its persistence status (permanent, temporary, or unlogged), physical size on disk, and associated description if any. If pattern is specified, only objects whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the S modifier to include system objects.

    此定义以英文显示

  • \dtDescribe database objects10 – 20

    In this group of commands, the letters E , i , m , s , t , and v stand for foreign table, index, materialized view, sequence, table, and view, respectively. You can specify any or all of these letters, in any order, to obtain a listing of objects of these types. For example, \dti lists tables and indexes. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each object is listed with its persistence status (permanent, temporary, or unlogged), physical size on disk, and associated description if any. If pattern is specified, only objects whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the S modifier to include system objects.

    此定义以英文显示

  • \duDescribe database objects10 – 20

    Lists database roles. (Since the concepts of “ users ” and “ groups ” have been unified into “ roles ” , this command is now equivalent to \dg .) By default, only user-created roles are shown; supply the S modifier to include system roles. If pattern is specified, only those roles whose names match the pattern are listed. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, additional information is shown about each role; currently this adds the comment for each role.

    此定义以英文显示

  • \dvDescribe database objects10 – 20

    In this group of commands, the letters E , i , m , s , t , and v stand for foreign table, index, materialized view, sequence, table, and view, respectively. You can specify any or all of these letters, in any order, to obtain a listing of objects of these types. For example, \dti lists tables and indexes. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each object is listed with its persistence status (permanent, temporary, or unlogged), physical size on disk, and associated description if any. If pattern is specified, only objects whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the S modifier to include system objects.

    此定义以英文显示

  • \dxDescribe database objects10 – 20

    Lists installed extensions. If pattern is specified, only those extensions whose names match the pattern are listed. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, all the objects belonging to each matching extension are listed.

    此定义以英文显示

  • \dyDescribe database objects10 – 20

    Lists event triggers. If pattern is specified, only those event triggers whose names match the pattern are listed. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each object is listed with its associated description.

    此定义以英文显示

  • \eQuery buffer and editing10 – 20

    If filename is specified, the file is edited; after the editor exits, the file's content is copied into the current query buffer. If no filename is given, the current query buffer is copied to a temporary file which is then edited in the same fashion. Or, if the current query buffer is empty, the most recently executed query is copied to a temporary file and edited in the same fashion.

    此定义以英文显示

  • \echoScripting and assistance10 – 20

    Prints the evaluated arguments to standard output, separated by spaces and followed by a newline. This can be useful to intersperse information in the output of scripts. For example:

    此定义以英文显示

  • \editQuery buffer and editing10 – 20

    If filename is specified, the file is edited; after the editor exits, the file's content is copied into the current query buffer. If no filename is given, the current query buffer is copied to a temporary file which is then edited in the same fashion. Or, if the current query buffer is empty, the most recently executed query is copied to a temporary file and edited in the same fashion.

    此定义以英文显示

  • \efQuery buffer and editing10 – 20

    This command fetches and edits the definition of the named function or procedure, in the form of a CREATE OR REPLACE FUNCTION or CREATE OR REPLACE PROCEDURE command. Editing is done in the same way as for \edit . If you quit the editor without saving, the statement is discarded. If you save and exit the editor, the updated command is executed immediately if you added a semicolon to it. Otherwise it is redisplayed; type semicolon or \g to send it, or \r to cancel.

    此定义以英文显示

  • \elifScripting and assistance10 – 20

    This group of commands implements nestable conditional blocks. A conditional block must begin with an \if and end with an \endif . In between there may be any number of \elif clauses, which may optionally be followed by a single \else clause. Ordinary queries and other types of backslash commands may (and usually do) appear between the commands forming a conditional block.

    此定义以英文显示

  • \elseScripting and assistance10 – 20

    This group of commands implements nestable conditional blocks. A conditional block must begin with an \if and end with an \endif . In between there may be any number of \elif clauses, which may optionally be followed by a single \else clause. Ordinary queries and other types of backslash commands may (and usually do) appear between the commands forming a conditional block.

    此定义以英文显示

  • \encodingConnections and sessions10 – 20

    Sets the client character set encoding. Without an argument, this command shows the current encoding.

    此定义以英文显示

  • \endifScripting and assistance10 – 20

    This group of commands implements nestable conditional blocks. A conditional block must begin with an \if and end with an \endif . In between there may be any number of \elif clauses, which may optionally be followed by a single \else clause. Ordinary queries and other types of backslash commands may (and usually do) appear between the commands forming a conditional block.

    此定义以英文显示

  • \endpipelineQuery execution18 – 20

    This group of commands implements pipelining of SQL statements. A pipeline must begin with a \startpipeline and end with an \endpipeline . In between there may be any number of \syncpipeline commands, which sends a sync message without ending the ongoing pipeline and flushing the send buffer. In pipeline mode, statements are sent to the server without waiting for the results of previous statements. See Section 32.5 for more details.

    此定义以英文显示

    1011121314151617181920
  • \errverboseScripting and assistance10 – 20

    Repeats the most recent server error message at maximum verbosity, as though VERBOSITY were set to verbose and SHOW_CONTEXT were set to always .

    此定义以英文显示

  • \evQuery buffer and editing10 – 20

    This command fetches and edits the definition of the named view, in the form of a CREATE OR REPLACE VIEW command. Editing is done in the same way as for \edit . If you quit the editor without saving, the statement is discarded. If you save and exit the editor, the updated command is executed immediately if you added a semicolon to it. Otherwise it is redisplayed; type semicolon or \g to send it, or \r to cancel.

    此定义以英文显示

  • \fOutput and formatting10 – 20

    Sets the field separator for unaligned query output. The default is the vertical bar ( | ). It is equivalent to \pset fieldsep .

    此定义以英文显示

  • \flushQuery execution18 – 20

    This group of commands implements pipelining of SQL statements. A pipeline must begin with a \startpipeline and end with an \endpipeline . In between there may be any number of \syncpipeline commands, which sends a sync message without ending the ongoing pipeline and flushing the send buffer. In pipeline mode, statements are sent to the server without waiting for the results of previous statements. See Section 32.5 for more details.

    此定义以英文显示

    1011121314151617181920
  • \flushrequestQuery execution18 – 20

    This group of commands implements pipelining of SQL statements. A pipeline must begin with a \startpipeline and end with an \endpipeline . In between there may be any number of \syncpipeline commands, which sends a sync message without ending the ongoing pipeline and flushing the send buffer. In pipeline mode, statements are sent to the server without waiting for the results of previous statements. See Section 32.5 for more details.

    此定义以英文显示

    1011121314151617181920
  • \gQuery execution10 – 20

    Sends the current query buffer to the server for execution.

    此定义以英文显示

  • \gdescQuery execution11 – 20

    Shows the description (that is, the column names and data types) of the result of the current query buffer. The query is not actually executed; however, if it contains some type of syntax error, that error will be reported in the normal way.

    此定义以英文显示

  • \getenvScripting and assistance15 – 20

    Gets the value of the environment variable env_var and assigns it to the psql variable psql_var . If env_var is not defined in the psql process's environment, psql_var is not changed. Example:

    此定义以英文显示

    1011121314151617181920
  • \getresultsQuery execution18 – 20

    This group of commands implements pipelining of SQL statements. A pipeline must begin with a \startpipeline and end with an \endpipeline . In between there may be any number of \syncpipeline commands, which sends a sync message without ending the ongoing pipeline and flushing the send buffer. In pipeline mode, statements are sent to the server without waiting for the results of previous statements. See Section 32.5 for more details.

    此定义以英文显示

    1011121314151617181920
  • \gexecQuery execution10 – 20

    Sends the current query buffer to the server, then treats each column of each row of the query's output (if any) as an SQL statement to be executed. For example, to create an index on each column of my_table :

    此定义以英文显示

  • \gsetQuery execution10 – 20

    Sends the current query buffer to the server and stores the query's output into psql variables (see Variables below). The query to be executed must return exactly one row. Each column of the row is stored into a separate variable, named the same as the column. For example:

    此定义以英文显示

  • \gxQuery execution10 – 20

    \gx is equivalent to \g , except that it forces expanded output mode for this query, as if expanded=on were included in the list of \pset options. See also \x .

    此定义以英文显示

  • \hScripting and assistance10 – 20

    Gives syntax help on the specified SQL command. If command is not specified, then psql will list all the commands for which syntax help is available. If command is an asterisk ( * ), then syntax help on all SQL commands is shown.

    此定义以英文显示

  • \helpScripting and assistance10 – 20

    Gives syntax help on the specified SQL command. If command is not specified, then psql will list all the commands for which syntax help is available. If command is an asterisk ( * ), then syntax help on all SQL commands is shown.

    此定义以英文显示

  • \htmlOutput and formatting10 – 20

    Turns on HTML query output format. If the HTML format is already on, it is switched back to the default aligned text format. This command is for compatibility and convenience, but see \pset about setting other output options.

    此定义以英文显示

  • \iScripting and assistance10 – 20

    Reads input from the file filename and executes it as though it had been typed on the keyboard.

    此定义以英文显示

  • \ifScripting and assistance10 – 20

    This group of commands implements nestable conditional blocks. A conditional block must begin with an \if and end with an \endif . In between there may be any number of \elif clauses, which may optionally be followed by a single \else clause. Ordinary queries and other types of backslash commands may (and usually do) appear between the commands forming a conditional block.

    此定义以英文显示

  • \includeScripting and assistance10 – 20

    Reads input from the file filename and executes it as though it had been typed on the keyboard.

    此定义以英文显示

  • \include_relativeScripting and assistance10 – 20

    The \ir command is similar to \i , but resolves relative file names differently. When executing in interactive mode, the two commands behave identically. However, when invoked from a script, \ir interprets file names relative to the directory in which the script is located, rather than the current working directory.

    此定义以英文显示

  • \irScripting and assistance10 – 20

    The \ir command is similar to \i , but resolves relative file names differently. When executing in interactive mode, the two commands behave identically. However, when invoked from a script, \ir interprets file names relative to the directory in which the script is located, rather than the current working directory.

    此定义以英文显示

  • \lDescribe database objects10 – 20

    List the databases in the server and show their names, owners, character set encodings, and access privileges. If pattern is specified, only databases whose names match the pattern are listed. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, database sizes, default tablespaces, and descriptions are also displayed. Size information is available for databases on which the current user has CONNECT privilege, or if the current user is a superuser or has privileges of the pg_read_all_stats role.

    此定义以英文显示

  • \listDescribe database objects10 – 20

    List the databases in the server and show their names, owners, character set encodings, and access privileges. If pattern is specified, only databases whose names match the pattern are listed. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, database sizes, default tablespaces, and descriptions are also displayed. Size information is available for databases on which the current user has CONNECT privilege, or if the current user is a superuser or has privileges of the pg_read_all_stats role.

    此定义以英文显示

  • \lo_exportData transfer and large objects10 – 20

    Reads the large object with OID loid from the database and writes it to filename . Note that this is subtly different from the server function lo_export , which acts with the permissions of the user that the database server runs as and on the server's file system.

    此定义以英文显示

  • \lo_importData transfer and large objects10 – 20

    Stores the file into a PostgreSQL large object. Optionally, it associates the given comment with the object. Example:

    此定义以英文显示

  • \lo_listData transfer and large objects10 – 20

    Shows a list of all PostgreSQL large objects currently stored in the database, along with any comments provided for them. If x is appended to the command name, the results are displayed in expanded mode. If + is appended to the command name, each large object is listed with its associated permissions, if any.

    此定义以英文显示

  • \lo_unlinkData transfer and large objects10 – 20

    Deletes the large object with OID loid from the database.

    此定义以英文显示

  • \oOutput and formatting10 – 20

    Arranges to save future query results to the file filename or pipe future results to the shell command command . If no argument is specified, the query output is reset to the standard output.

    此定义以英文显示

  • \outOutput and formatting10 – 20

    Arranges to save future query results to the file filename or pipe future results to the shell command command . If no argument is specified, the query output is reset to the standard output.

    此定义以英文显示

  • \pQuery buffer and editing10 – 20

    Print the current query buffer to the standard output. If the current query buffer is empty, the most recently executed query is printed instead.

    此定义以英文显示

  • \parseQuery execution18 – 20

    Creates a prepared statement from the current query buffer, based on the name of a destination prepared-statement object. An empty string denotes the unnamed prepared statement.

    此定义以英文显示

    1011121314151617181920
  • \passwordConnections and sessions10 – 20

    Changes the password of the specified user (by default, the current user). This command prompts for the new password, encrypts it, and sends it to the server as an ALTER ROLE command. This makes sure that the new password does not appear in cleartext in the command history, the server log, or elsewhere.

    此定义以英文显示

  • \printQuery buffer and editing10 – 20

    Print the current query buffer to the standard output. If the current query buffer is empty, the most recently executed query is printed instead.

    此定义以英文显示

  • \promptScripting and assistance10 – 20

    Prompts the user to supply text, which is assigned to the variable name . An optional prompt string, text , can be specified. (For multiword prompts, surround the text with single quotes.)

    此定义以英文显示

  • \psetOutput and formatting10 – 20

    This command sets options affecting the output of query result tables. option indicates which option is to be set. The semantics of value vary depending on the selected option. For some options, omitting value causes the option to be toggled or unset, as described under the particular option. If no such behavior is mentioned, then omitting value just results in the current setting being displayed.

    此定义以英文显示

  • \qScripting and assistance10 – 20

    Quits the psql program. In a script file, only execution of that script is terminated.

    此定义以英文显示

  • \qechoScripting and assistance10 – 20

    This command is identical to \echo except that the output will be written to the query output channel, as set by \o .

    此定义以英文显示

  • \quitScripting and assistance10 – 20

    Quits the psql program. In a script file, only execution of that script is terminated.

    此定义以英文显示

  • \rQuery buffer and editing10 – 20

    Resets (clears) the query buffer.

    此定义以英文显示

  • \resetQuery buffer and editing10 – 20

    Resets (clears) the query buffer.

    此定义以英文显示

  • \restrictScripting and assistance13 – 20

    Enter "restricted" mode with the provided key. In this mode, the only allowed meta-command is \unrestrict , to exit restricted mode. The key may contain only alphanumeric characters.

    此定义以英文显示

  • \sQuery buffer and editing10 – 20

    Print psql 's command line history to filename . If filename is omitted, the history is written to the standard output (using the pager if appropriate). This command is not available if psql was built without Readline support.

    此定义以英文显示

  • \sendpipelineQuery execution18 – 20

    This group of commands implements pipelining of SQL statements. A pipeline must begin with a \startpipeline and end with an \endpipeline . In between there may be any number of \syncpipeline commands, which sends a sync message without ending the ongoing pipeline and flushing the send buffer. In pipeline mode, statements are sent to the server without waiting for the results of previous statements. See Section 32.5 for more details.

    此定义以英文显示

    1011121314151617181920
  • \setScripting and assistance10 – 20

    Sets the psql variable name to value , or if more than one value is given, to the concatenation of all of them. If only one argument is given, the variable is set to an empty-string value. To unset a variable, use the \unset command.

    此定义以英文显示

  • \setenvScripting and assistance10 – 20

    Sets the environment variable name to value , or if the value is not supplied, unsets the environment variable. Example:

    此定义以英文显示

  • \sfQuery buffer and editing10 – 20

    This command fetches and shows the definition of the named function or procedure, in the form of a CREATE OR REPLACE FUNCTION or CREATE OR REPLACE PROCEDURE command. The definition is printed to the current query output channel, as set by \o .

    此定义以英文显示

  • \startpipelineQuery execution18 – 20

    This group of commands implements pipelining of SQL statements. A pipeline must begin with a \startpipeline and end with an \endpipeline . In between there may be any number of \syncpipeline commands, which sends a sync message without ending the ongoing pipeline and flushing the send buffer. In pipeline mode, statements are sent to the server without waiting for the results of previous statements. See Section 32.5 for more details.

    此定义以英文显示

    1011121314151617181920
  • \svQuery buffer and editing10 – 20

    This command fetches and shows the definition of the named view, in the form of a CREATE OR REPLACE VIEW command. The definition is printed to the current query output channel, as set by \o .

    此定义以英文显示

  • \syncpipelineQuery execution18 – 20

    This group of commands implements pipelining of SQL statements. A pipeline must begin with a \startpipeline and end with an \endpipeline . In between there may be any number of \syncpipeline commands, which sends a sync message without ending the ongoing pipeline and flushing the send buffer. In pipeline mode, statements are sent to the server without waiting for the results of previous statements. See Section 32.5 for more details.

    此定义以英文显示

    1011121314151617181920
  • \tOutput and formatting10 – 20

    Toggles the display of output column name headings and row count footer. This command is equivalent to \pset tuples_only and is provided for convenience.

    此定义以英文显示

  • \timingScripting and assistance10 – 20

    With a parameter, turns displaying of how long each SQL statement takes on or off. Without a parameter, toggles the display between on and off. The display is in milliseconds; intervals longer than 1 second are also shown in minutes:seconds format, with hours and days fields added if needed.

    此定义以英文显示

  • \unrestrictScripting and assistance13 – 20

    Exit "restricted" mode (i.e., where all other meta-commands are blocked), provided the specified key matches the one given to \restrict when restricted mode was entered.

    此定义以英文显示

  • \unsetScripting and assistance10 – 20

    Unsets (deletes) the psql variable name .

    此定义以英文显示

  • \wQuery buffer and editing10 – 20

    Writes the current query buffer to the file filename or pipes it to the shell command command . If the current query buffer is empty, the most recently executed query is written instead.

    此定义以英文显示

  • \warnScripting and assistance13 – 20

    This command is identical to \echo except that the output will be written to psql 's standard error channel, rather than standard output.

    此定义以英文显示

  • \watchQuery execution10 – 20

    Repeatedly execute the current query buffer (as \g does) until interrupted, or the query fails, or the execution count limit (if given) is reached, or the query no longer returns the minimum number of rows. Wait the specified number of seconds (default 2) between executions. The default wait can be changed with the variable WATCH_INTERVAL . For backwards compatibility, seconds can be specified with or without an interval= prefix. Each query result is displayed with a header that includes the \pset title string (if any), the time as of query start, and the delay interval.

    此定义以英文显示

  • \writeQuery buffer and editing10 – 20

    Writes the current query buffer to the file filename or pipes it to the shell command command . If the current query buffer is empty, the most recently executed query is written instead.

    此定义以英文显示

  • \xOutput and formatting10 – 20

    Sets or toggles expanded table formatting mode. As such it is equivalent to \pset expanded .

    此定义以英文显示

  • \zDescribe database objects10 – 20

    Lists tables, views and sequences with their associated access privileges. If a pattern is specified, only tables, views and sequences whose names match the pattern are listed. By default only user-created objects are shown; supply a pattern or the S modifier to include system objects. If x is appended to the command name, the results are displayed in expanded mode.

    此定义以英文显示