{"Entry":{"collection":"tool","key":"psql","name":"psql","aliases":["psql"],"metadata":{"aliases":["psql"],"category":"Client applications","content_hash":"55335a4ca513a42a35d079ab722124f676238d1bce30f048dfdc109a2c986747","imported_at":"2026-09-30T00:40:34.632601+08:00","name":"psql","name_zh":"","slug":"psql","summary":"psql — PostgreSQL interactive terminal"}},"Definition":{"Collection":"tool","Key":"psql","SourceDatabase":"center","Version":"18","SourceTable":"command_tool","SourceKey":"psql","SourceRevision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","Facts":{"comparison_data":{"environment":[{"description":"If \\pset columns is zero, controls the width for the wrapped format and width for determining if wide output requires the pager or should be switched to the vertical format in expanded auto mode.","name":"COLUMNS"},{"description":"Default connection parameters (see Section 32.15 ).","name":"PGDATABASE PGHOST PGPORT PGUSER"},{"description":"Specifies whether to use color in diagnostic messages. Possible values are always , auto and never .","name":"PG_COLOR"},{"description":"Editor used by the \\e , \\ef , and \\ev commands. These variables are examined in the order listed; the first that is set is used. If none of them is set, the default is to use vi on Unix systems or notepad.exe on Windows systems.","name":"PSQL_EDITOR EDITOR VISUAL"},{"description":"When \\e , \\ef , or \\ev is used with a line number argument, this variable specifies the command-line argument used to pass the starting line number to the user's editor. For editors such as Emacs or vi , this is a plus sign. Include a trailing space in the value of the variable if there needs to be space between the option name and the line number. Examples: PSQL_EDITOR_LINENUMBER_ARG='+' PSQL_EDITOR_LINENUMBER_ARG='--line ' The default is + on Unix systems (corresponding to the default editor vi , and useful for many other common editors); but there is no default on Windows systems.","name":"PSQL_EDITOR_LINENUMBER_ARG"},{"description":"Alternative location for the command history file. Tilde ( ~ ) expansion is performed.","name":"PSQL_HISTORY"},{"description":"If a query's results do not fit on the screen, they are piped through this command. Typical values are more or less . Use of the pager can be disabled by setting PSQL_PAGER or PAGER to an empty string, or by adjusting the pager-related options of the \\pset command. These variables are examined in the order listed; the first that is set is used. If neither of them is set, the default is to use more on most platforms, but less on Cygwin.","name":"PSQL_PAGER PAGER"},{"description":"When a query is executed repeatedly with the \\watch command, a pager is not used by default. This behavior can be changed by setting PSQL_WATCH_PAGER to a pager command, on Unix systems. The pspg pager (not part of PostgreSQL but available in many open source software distributions) can display the output of \\watch if started with the option --stream .","name":"PSQL_WATCH_PAGER"},{"description":"Alternative location of the user's .psqlrc file. Tilde ( ~ ) expansion is performed.","name":"PSQLRC"},{"description":"Command executed by the \\! command.","name":"SHELL"},{"description":"Directory for storing temporary files. The default is /tmp .","name":"TMPDIR"}],"options":[{"description":"Print all nonempty input lines to standard output as they are read. (This does not apply to lines read interactively.) This is equivalent to setting the variable ECHO to all .","names":["-a","--echo-all"],"signature":"-a --echo-all"},{"description":"Switches to unaligned output mode. (The default output mode is aligned .) This is equivalent to \\pset format unaligned .","names":["-A","--no-align"],"signature":"-A --no-align"},{"description":"Print failed SQL commands to standard error output. This is equivalent to setting the variable ECHO to errors .","names":["-b","--echo-errors"],"signature":"-b --echo-errors"},{"description":"Specifies that psql is to execute the given command string, command . This option can be repeated and combined in any order with the -f option. When either -c or -f is specified, psql does not read commands from standard input; instead it terminates after processing all the -c and -f options in sequence. command must be either a command string that is completely parsable by the server (i.e., it contains no psql -specific features), or a single backslash command. Thus you cannot mix SQL and psql meta-commands within a -c option. To achieve that, you could use repeated -c options or pipe the string into psql , for example: psql -c '\\x' -c 'SELECT * FROM foo;' or echo '\\x \\\\ SELECT * FROM foo;' | psql ( \\\\ is the separator meta-command.) Each SQL command string passed to -c is sent to the server as a single request. Because of this, the server executes it as a single transaction even if the string contains multiple SQL commands, unless there are explicit BEGIN / COMMIT commands included in the string to divide it into multiple transactions. (See Section 54.2.2.1 for more details about how the server handles multi-query strings.) If having several commands executed in one transaction is not desired, use repeated -c commands or feed multiple commands to psql 's standard input, either using echo as illustrated above, or via a shell here-document, for example: psql \u003c\u003cEOF \\x SELECT * FROM foo; EOF","names":["-c command","--command= command"],"signature":"-c command --command= command"},{"description":"Switches to CSV (Comma-Separated Values) output mode. This is equivalent to \\pset format csv .","names":["--csv"],"signature":"--csv"},{"description":"Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.","names":["-d dbname","--dbname= dbname"],"signature":"-d dbname --dbname= dbname"},{"description":"Copy all SQL commands sent to the server to standard output as well. This is equivalent to setting the variable ECHO to queries .","names":["-e","--echo-queries"],"signature":"-e --echo-queries"},{"description":"Echo the actual queries generated by \\d and other backslash commands. You can use this to study psql 's internal operations. This is equivalent to setting the variable ECHO_HIDDEN to on .","names":["-E","--echo-hidden"],"signature":"-E --echo-hidden"},{"description":"Read commands from the file filename , rather than standard input. This option can be repeated and combined in any order with the -c option. When either -c or -f is specified, psql does not read commands from standard input; instead it terminates after processing all the -c and -f options in sequence. Except for that, this option is largely equivalent to the meta-command \\i . If filename is - (hyphen), then standard input is read until an EOF indication or \\q meta-command. This can be used to intersperse interactive input with input from files. Note however that Readline is not used in this case (much as if -n had been specified). Using this option is subtly different from writing psql \u003c filename . In general, both will do what you expect, but using -f enables some nice features such as error messages with line numbers. There is also a slight chance that using this option will reduce the start-up overhead. On the other hand, the variant using the shell's input redirection is (in theory) guaranteed to yield exactly the same output you would have received had you entered everything by hand.","names":["-f filename","--file= filename"],"signature":"-f filename --file= filename"},{"description":"Use separator as the field separator for unaligned output. This is equivalent to \\pset fieldsep or \\f .","names":["-F separator","--field-separator= separator"],"signature":"-F separator --field-separator= separator"},{"description":"Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix-domain socket.","names":["-h hostname","--host= hostname"],"signature":"-h hostname --host= hostname"},{"description":"Switches to HTML output mode. This is equivalent to \\pset format html or the \\H command.","names":["-H","--html"],"signature":"-H --html"},{"description":"List all available databases, then exit. Other non-connection options are ignored. This is similar to the meta-command \\list . When this option is used, psql will connect to the database postgres , unless a different database is named on the command line (option -d or non-option argument, possibly via a service entry, but not via an environment variable).","names":["-l","--list"],"signature":"-l --list"},{"description":"Write all query output into file filename , in addition to the normal output destination.","names":["-L filename","--log-file= filename"],"signature":"-L filename --log-file= filename"},{"description":"Do not use Readline for line editing and do not use the command history (see the section called “Command-Line Editing” below).","names":["-n","--no-readline"],"signature":"-n --no-readline"},{"description":"Put all query output into file filename . This is equivalent to the command \\o .","names":["-o filename","--output= filename"],"signature":"-o filename --output= filename"},{"description":"Specifies the TCP port or the local Unix-domain socket file extension on which the server is listening for connections. Defaults to the value of the PGPORT environment variable or, if not set, to the port specified at compile time, usually 5432.","names":["-p port","--port= port"],"signature":"-p port --port= port"},{"description":"Specifies printing options, in the style of \\pset . Note that here you have to separate name and value with an equal sign instead of a space. For example, to set the output format to LaTeX , you could write -P format=latex .","names":["-P assignment","--pset= assignment"],"signature":"-P assignment --pset= assignment"},{"description":"Specifies that psql should do its work quietly. By default, it prints welcome messages and various informational output. If this option is used, none of this happens. This is useful with the -c option. This is equivalent to setting the variable QUIET to on .","names":["-q","--quiet"],"signature":"-q --quiet"},{"description":"Use separator as the record separator for unaligned output. This is equivalent to \\pset recordsep .","names":["-R separator","--record-separator= separator"],"signature":"-R separator --record-separator= separator"},{"description":"Run in single-step mode. That means the user is prompted before each command is sent to the server, with the option to cancel execution as well. Use this to debug scripts.","names":["-s","--single-step"],"signature":"-s --single-step"},{"description":"Runs in single-line mode where a newline terminates an SQL command, as a semicolon does. Note This mode is provided for those who insist on it, but you are not necessarily encouraged to use it. In particular, if you mix SQL and meta-commands on a line the order of execution might not always be clear to the inexperienced user.","names":["-S","--single-line"],"signature":"-S --single-line"},{"description":"Turn off printing of column names and result row count footers, etc. This is equivalent to \\t or \\pset tuples_only .","names":["-t","--tuples-only"],"signature":"-t --tuples-only"},{"description":"Specifies options to be placed within the HTML table tag. See \\pset tableattr for details.","names":["-T table_options","--table-attr= table_options"],"signature":"-T table_options --table-attr= table_options"},{"description":"Connect to the database as the user username instead of the default. (You must have permission to do so, of course.)","names":["-U username","--username= username"],"signature":"-U username --username= username"},{"description":"Perform a variable assignment, like the \\set meta-command. Note that you must separate name and value, if any, by an equal sign on the command line. To unset a variable, leave off the equal sign. To set a variable with an empty value, use the equal sign but leave off the value. These assignments are done during command line processing, so variables that reflect connection state will get overwritten later.","names":["-v assignment","--set= assignment","--variable= assignment"],"signature":"-v assignment --set= assignment --variable= assignment"},{"description":"Print the psql version and exit.","names":["-V","--version"],"signature":"-V --version"},{"description":"Never issue a password prompt. If the server requires password authentication and a password is not available from other sources such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password. Note that this option will remain set for the entire session, and so it affects uses of the meta-command \\connect as well as the initial connection attempt.","names":["-w","--no-password"],"signature":"-w --no-password"},{"description":"Force psql to prompt for a password before connecting to a database, even if the password will not be used. If the server requires password authentication and a password is not available from other sources such as a .pgpass file, psql will prompt for a password in any case. However, psql will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing -W to avoid the extra connection attempt. Note that this option will remain set for the entire session, and so it affects uses of the meta-command \\connect as well as the initial connection attempt.","names":["-W","--password"],"signature":"-W --password"},{"description":"Turn on the expanded table formatting mode. This is equivalent to \\x or \\pset expanded .","names":["-x","--expanded"],"signature":"-x --expanded"},{"description":"Do not read the start-up file (neither the system-wide psqlrc file nor the user's ~/.psqlrc file).","names":["-X","--no-psqlrc"],"signature":"-X --no-psqlrc"},{"description":"Set the field separator for unaligned output to a zero byte. This is equivalent to \\pset fieldsep_zero .","names":["-z","--field-separator-zero"],"signature":"-z --field-separator-zero"},{"description":"Set the record separator for unaligned output to a zero byte. This is useful for interfacing, for example, with xargs -0 . This is equivalent to \\pset recordsep_zero .","names":["-0","--record-separator-zero"],"signature":"-0 --record-separator-zero"},{"description":"This option can only be used in combination with one or more -c and/or -f options. It causes psql to issue a BEGIN command before the first such option and a COMMIT command after the last one, thereby wrapping all the commands into a single transaction. If any of the commands fails and the variable ON_ERROR_STOP was set, a ROLLBACK command is sent instead. This ensures that either all the commands complete successfully, or no changes are applied. If the commands themselves contain BEGIN , COMMIT , or ROLLBACK , this option will not have the desired effects. Also, if an individual command cannot be executed inside a transaction block, specifying this option will cause the whole transaction to fail.","names":["-1","--single-transaction"],"signature":"-1 --single-transaction"},{"description":"Show help about psql and exit. The optional topic parameter (defaulting to options ) 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.","names":["-?","--help[= topic ]"],"signature":"-? --help[= topic ]"}],"synopsis":["psql [ option ...] [ dbname [ username ]]"]},"comparison_hash":"7e52d8ca2dae4caec99412af17f0657a086f7413f9904aa5e55efb826f752e8b","description":["psql — PostgreSQL interactive terminal"],"environment":[{"description":"If \\pset columns is zero, controls the width for the wrapped format and width for determining if wide output requires the pager or should be switched to the vertical format in expanded auto mode.","name":"COLUMNS"},{"description":"Default connection parameters (see Section 32.15 ).","name":"PGDATABASE PGHOST PGPORT PGUSER"},{"description":"Specifies whether to use color in diagnostic messages. Possible values are always , auto and never .","name":"PG_COLOR"},{"description":"Editor used by the \\e , \\ef , and \\ev commands. These variables are examined in the order listed; the first that is set is used. If none of them is set, the default is to use vi on Unix systems or notepad.exe on Windows systems.","name":"PSQL_EDITOR EDITOR VISUAL"},{"description":"When \\e , \\ef , or \\ev is used with a line number argument, this variable specifies the command-line argument used to pass the starting line number to the user's editor. For editors such as Emacs or vi , this is a plus sign. Include a trailing space in the value of the variable if there needs to be space between the option name and the line number. Examples: PSQL_EDITOR_LINENUMBER_ARG='+' PSQL_EDITOR_LINENUMBER_ARG='--line ' The default is + on Unix systems (corresponding to the default editor vi , and useful for many other common editors); but there is no default on Windows systems.","name":"PSQL_EDITOR_LINENUMBER_ARG"},{"description":"Alternative location for the command history file. Tilde ( ~ ) expansion is performed.","name":"PSQL_HISTORY"},{"description":"If a query's results do not fit on the screen, they are piped through this command. Typical values are more or less . Use of the pager can be disabled by setting PSQL_PAGER or PAGER to an empty string, or by adjusting the pager-related options of the \\pset command. These variables are examined in the order listed; the first that is set is used. If neither of them is set, the default is to use more on most platforms, but less on Cygwin.","name":"PSQL_PAGER PAGER"},{"description":"When a query is executed repeatedly with the \\watch command, a pager is not used by default. This behavior can be changed by setting PSQL_WATCH_PAGER to a pager command, on Unix systems. The pspg pager (not part of PostgreSQL but available in many open source software distributions) can display the output of \\watch if started with the option --stream .","name":"PSQL_WATCH_PAGER"},{"description":"Alternative location of the user's .psqlrc file. Tilde ( ~ ) expansion is performed.","name":"PSQLRC"},{"description":"Command executed by the \\! command.","name":"SHELL"},{"description":"Directory for storing temporary files. The default is /tmp .","name":"TMPDIR"}],"facts":[{"label":"Documented executable","value":"psql"},{"label":"Executable version","value":"18.6"},{"label":"Reference inventory","value":"Client applications"},{"label":"Option definition groups","value":"35"}],"manual_html":"\u003cdiv\u003e\u003cdiv class=\"refentry\" id=\"APP-PSQL\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\u003c/div\u003e\n\u003cdiv class=\"refnamediv\"\u003e\n\u003ch2\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e — \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e interactive terminal\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsynopsisdiv\"\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.4.21.4.1\"\u003e\u003ccode class=\"command\"\u003epsql\u003c/code\u003e [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...] [\u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e]]\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.21.5\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e is a terminal-based front-end to \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e. It enables you to type in queries interactively, issue them to \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e, and see the query results. Alternatively, input can be from a file or from command line arguments. In addition, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e provides a number of meta-commands and various shell-like features to facilitate writing scripts and automating a wide variety of tasks.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"R1-APP-PSQL-3\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-PSQL-OPTION-ECHO-ALL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-a\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--echo-all\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint all nonempty input lines to standard output as they are read. (This does not apply to lines read interactively.) This is equivalent to setting the variable \u003ccode class=\"varname\"\u003eECHO\u003c/code\u003e to \u003ccode class=\"literal\"\u003eall\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-NO-ALIGN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-A\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-align\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSwitches to unaligned output mode. (The default output mode is \u003ccode class=\"literal\"\u003ealigned\u003c/code\u003e.) This is equivalent to \u003ccode class=\"command\"\u003e\\pset format unaligned\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-ECHO-ERRORS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-b\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--echo-errors\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint failed SQL commands to standard error output. This is equivalent to setting the variable \u003ccode class=\"varname\"\u003eECHO\u003c/code\u003e to \u003ccode class=\"literal\"\u003eerrors\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-COMMAND\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-c \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--command=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies that \u003cspan class=\"application\"\u003epsql\u003c/span\u003e is to execute the given command string, \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e. This option can be repeated and combined in any order with the \u003ccode class=\"option\"\u003e-f\u003c/code\u003e option. When either \u003ccode class=\"option\"\u003e-c\u003c/code\u003e or \u003ccode class=\"option\"\u003e-f\u003c/code\u003e is specified, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e does not read commands from standard input; instead it terminates after processing all the \u003ccode class=\"option\"\u003e-c\u003c/code\u003e and \u003ccode class=\"option\"\u003e-f\u003c/code\u003e options in sequence.\u003c/p\u003e\n\u003cp\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e must be either a command string that is completely parsable by the server (i.e., it contains no \u003cspan class=\"application\"\u003epsql\u003c/span\u003e-specific features), or a single backslash command. Thus you cannot mix SQL and \u003cspan class=\"application\"\u003epsql\u003c/span\u003e meta-commands within a \u003ccode class=\"option\"\u003e-c\u003c/code\u003e option. To achieve that, you could use repeated \u003ccode class=\"option\"\u003e-c\u003c/code\u003e options or pipe the string into \u003cspan class=\"application\"\u003epsql\u003c/span\u003e, for example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003epsql -c '\\x' -c 'SELECT * FROM foo;'\n\u003c/pre\u003e\n\u003cp\u003eor\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eecho '\\x \\\\ SELECT * FROM foo;' | psql\n\u003c/pre\u003e\n\u003cp\u003e(\u003ccode class=\"literal\"\u003e\\\\\u003c/code\u003e is the separator meta-command.)\u003c/p\u003e\n\u003cp\u003eEach SQL command string passed to \u003ccode class=\"option\"\u003e-c\u003c/code\u003e is sent to the server as a single request. Because of this, the server executes it as a single transaction even if the string contains multiple SQL commands, unless there are explicit \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e/\u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e commands included in the string to divide it into multiple transactions. (See \u003ca class=\"xref\" href=\"/docs/18/protocol-flow.html#PROTOCOL-FLOW-MULTI-STATEMENT\" title=\"54.2.2.1. Multiple Statements in a Simple Query\"\u003eSection 54.2.2.1\u003c/a\u003e for more details about how the server handles multi-query strings.)\u003c/p\u003e\n\u003cp\u003eIf having several commands executed in one transaction is not desired, use repeated \u003ccode class=\"option\"\u003e-c\u003c/code\u003e commands or feed multiple commands to \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's standard input, either using \u003cspan class=\"application\"\u003eecho\u003c/span\u003e as illustrated above, or via a shell here-document, for example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003epsql \u0026lt;\u0026lt;EOF\n\\x\nSELECT * FROM foo;\nEOF\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-CSV\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--csv\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSwitches to CSV (Comma-Separated Values) output mode. This is equivalent to \u003ccode class=\"command\"\u003e\\pset format csv\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-DBNAME\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-d \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--dbname=\u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the name of the database to connect to. This is equivalent to specifying \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e as the first non-option argument on the command line. The \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e can be a \u003ca class=\"link\" href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"32.1.1. Connection Strings\"\u003econnection string\u003c/a\u003e. If so, connection string parameters will override any conflicting command line options.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-ECHO-QUERIES\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--echo-queries\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCopy all SQL commands sent to the server to standard output as well. This is equivalent to setting the variable \u003ccode class=\"varname\"\u003eECHO\u003c/code\u003e to \u003ccode class=\"literal\"\u003equeries\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-ECHO-HIDDEN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-E\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--echo-hidden\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEcho the actual queries generated by \u003ccode class=\"command\"\u003e\\d\u003c/code\u003e and other backslash commands. You can use this to study \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's internal operations. This is equivalent to setting the variable \u003ccode class=\"varname\"\u003eECHO_HIDDEN\u003c/code\u003e to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-FILE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-f \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--file=\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRead commands from the file \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e, rather than standard input. This option can be repeated and combined in any order with the \u003ccode class=\"option\"\u003e-c\u003c/code\u003e option. When either \u003ccode class=\"option\"\u003e-c\u003c/code\u003e or \u003ccode class=\"option\"\u003e-f\u003c/code\u003e is specified, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e does not read commands from standard input; instead it terminates after processing all the \u003ccode class=\"option\"\u003e-c\u003c/code\u003e and \u003ccode class=\"option\"\u003e-f\u003c/code\u003e options in sequence. Except for that, this option is largely equivalent to the meta-command \u003ccode class=\"command\"\u003e\\i\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eIf \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e is \u003ccode class=\"literal\"\u003e-\u003c/code\u003e (hyphen), then standard input is read until an EOF indication or \u003ccode class=\"command\"\u003e\\q\u003c/code\u003e meta-command. This can be used to intersperse interactive input with input from files. Note however that Readline is not used in this case (much as if \u003ccode class=\"option\"\u003e-n\u003c/code\u003e had been specified).\u003c/p\u003e\n\u003cp\u003eUsing this option is subtly different from writing \u003ccode class=\"literal\"\u003epsql \u0026lt; \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e. In general, both will do what you expect, but using \u003ccode class=\"literal\"\u003e-f\u003c/code\u003e enables some nice features such as error messages with line numbers. There is also a slight chance that using this option will reduce the start-up overhead. On the other hand, the variant using the shell's input redirection is (in theory) guaranteed to yield exactly the same output you would have received had you entered everything by hand.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-FIELD-SEPARATOR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-F \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseparator\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--field-separator=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eseparator\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUse \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseparator\u003c/code\u003e\u003c/em\u003e as the field separator for unaligned output. This is equivalent to \u003ccode class=\"command\"\u003e\\pset fieldsep\u003c/code\u003e or \u003ccode class=\"command\"\u003e\\f\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-FIELD-HOST\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-h \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehostname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--host=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ehostname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix-domain socket.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-HTML\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-H\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--html\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSwitches to HTML output mode. This is equivalent to \u003ccode class=\"command\"\u003e\\pset format html\u003c/code\u003e or the \u003ccode class=\"command\"\u003e\\H\u003c/code\u003e command.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-LIST\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-l\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--list\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eList all available databases, then exit. Other non-connection options are ignored. This is similar to the meta-command \u003ccode class=\"command\"\u003e\\list\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eWhen this option is used, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will connect to the database \u003ccode class=\"literal\"\u003epostgres\u003c/code\u003e, unless a different database is named on the command line (option \u003ccode class=\"option\"\u003e-d\u003c/code\u003e or non-option argument, possibly via a service entry, but not via an environment variable).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-LOG-FILE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-L \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--log-file=\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWrite all query output into file \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e, in addition to the normal output destination.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-NO-READLINE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-readline\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not use \u003cspan class=\"application\"\u003eReadline\u003c/span\u003e for line editing and do not use the command history (see \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-READLINE\" title=\"Command-Line Editing\"\u003ethe section called “Command-Line Editing”\u003c/a\u003e below).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-OUTPUT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-o \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--output=\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePut all query output into file \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e. This is equivalent to the command \u003ccode class=\"command\"\u003e\\o\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-PORT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-p \u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--port=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the TCP port or the local Unix-domain socket file extension on which the server is listening for connections. Defaults to the value of the \u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e environment variable or, if not set, to the port specified at compile time, usually 5432.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-PSET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-P \u003cem class=\"replaceable\"\u003e\u003ccode\u003eassignment\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--pset=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eassignment\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies printing options, in the style of \u003ccode class=\"command\"\u003e\\pset\u003c/code\u003e. Note that here you have to separate name and value with an equal sign instead of a space. For example, to set the output format to \u003cspan class=\"application\"\u003eLaTeX\u003c/span\u003e, you could write \u003ccode class=\"literal\"\u003e-P format=latex\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-QUIET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-q\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--quiet\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies that \u003cspan class=\"application\"\u003epsql\u003c/span\u003e should do its work quietly. By default, it prints welcome messages and various informational output. If this option is used, none of this happens. This is useful with the \u003ccode class=\"option\"\u003e-c\u003c/code\u003e option. This is equivalent to setting the variable \u003ccode class=\"varname\"\u003eQUIET\u003c/code\u003e to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-RECORD-SEPARATOR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-R \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseparator\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--record-separator=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eseparator\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUse \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseparator\u003c/code\u003e\u003c/em\u003e as the record separator for unaligned output. This is equivalent to \u003ccode class=\"command\"\u003e\\pset recordsep\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-SINGLE-STEP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-s\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--single-step\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRun in single-step mode. That means the user is prompted before each command is sent to the server, with the option to cancel execution as well. Use this to debug scripts.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-SINGLE-LINE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-S\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--single-line\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRuns in single-line mode where a newline terminates an SQL command, as a semicolon does.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis mode is provided for those who insist on it, but you are not necessarily encouraged to use it. In particular, if you mix SQL and meta-commands on a line the order of execution might not always be clear to the inexperienced user.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-TUPLES-ONLY\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-t\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--tuples-only\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eTurn off printing of column names and result row count footers, etc. This is equivalent to \u003ccode class=\"command\"\u003e\\t\u003c/code\u003e or \u003ccode class=\"command\"\u003e\\pset tuples_only\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-TABLE-ATTR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-T \u003cem class=\"replaceable\"\u003e\u003ccode\u003etable_options\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--table-attr=\u003cem class=\"replaceable\"\u003e\u003ccode\u003etable_options\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies options to be placed within the HTML \u003ccode class=\"sgmltag-element\"\u003etable\u003c/code\u003e tag. See \u003ccode class=\"command\"\u003e\\pset tableattr\u003c/code\u003e for details.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-USERNAME\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-U \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--username=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eConnect to the database as the user \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e instead of the default. (You must have permission to do so, of course.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-VARIABLE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-v \u003cem class=\"replaceable\"\u003e\u003ccode\u003eassignment\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--set=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eassignment\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--variable=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eassignment\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePerform a variable assignment, like the \u003ccode class=\"command\"\u003e\\set\u003c/code\u003e meta-command. Note that you must separate name and value, if any, by an equal sign on the command line. To unset a variable, leave off the equal sign. To set a variable with an empty value, use the equal sign but leave off the value. These assignments are done during command line processing, so variables that reflect connection state will get overwritten later.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-VERSION\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--version\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e version and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-NO-PASSWORD\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-w\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-password\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eNever issue a password prompt. If the server requires password authentication and a password is not available from other sources such as a \u003ccode class=\"filename\"\u003e.pgpass\u003c/code\u003e file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password.\u003c/p\u003e\n\u003cp\u003eNote that this option will remain set for the entire session, and so it affects uses of the meta-command \u003ccode class=\"command\"\u003e\\connect\u003c/code\u003e as well as the initial connection attempt.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-PASSWORD\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-W\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--password\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eForce \u003cspan class=\"application\"\u003epsql\u003c/span\u003e to prompt for a password before connecting to a database, even if the password will not be used.\u003c/p\u003e\n\u003cp\u003eIf the server requires password authentication and a password is not available from other sources such as a \u003ccode class=\"filename\"\u003e.pgpass\u003c/code\u003e file, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will prompt for a password in any case. However, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing \u003ccode class=\"option\"\u003e-W\u003c/code\u003e to avoid the extra connection attempt.\u003c/p\u003e\n\u003cp\u003eNote that this option will remain set for the entire session, and so it affects uses of the meta-command \u003ccode class=\"command\"\u003e\\connect\u003c/code\u003e as well as the initial connection attempt.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-EXPANDED\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-x\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--expanded\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eTurn on the expanded table formatting mode. This is equivalent to \u003ccode class=\"command\"\u003e\\x\u003c/code\u003e or \u003ccode class=\"command\"\u003e\\pset expanded\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-NO-PSQLRC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-X\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-psqlrc\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not read the start-up file (neither the system-wide \u003ccode class=\"filename\"\u003epsqlrc\u003c/code\u003e file nor the user's \u003ccode class=\"filename\"\u003e~/.psqlrc\u003c/code\u003e file).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-FIELD-SEPARATOR-ZERO\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-z\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--field-separator-zero\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSet the field separator for unaligned output to a zero byte. This is equivalent to \u003ccode class=\"command\"\u003e\\pset fieldsep_zero\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-RECORD-SEPARATOR-ZERO\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-0\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--record-separator-zero\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSet the record separator for unaligned output to a zero byte. This is useful for interfacing, for example, with \u003ccode class=\"literal\"\u003exargs -0\u003c/code\u003e. This is equivalent to \u003ccode class=\"command\"\u003e\\pset recordsep_zero\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-SINGLE-TRANSACTION\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-1\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--single-transaction\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option can only be used in combination with one or more \u003ccode class=\"option\"\u003e-c\u003c/code\u003e and/or \u003ccode class=\"option\"\u003e-f\u003c/code\u003e options. It causes \u003cspan class=\"application\"\u003epsql\u003c/span\u003e to issue a \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e command before the first such option and a \u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e command after the last one, thereby wrapping all the commands into a single transaction. If any of the commands fails and the variable \u003ccode class=\"varname\"\u003eON_ERROR_STOP\u003c/code\u003e was set, a \u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e command is sent instead. This ensures that either all the commands complete successfully, or no changes are applied.\u003c/p\u003e\n\u003cp\u003eIf the commands themselves contain \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e, \u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e, or \u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e, this option will not have the desired effects. Also, if an individual command cannot be executed inside a transaction block, specifying this option will cause the whole transaction to fail.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-HELP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--help[=\u003cem class=\"replaceable\"\u003e\u003ccode\u003etopic\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow help about \u003cspan class=\"application\"\u003epsql\u003c/span\u003e and exit. The optional \u003cem class=\"replaceable\"\u003e\u003ccode\u003etopic\u003c/code\u003e\u003c/em\u003e parameter (defaulting to \u003ccode class=\"literal\"\u003eoptions\u003c/code\u003e) selects which part of \u003cspan class=\"application\"\u003epsql\u003c/span\u003e is explained: \u003ccode class=\"literal\"\u003ecommands\u003c/code\u003e describes \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's backslash commands; \u003ccode class=\"literal\"\u003eoptions\u003c/code\u003e describes the command-line options that can be passed to \u003cspan class=\"application\"\u003epsql\u003c/span\u003e; and \u003ccode class=\"literal\"\u003evariables\u003c/code\u003e shows help about \u003cspan class=\"application\"\u003epsql\u003c/span\u003e configuration variables.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.21.7\"\u003e\n\u003ch2\u003eExit Status\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e returns 0 to the shell if it finished normally, 1 if a fatal error of its own occurs (e.g., out of memory, file not found), 2 if the connection to the server went bad and the session was not interactive, and 3 if an error occurred in a script and the variable \u003ccode class=\"varname\"\u003eON_ERROR_STOP\u003c/code\u003e was set.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.21.8\"\u003e\n\u003ch2\u003eUsage\u003c/h2\u003e\n\u003cdiv class=\"refsect2\" id=\"R2-APP-PSQL-CONNECTING\"\u003e\n\u003ch3\u003eConnecting to a Database\u003c/h3\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e is a regular \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e client application. In order to connect to a database you need to know the name of your target database, the host name and port number of the server, and what database user name you want to connect as. \u003cspan class=\"application\"\u003epsql\u003c/span\u003e can be told about those parameters via command line options, namely \u003ccode class=\"option\"\u003e-d\u003c/code\u003e, \u003ccode class=\"option\"\u003e-h\u003c/code\u003e, \u003ccode class=\"option\"\u003e-p\u003c/code\u003e, and \u003ccode class=\"option\"\u003e-U\u003c/code\u003e respectively. If an argument is found that does not belong to any option it will be interpreted as the database name (or the database user name, if the database name is already given). Not all of these options are required; there are useful defaults. If you omit the host name, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will connect via a Unix-domain socket to a server on the local host, or via TCP/IP to \u003ccode class=\"literal\"\u003elocalhost\u003c/code\u003e on Windows. The default port number is determined at compile time. Since the database server uses the same default, you will not have to specify the port in most cases. The default database user name is your operating-system user name. Once the database user name is determined, it is used as the default database name. Note that you cannot just connect to any database under any database user name. Your database administrator should have informed you about your access rights.\u003c/p\u003e\n\u003cp\u003eWhen the defaults aren't quite right, you can save yourself some typing by setting the environment variables \u003ccode class=\"envar\"\u003ePGDATABASE\u003c/code\u003e, \u003ccode class=\"envar\"\u003ePGHOST\u003c/code\u003e, \u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e and/or \u003ccode class=\"envar\"\u003ePGUSER\u003c/code\u003e to appropriate values. (For additional environment variables, see \u003ca class=\"xref\" href=\"/docs/18/libpq-envars.html\" title=\"32.15. Environment Variables\"\u003eSection 32.15\u003c/a\u003e.) It is also convenient to have a \u003ccode class=\"filename\"\u003e~/.pgpass\u003c/code\u003e file to avoid regularly having to type in passwords. See \u003ca class=\"xref\" href=\"/docs/18/libpq-pgpass.html\" title=\"32.16. The Password File\"\u003eSection 32.16\u003c/a\u003e for more information.\u003c/p\u003e\n\u003cp\u003eAn alternative way to specify connection parameters is in a \u003cem class=\"parameter\"\u003e\u003ccode\u003econninfo\u003c/code\u003e\u003c/em\u003e string or a URI, which is used instead of a database name. This mechanism give you very wide control over the connection. For example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e$ \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epsql \"service=myservice sslmode=require\"\u003c/code\u003e\u003c/strong\u003e\n$ \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epsql postgresql://dbmaster:5433/mydb?sslmode=require\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eThis way you can also use LDAP for connection parameter lookup as described in \u003ca class=\"xref\" href=\"/docs/18/libpq-ldap.html\" title=\"32.18. LDAP Lookup of Connection Parameters\"\u003eSection 32.18\u003c/a\u003e. See \u003ca class=\"xref\" href=\"/docs/18/libpq-connect.html#LIBPQ-PARAMKEYWORDS\" title=\"32.1.2. Parameter Key Words\"\u003eSection 32.1.2\u003c/a\u003e for more information on all the available connection options.\u003c/p\u003e\n\u003cp\u003eIf the connection could not be made for any reason (e.g., insufficient privileges, server is not running on the targeted host, etc.), \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will return an error and terminate.\u003c/p\u003e\n\u003cp\u003eIf both standard input and standard output are a terminal, then \u003cspan class=\"application\"\u003epsql\u003c/span\u003e sets the client encoding to \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eauto\u003c/span\u003e”\u003c/span\u003e, which will detect the appropriate client encoding from the locale settings (\u003ccode class=\"envar\"\u003eLC_CTYPE\u003c/code\u003e environment variable on Unix systems). If this doesn't work out as expected, the client encoding can be overridden using the environment variable \u003ccode class=\"envar\"\u003ePGCLIENTENCODING\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"R2-APP-PSQL-4\"\u003e\n\u003ch3\u003eEntering SQL Commands\u003c/h3\u003e\n\u003cp\u003eIn normal operation, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e provides a prompt with the name of the database to which \u003cspan class=\"application\"\u003epsql\u003c/span\u003e is currently connected, followed by the string \u003ccode class=\"literal\"\u003e=\u0026gt;\u003c/code\u003e. For example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e$ \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epsql testdb\u003c/code\u003e\u003c/strong\u003e\npsql (18.6)\nType \"help\" for help.\n\ntestdb=\u0026gt;\n\u003c/pre\u003e\n\u003cp\u003eAt the prompt, the user can type in SQL commands. Ordinarily, input lines are sent to the server when a command-terminating semicolon is reached. An end of line does not terminate a command. Thus commands can be spread over several lines for clarity. If the command was sent and executed without error, the results of the command are displayed on the screen.\u003c/p\u003e\n\u003cp\u003eIf untrusted users have access to a database that has not adopted a \u003ca class=\"link\" href=\"/docs/18/ddl-schemas.html#DDL-SCHEMAS-PATTERNS\" title=\"5.10.6. Usage Patterns\"\u003esecure schema usage pattern\u003c/a\u003e, begin your session by removing publicly-writable schemas from \u003ccode class=\"varname\"\u003esearch_path\u003c/code\u003e. One can add \u003ccode class=\"literal\"\u003eoptions=-csearch_path=\u003c/code\u003e to the connection string or issue \u003ccode class=\"literal\"\u003eSELECT pg_catalog.set_config('search_path', '', false)\u003c/code\u003e before other SQL commands. This consideration is not specific to \u003cspan class=\"application\"\u003epsql\u003c/span\u003e; it applies to every interface for executing arbitrary SQL commands.\u003c/p\u003e\n\u003cp\u003eWhenever a command is executed, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e also polls for asynchronous notification events generated by \u003ca class=\"link\" href=\"/docs/18/sql-listen.html\" title=\"LISTEN\"\u003e\u003ccode class=\"command\"\u003eLISTEN\u003c/code\u003e\u003c/a\u003e and \u003ca class=\"link\" href=\"/docs/18/sql-notify.html\" title=\"NOTIFY\"\u003e\u003ccode class=\"command\"\u003eNOTIFY\u003c/code\u003e\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eWhile C-style block comments are passed to the server for processing and removal, SQL-standard comments are removed by \u003cspan class=\"application\"\u003epsql\u003c/span\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"APP-PSQL-META-COMMANDS\"\u003e\n\u003ch3\u003eMeta-Commands\u003c/h3\u003e\n\u003cp\u003eAnything you enter in \u003cspan class=\"application\"\u003epsql\u003c/span\u003e that begins with an unquoted backslash is a \u003cspan class=\"application\"\u003epsql\u003c/span\u003e meta-command that is processed by \u003cspan class=\"application\"\u003epsql\u003c/span\u003e itself. These commands make \u003cspan class=\"application\"\u003epsql\u003c/span\u003e more useful for administration or scripting. Meta-commands are often called slash or backslash commands.\u003c/p\u003e\n\u003cp\u003eThe format of a \u003cspan class=\"application\"\u003epsql\u003c/span\u003e command is the backslash, followed immediately by a command verb, then any arguments. The arguments are separated from the command verb and each other by any number of whitespace characters.\u003c/p\u003e\n\u003cp\u003eTo include whitespace in an argument you can quote it with single quotes. To include a single quote in an argument, write two single quotes within single-quoted text. Anything contained in single quotes is furthermore subject to C-like substitutions for \u003ccode class=\"literal\"\u003e\\n\u003c/code\u003e (new line), \u003ccode class=\"literal\"\u003e\\t\u003c/code\u003e (tab), \u003ccode class=\"literal\"\u003e\\b\u003c/code\u003e (backspace), \u003ccode class=\"literal\"\u003e\\r\u003c/code\u003e (carriage return), \u003ccode class=\"literal\"\u003e\\f\u003c/code\u003e (form feed), \u003ccode class=\"literal\"\u003e\\\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003edigits\u003c/code\u003e\u003c/em\u003e (octal), and \u003ccode class=\"literal\"\u003e\\x\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003edigits\u003c/code\u003e\u003c/em\u003e (hexadecimal). A backslash preceding any other character within single-quoted text quotes that single character, whatever it is.\u003c/p\u003e\n\u003cp\u003eIf an unquoted colon (\u003ccode class=\"literal\"\u003e:\u003c/code\u003e) followed by a \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variable name appears within an argument, it is replaced by the variable's value, as described in \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-INTERPOLATION\" title=\"SQL Interpolation\"\u003eSQL Interpolation\u003c/a\u003e below. The forms \u003ccode class=\"literal\"\u003e:'\u003cem class=\"replaceable\"\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e'\u003c/code\u003e and \u003ccode class=\"literal\"\u003e:\"\u003cem class=\"replaceable\"\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e\"\u003c/code\u003e described there work as well. The \u003ccode class=\"literal\"\u003e:{?\u003cem class=\"replaceable\"\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e}\u003c/code\u003e syntax allows testing whether a variable is defined. It is substituted by TRUE or FALSE. Escaping the colon with a backslash protects it from substitution.\u003c/p\u003e\n\u003cp\u003eWithin an argument, text that is enclosed in backquotes (\u003ccode class=\"literal\"\u003e`\u003c/code\u003e) is taken as a command line that is passed to the shell. The output of the command (with any trailing newline removed) replaces the backquoted text. Within the text enclosed in backquotes, no special quoting or other processing occurs, except that appearances of \u003ccode class=\"literal\"\u003e:\u003cem class=\"replaceable\"\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e where \u003cem class=\"replaceable\"\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e is a \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variable name are replaced by the variable's value. Also, appearances of \u003ccode class=\"literal\"\u003e:'\u003cem class=\"replaceable\"\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e'\u003c/code\u003e are replaced by the variable's value suitably quoted to become a single shell command argument. (The latter form is almost always preferable, unless you are very sure of what is in the variable.) Because carriage return and line feed characters cannot be safely quoted on all platforms, the \u003ccode class=\"literal\"\u003e:'\u003cem class=\"replaceable\"\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e'\u003c/code\u003e form prints an error message and does not substitute the variable value when such characters appear in the value.\u003c/p\u003e\n\u003cp\u003eSome commands take an SQL identifier (such as a table name) as argument. These arguments follow the syntax rules of SQL: Unquoted letters are forced to lowercase, while double quotes (\u003ccode class=\"literal\"\u003e\"\u003c/code\u003e) protect letters from case conversion and allow incorporation of whitespace into the identifier. Within double quotes, paired double quotes reduce to a single double quote in the resulting name. For example, \u003ccode class=\"literal\"\u003eFOO\"BAR\"BAZ\u003c/code\u003e is interpreted as \u003ccode class=\"literal\"\u003efooBARbaz\u003c/code\u003e, and \u003ccode class=\"literal\"\u003e\"A weird\"\" name\"\u003c/code\u003e becomes \u003ccode class=\"literal\"\u003eA weird\" name\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eParsing for arguments stops at the end of the line, or when another unquoted backslash is found. An unquoted backslash is taken as the beginning of a new meta-command. The special sequence \u003ccode class=\"literal\"\u003e\\\\\u003c/code\u003e (two backslashes) marks the end of arguments and continues parsing SQL commands, if any. That way SQL and \u003cspan class=\"application\"\u003epsql\u003c/span\u003e commands can be freely mixed on a line. But in any case, the arguments of a meta-command cannot continue beyond the end of the line.\u003c/p\u003e\n\u003cp\u003eMany of the meta-commands act on the \u003cem class=\"firstterm\"\u003ecurrent query buffer\u003c/em\u003e. This is simply a buffer holding whatever SQL command text has been typed but not yet sent to the server for execution. This will include previous input lines as well as any text appearing before the meta-command on the same line.\u003c/p\u003e\n\u003cp\u003eMany of the meta-commands also allow \u003ccode class=\"literal\"\u003ex\u003c/code\u003e to be appended as an option. This will cause the results to be displayed in expanded mode, as if \u003ccode class=\"command\"\u003e\\x\u003c/code\u003e or \u003ccode class=\"command\"\u003e\\pset expanded\u003c/code\u003e had been used.\u003c/p\u003e\n\u003cp\u003eThe following meta-commands are defined:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-A\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\a\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf 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 \u003ccode class=\"command\"\u003e\\pset\u003c/code\u003e for a more general solution.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-BIND\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\bind\u003c/code\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e ] ...\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets query parameters for the next query execution, with the specified parameters passed for any parameter placeholders (\u003ccode class=\"literal\"\u003e$1\u003c/code\u003e etc.).\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eINSERT INTO tbl1 VALUES ($1, $2) \\bind 'first value' 'second value' \\g\n\u003c/pre\u003e\n\u003cp\u003eThis also works for query-execution commands besides \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e, such as \u003ccode class=\"literal\"\u003e\\gx\u003c/code\u003e and \u003ccode class=\"literal\"\u003e\\gset\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThis command causes the extended query protocol (see \u003ca class=\"xref\" href=\"/docs/18/protocol-overview.html#PROTOCOL-QUERY-CONCEPTS\" title=\"54.1.2. Extended Query Overview\"\u003eSection 54.1.2\u003c/a\u003e) to be used, unlike normal \u003cspan class=\"application\"\u003epsql\u003c/span\u003e operation, which uses the simple query protocol. So this command can be useful to test the extended query protocol from \u003cspan class=\"application\"\u003epsql\u003c/span\u003e. (The extended query protocol is used even if the query has no parameters and this command specifies zero parameters.) This command affects only the next query executed; all subsequent queries will use the simple query protocol by default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-BIND-NAMED\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\bind_named\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003estatement_name\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e ] ...\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e\\bind_named\u003c/code\u003e is equivalent to \u003ccode class=\"literal\"\u003e\\bind\u003c/code\u003e, except that it takes the name of an existing prepared statement as first parameter. An empty string denotes the unnamed prepared statement.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eINSERT INTO tbls1 VALUES ($1, $2) \\parse stmt1\n\\bind_named stmt1 'first value' 'second value' \\g\n\u003c/pre\u003e\n\u003cp\u003eThis command causes the extended query protocol (see \u003ca class=\"xref\" href=\"/docs/18/protocol-overview.html#PROTOCOL-QUERY-CONCEPTS\" title=\"54.1.2. Extended Query Overview\"\u003eSection 54.1.2\u003c/a\u003e) to be used, unlike normal \u003cspan class=\"application\"\u003epsql\u003c/span\u003e operation, which uses the simple query protocol. So this command can be useful to test the extended query protocol from \u003cspan class=\"application\"\u003epsql\u003c/span\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-C-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\c\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\connect [ -reuse-previous=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eon|off\u003c/code\u003e\u003c/em\u003e ] [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e ] [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e ] [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e ] | \u003cem class=\"replaceable\"\u003e\u003ccode\u003econninfo\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEstablishes a new connection to a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 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 \u003cem class=\"replaceable\"\u003e\u003ccode\u003econninfo\u003c/code\u003e\u003c/em\u003e connection string as detailed in \u003ca class=\"xref\" href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"32.1.1. Connection Strings\"\u003eSection 32.1.1\u003c/a\u003e. If no arguments are given, a new connection is made using the same parameters as before.\u003c/p\u003e\n\u003cp\u003eSpecifying any of \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e or \u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e as \u003ccode class=\"literal\"\u003e-\u003c/code\u003e is equivalent to omitting that parameter.\u003c/p\u003e\n\u003cp\u003eThe new connection can re-use connection parameters from the previous connection; not only database name, user, host, and port, but other settings such as \u003cem class=\"replaceable\"\u003e\u003ccode\u003esslmode\u003c/code\u003e\u003c/em\u003e. By default, parameters are re-used in the positional syntax, but not when a \u003cem class=\"replaceable\"\u003e\u003ccode\u003econninfo\u003c/code\u003e\u003c/em\u003e string is given. Passing a first argument of \u003ccode class=\"literal\"\u003e-reuse-previous=on\u003c/code\u003e or \u003ccode class=\"literal\"\u003e-reuse-previous=off\u003c/code\u003e overrides that default. If parameters are re-used, then any parameter not explicitly specified as a positional parameter or in the \u003cem class=\"replaceable\"\u003e\u003ccode\u003econninfo\u003c/code\u003e\u003c/em\u003e string is taken from the existing connection's parameters. An exception is that if the \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e setting is changed from its previous value using the positional syntax, any \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehostaddr\u003c/code\u003e\u003c/em\u003e setting present in the existing connection's parameters is dropped. Also, any password used for the existing connection will be re-used only if the user, host, and port settings are not changed. When the command neither specifies nor reuses a particular parameter, the \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e default is used.\u003c/p\u003e\n\u003cp\u003eIf the new connection is successfully made, the previous connection is closed. If the connection attempt fails (wrong user name, access denied, etc.), the previous connection will be kept if \u003cspan class=\"application\"\u003epsql\u003c/span\u003e is in interactive mode. But when executing a non-interactive script, the old connection is closed and an error is reported. That may or may not terminate the script; if it does not, all database-accessing commands will fail until another \u003ccode class=\"literal\"\u003e\\connect\u003c/code\u003e command is successfully executed. 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. Note that whenever a \u003ccode class=\"literal\"\u003e\\connect\u003c/code\u003e command attempts to re-use parameters, the values re-used are those of the last successful connection, not of any failed attempts made subsequently. However, in the case of a non-interactive \u003ccode class=\"literal\"\u003e\\connect\u003c/code\u003e failure, no parameters are allowed to be re-used later, since the script would likely be expecting the values from the failed \u003ccode class=\"literal\"\u003e\\connect\u003c/code\u003e to be re-used.\u003c/p\u003e\n\u003cp\u003eExamples:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e=\u0026gt; \\c mydb myuser host.dom 6432\n=\u0026gt; \\c service=foo\n=\u0026gt; \\c \"host=localhost port=5432 dbname=mydb connect_timeout=10 sslmode=disable\"\n=\u0026gt; \\c -reuse-previous=on sslmode=require    -- changes only sslmode\n=\u0026gt; \\c postgresql://tom@localhost/mydb?application_name=myapp\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-C-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\C [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003etitle\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the title of any tables being printed as the result of a query or unset any such title. This command is equivalent to \u003ccode class=\"literal\"\u003e\\pset title \u003cem class=\"replaceable\"\u003e\u003ccode\u003etitle\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e. (The name of this command derives from \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003ecaption\u003c/span\u003e”\u003c/span\u003e, as it was previously only used to set the caption in an HTML table.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-CD\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\cd [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eChanges the current working directory to \u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e. Without argument, changes to the current user's home directory. For details on how home directories are found, see \u003ca class=\"xref\" href=\"/docs/18/libpq-pgpass.html\" title=\"32.16. The Password File\"\u003eSection 32.16\u003c/a\u003e.\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eTo print your current working directory, use \u003ccode class=\"literal\"\u003e\\! pwd\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-CLOSE-PREPARED\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\close_prepared\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eprepared_statement_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCloses 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.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT $1 \\parse stmt1\n\\close_prepared stmt1\n\u003c/pre\u003e\n\u003cp\u003eThis command causes the extended query protocol to be used, unlike normal \u003cspan class=\"application\"\u003epsql\u003c/span\u003e operation, which uses the simple query protocol. So this command can be useful to test the extended query protocol from \u003cspan class=\"application\"\u003epsql\u003c/span\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-CONNINFO\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\conninfo\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eOutputs information about the current database connection, including SSL-related information if SSL is in use.\u003c/p\u003e\n\u003cp\u003eNote that the \u003ccode class=\"structfield\"\u003eClient User\u003c/code\u003e field shows the user at the time of connection, while the \u003ccode class=\"structfield\"\u003eSuperuser\u003c/code\u003e field indicates whether the current user (in the current execution context) has superuser privileges. These users are usually the same, but they can differ, for example, if the current user was changed with the \u003ccode class=\"command\"\u003eSET ROLE\u003c/code\u003e command.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMANDS-COPY\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\copy { \u003cem class=\"replaceable\"\u003e\u003ccode\u003etable\u003c/code\u003e\u003c/em\u003e [ ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolumn_list\u003c/code\u003e\u003c/em\u003e ) ] } \u003ccode class=\"literal\"\u003efrom\u003c/code\u003e { \u003cem class=\"replaceable\"\u003e\u003ccode\u003e'filename'\u003c/code\u003e\u003c/em\u003e | program \u003cem class=\"replaceable\"\u003e\u003ccode\u003e'command'\u003c/code\u003e\u003c/em\u003e | stdin | pstdin } [ [ with ] ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e [, ...] ) ] [ where \u003cem class=\"replaceable\"\u003e\u003ccode\u003econdition\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\copy { \u003cem class=\"replaceable\"\u003e\u003ccode\u003etable\u003c/code\u003e\u003c/em\u003e [ ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolumn_list\u003c/code\u003e\u003c/em\u003e ) ] | ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003equery\u003c/code\u003e\u003c/em\u003e ) } \u003ccode class=\"literal\"\u003eto\u003c/code\u003e { \u003cem class=\"replaceable\"\u003e\u003ccode\u003e'filename'\u003c/code\u003e\u003c/em\u003e | program \u003cem class=\"replaceable\"\u003e\u003ccode\u003e'command'\u003c/code\u003e\u003c/em\u003e | stdout | pstdout } [ [ with ] ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e [, ...] ) ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePerforms a frontend (client) copy. This is an operation that runs an SQL \u003ca class=\"link\" href=\"/docs/18/sql-copy.html\" title=\"COPY\"\u003e\u003ccode class=\"command\"\u003eCOPY\u003c/code\u003e\u003c/a\u003e command, but instead of the server reading or writing the specified file, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e 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.\u003c/p\u003e\n\u003cp\u003eWhen \u003ccode class=\"literal\"\u003eprogram\u003c/code\u003e is specified, \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e is executed by \u003cspan class=\"application\"\u003epsql\u003c/span\u003e and the data passed from or to \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e is routed between the server and the client. Again, the execution privileges are those of the local user, not the server, and no SQL superuser privileges are required.\u003c/p\u003e\n\u003cp\u003eFor \u003ccode class=\"literal\"\u003e\\copy ... from stdin\u003c/code\u003e, data rows are read from the same source that issued the command, continuing until a line containing only \u003ccode class=\"literal\"\u003e\\.\u003c/code\u003e is read or the stream reaches EOF. This option is useful for populating tables in-line within an SQL script file. For \u003ccode class=\"literal\"\u003e\\copy ... to stdout\u003c/code\u003e, output is sent to the same place as \u003cspan class=\"application\"\u003epsql\u003c/span\u003e command output, and the \u003ccode class=\"literal\"\u003eCOPY \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e command status is not printed (since it might be confused with a data row). To read/write \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's standard input or output regardless of the current command source or \u003ccode class=\"literal\"\u003e\\o\u003c/code\u003e option, write \u003ccode class=\"literal\"\u003efrom pstdin\u003c/code\u003e or \u003ccode class=\"literal\"\u003eto pstdout\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe syntax of this command is similar to that of the SQL \u003ca class=\"link\" href=\"/docs/18/sql-copy.html\" title=\"COPY\"\u003e\u003ccode class=\"command\"\u003eCOPY\u003c/code\u003e\u003c/a\u003e command. All options other than the data source/destination are as specified for \u003ccode class=\"command\"\u003eCOPY\u003c/code\u003e. Because of this, special parsing rules apply to the \u003ccode class=\"command\"\u003e\\copy\u003c/code\u003e meta-command. Unlike most other meta-commands, the entire remainder of the line is always taken to be the arguments of \u003ccode class=\"command\"\u003e\\copy\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments.\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eAnother way to obtain the same result as \u003ccode class=\"literal\"\u003e\\copy ... to\u003c/code\u003e is to use the SQL \u003ccode class=\"literal\"\u003eCOPY ... TO STDOUT\u003c/code\u003e command and terminate it with \u003ccode class=\"literal\"\u003e\\g \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\g |\u003cem class=\"replaceable\"\u003e\u003ccode\u003eprogram\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e. Unlike \u003ccode class=\"literal\"\u003e\\copy\u003c/code\u003e, this method allows the command to span multiple lines; also, variable interpolation and backquote expansion can be used.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eThese operations are not as efficient as the SQL \u003ccode class=\"command\"\u003eCOPY\u003c/code\u003e command with a file or program data source or destination, because all data must pass through the client/server connection. For large amounts of data the SQL command might be preferable.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-COPYRIGHT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\copyright\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShows the copyright and distribution terms of \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMANDS-CROSSTABVIEW\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\crosstabview [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolD\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003esortcolH\u003c/code\u003e\u003c/em\u003e ] ] ] ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eExecutes the current query buffer (like \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e) and shows the results in a crosstab grid. The query must return at least three columns. The output column identified by \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e becomes a vertical header and the output column identified by \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e becomes a horizontal header. \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolD\u003c/code\u003e\u003c/em\u003e identifies the output column to display within the grid. \u003cem class=\"replaceable\"\u003e\u003ccode\u003esortcolH\u003c/code\u003e\u003c/em\u003e identifies an optional sort column for the horizontal header.\u003c/p\u003e\n\u003cp\u003eEach column specification can be a column number (starting at 1) or a column name. The usual SQL case folding and quoting rules apply to column names. If omitted, \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e is taken as column 1 and \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e as column 2. \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e must differ from \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolD\u003c/code\u003e\u003c/em\u003e is not specified, then there must be exactly three columns in the query result, and the column that is neither \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e nor \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e is taken to be \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolD\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eThe vertical header, displayed as the leftmost column, contains the values found in column \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e, in the same order as in the query results, but with duplicates removed.\u003c/p\u003e\n\u003cp\u003eThe horizontal header, displayed as the first row, contains the values found in column \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e, with duplicates removed. By default, these appear in the same order as in the query results. But if the optional \u003cem class=\"replaceable\"\u003e\u003ccode\u003esortcolH\u003c/code\u003e\u003c/em\u003e argument is given, it identifies a column whose values must be integer numbers, and the values from \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e will appear in the horizontal header sorted according to the corresponding \u003cem class=\"replaceable\"\u003e\u003ccode\u003esortcolH\u003c/code\u003e\u003c/em\u003e values.\u003c/p\u003e\n\u003cp\u003eInside the crosstab grid, for each distinct value \u003ccode class=\"literal\"\u003ex\u003c/code\u003e of \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e and each distinct value \u003ccode class=\"literal\"\u003ey\u003c/code\u003e of \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e, the cell located at the intersection \u003ccode class=\"literal\"\u003e(x,y)\u003c/code\u003e contains the value of the \u003ccode class=\"literal\"\u003ecolD\u003c/code\u003e column in the query result row for which the value of \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e is \u003ccode class=\"literal\"\u003ex\u003c/code\u003e and the value of \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e is \u003ccode class=\"literal\"\u003ey\u003c/code\u003e. If there is no such row, the cell is empty. If there are multiple such rows, an error is reported.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-D\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\d[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eFor each relation (table, view, materialized view, index, sequence, or foreign table) or composite type matching the \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e, show all columns, their types, the tablespace (if not the default) and any special attributes such as \u003ccode class=\"literal\"\u003eNOT NULL\u003c/code\u003e or defaults. Associated indexes, constraints, rules, and triggers are also shown. For foreign tables, the associated foreign server is shown as well. (\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eMatching the pattern\u003c/span\u003e”\u003c/span\u003e is defined in \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003ePatterns\u003c/a\u003e below.)\u003c/p\u003e\n\u003cp\u003eFor some types of relation, \u003ccode class=\"literal\"\u003e\\d\u003c/code\u003e shows additional information for each column: column values for sequences, indexed expressions for indexes, and foreign data wrapper options for foreign tables.\u003c/p\u003e\n\u003cp\u003eThe command form \u003ccode class=\"literal\"\u003e\\d+\u003c/code\u003e 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, the view definition if the relation is a view, a non-default \u003ca class=\"link\" href=\"/docs/18/sql-altertable.html#SQL-ALTERTABLE-REPLICA-IDENTITY\"\u003ereplica identity\u003c/a\u003e setting and the \u003ca class=\"link\" href=\"/docs/18/sql-create-access-method.html\" title=\"CREATE ACCESS METHOD\"\u003eaccess method\u003c/a\u003e name if the relation has an access method.\u003c/p\u003e\n\u003cp\u003eBy default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eIf \u003ccode class=\"command\"\u003e\\d\u003c/code\u003e is used without a \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e argument, it is equivalent to \u003ccode class=\"command\"\u003e\\dtvmsE\u003c/code\u003e which will show a list of all visible tables, views, materialized views, sequences and foreign tables. This is purely a convenience measure.\u003c/p\u003e\n\u003cp\u003eAs with many other commands, if \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode, but note that this only applies when \u003ccode class=\"command\"\u003e\\d\u003c/code\u003e is used without a \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e argument, and the \u003ccode class=\"literal\"\u003ex\u003c/code\u003e modifier cannot appear immediately after the \u003ccode class=\"command\"\u003e\\d\u003c/code\u003e (because \u003ccode class=\"command\"\u003e\\dx\u003c/code\u003e is a different command); the \u003ccode class=\"literal\"\u003ex\u003c/code\u003e modifier may only appear after an \u003ccode class=\"literal\"\u003eS\u003c/code\u003e or \u003ccode class=\"literal\"\u003e+\u003c/code\u003e modifier. For example, \u003ccode class=\"command\"\u003e\\d+x\u003c/code\u003e is equivalent to \u003ccode class=\"command\"\u003e\\dtvmsE+x\u003c/code\u003e and will show a list of all relations in expanded mode.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DA-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\da[Sx] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists aggregate functions, together with their return type and the data types they operate on. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only aggregates whose names match the pattern are shown. By default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DA-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dA[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists access methods. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only access methods whose names match the pattern are shown. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each access method is listed with its associated handler function and description.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DAC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dAc[x+] [\u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [\u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einput-type-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e]]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists operator classes (see \u003ca class=\"xref\" href=\"/docs/18/xindex.html#XINDEX-OPCLASS\" title=\"36.16.1. Index Methods and Operator Classes\"\u003eSection 36.16.1\u003c/a\u003e). If \u003cem class=\"replaceable\"\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e is specified, only operator classes associated with access methods whose names match that pattern are listed. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003einput-type-pattern\u003c/code\u003e\u003c/em\u003e is specified, only operator classes associated with input types whose names match that pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each operator class is listed with its associated operator family and owner.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DAF\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dAf[x+] [\u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [\u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einput-type-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e]]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists operator families (see \u003ca class=\"xref\" href=\"/docs/18/xindex.html#XINDEX-OPFAMILY\" title=\"36.16.5. Operator Classes and Operator Families\"\u003eSection 36.16.5\u003c/a\u003e). If \u003cem class=\"replaceable\"\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e is specified, only operator families associated with access methods whose names match that pattern are listed. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003einput-type-pattern\u003c/code\u003e\u003c/em\u003e is specified, only operator families associated with input types whose names match that pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each operator family is listed with its owner.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DAO\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dAo[x+] [\u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [\u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoperator-family-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e]]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists operators associated with operator families (see \u003ca class=\"xref\" href=\"/docs/18/xindex.html#XINDEX-STRATEGIES\" title=\"36.16.2. Index Method Strategies\"\u003eSection 36.16.2\u003c/a\u003e). If \u003cem class=\"replaceable\"\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e is specified, only members of operator families associated with access methods whose names match that pattern are listed. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoperator-family-pattern\u003c/code\u003e\u003c/em\u003e is specified, only members of operator families whose names match that pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DAP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dAp[x+] [\u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [\u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoperator-family-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e]]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists support functions associated with operator families (see \u003ca class=\"xref\" href=\"/docs/18/xindex.html#XINDEX-SUPPORT\" title=\"36.16.3. Index Method Support Routines\"\u003eSection 36.16.3\u003c/a\u003e). If \u003cem class=\"replaceable\"\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e is specified, only functions of operator families associated with access methods whose names match that pattern are listed. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoperator-family-pattern\u003c/code\u003e\u003c/em\u003e is specified, only functions of operator families whose names match that pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, functions are displayed verbosely, with their actual parameter lists.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DB\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\db[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists tablespaces. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only tablespaces whose names match the pattern are shown. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each tablespace is listed with its associated options, on-disk size, permissions and description.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DC-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dc[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists conversions between character-set encodings. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only conversions whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each object is listed with its associated description.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DCONFIG\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dconfig[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists server configuration parameters and their values. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only parameters whose names match the pattern are listed. Without a \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e, only parameters that are set to non-default values are listed. (Use \u003ccode class=\"literal\"\u003e\\dconfig *\u003c/code\u003e to see all parameters.) If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DC-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dC[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists type casts. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only casts whose source or target types match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DD-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dd[Sx] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShows the descriptions of objects of type \u003ccode class=\"literal\"\u003econstraint\u003c/code\u003e, \u003ccode class=\"literal\"\u003eoperator class\u003c/code\u003e, \u003ccode class=\"literal\"\u003eoperator family\u003c/code\u003e, \u003ccode class=\"literal\"\u003erule\u003c/code\u003e, and \u003ccode class=\"literal\"\u003etrigger\u003c/code\u003e. All other comments may be viewed by the respective backslash commands for those object types.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e\\dd\u003c/code\u003e displays descriptions for objects matching the \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e, or of visible objects of the appropriate type if no argument is given. But in either case, only objects that have a description are listed. By default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003cp\u003eDescriptions for objects can be created with the \u003ca class=\"link\" href=\"/docs/18/sql-comment.html\" title=\"COMMENT\"\u003e\u003ccode class=\"command\"\u003eCOMMENT\u003c/code\u003e\u003c/a\u003e SQL command.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DD-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dD[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists domains. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only domains whose names match the pattern are shown. By default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each object is listed with its associated permissions and description.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DDP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\ddp[x] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists 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 \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only entries whose role name or schema name matches the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003cp\u003eThe \u003ca class=\"link\" href=\"/docs/18/sql-alterdefaultprivileges.html\" title=\"ALTER DEFAULT PRIVILEGES\"\u003e\u003ccode class=\"command\"\u003eALTER DEFAULT PRIVILEGES\u003c/code\u003e\u003c/a\u003e command is used to set default access privileges. The meaning of the privilege display is explained in \u003ca class=\"xref\" href=\"/docs/18/ddl-priv.html\" title=\"5.8. Privileges\"\u003eSection 5.8\u003c/a\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dE[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\di[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dm[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\ds[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dt[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dv[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIn this group of commands, the letters \u003ccode class=\"literal\"\u003eE\u003c/code\u003e, \u003ccode class=\"literal\"\u003ei\u003c/code\u003e, \u003ccode class=\"literal\"\u003em\u003c/code\u003e, \u003ccode class=\"literal\"\u003es\u003c/code\u003e, \u003ccode class=\"literal\"\u003et\u003c/code\u003e, and \u003ccode class=\"literal\"\u003ev\u003c/code\u003e 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, \u003ccode class=\"literal\"\u003e\\dti\u003c/code\u003e lists tables and indexes. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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 \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only objects whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DES\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\des[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists foreign servers (mnemonic: \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eexternal servers\u003c/span\u003e”\u003c/span\u003e). If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those servers whose name matches the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\det[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists foreign tables (mnemonic: \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eexternal tables\u003c/span\u003e”\u003c/span\u003e). If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only entries whose table name or schema name matches the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, generic options and the foreign table description are also displayed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DEU\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\deu[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists user mappings (mnemonic: \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eexternal users\u003c/span\u003e”\u003c/span\u003e). If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those mappings whose user names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, additional information about each mapping is shown.\u003c/p\u003e\n\u003cdiv class=\"caution\"\u003e\n\u003ch3 class=\"title\"\u003eCaution\u003c/h3\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e\\deu+\u003c/code\u003e might also display the user name and password of the remote user, so care should be taken not to disclose them.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DEW\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dew[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists foreign-data wrappers (mnemonic: \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eexternal wrappers\u003c/span\u003e”\u003c/span\u003e). If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those foreign-data wrappers whose name matches the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, the access privileges, options, and description of the foreign-data wrapper are also shown.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DF-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\df[anptwSx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003earg_pattern\u003c/code\u003e\u003c/em\u003e ... ] ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists functions, together with their result data types, argument data types, and function types, which are classified as \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eagg\u003c/span\u003e”\u003c/span\u003e (aggregate), \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003enormal\u003c/span\u003e”\u003c/span\u003e, \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eprocedure\u003c/span\u003e”\u003c/span\u003e, \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003etrigger\u003c/span\u003e”\u003c/span\u003e, or \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003ewindow\u003c/span\u003e”\u003c/span\u003e. To display only functions of specific type(s), add the corresponding letters \u003ccode class=\"literal\"\u003ea\u003c/code\u003e, \u003ccode class=\"literal\"\u003en\u003c/code\u003e, \u003ccode class=\"literal\"\u003ep\u003c/code\u003e, \u003ccode class=\"literal\"\u003et\u003c/code\u003e, or \u003ccode class=\"literal\"\u003ew\u003c/code\u003e to the command. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e 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 \u003ccode class=\"literal\"\u003e-\u003c/code\u003e as the last \u003cem class=\"replaceable\"\u003e\u003ccode\u003earg_pattern\u003c/code\u003e\u003c/em\u003e.) By default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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 \u003ccode class=\"literal\"\u003e\\sf\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DF-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dF[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists text search configurations. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only configurations whose names match the pattern are shown. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DFD\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dFd[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists text search dictionaries. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only dictionaries whose names match the pattern are shown. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, additional information is shown about each selected dictionary, including the underlying text search template and the option values.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DFP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dFp[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists text search parsers. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only parsers whose names match the pattern are shown. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DFT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dFt[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists text search templates. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only templates whose names match the pattern are shown. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, additional information is shown about each template, including the underlying function names.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DG\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dg[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists database roles. (Since the concepts of \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eusers\u003c/span\u003e”\u003c/span\u003e and \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003egroups\u003c/span\u003e”\u003c/span\u003e have been unified into \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eroles\u003c/span\u003e”\u003c/span\u003e, this command is now equivalent to \u003ccode class=\"literal\"\u003e\\du\u003c/code\u003e.) By default, only user-created roles are shown; supply the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system roles. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those roles whose names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, additional information is shown about each role; currently this adds the comment for each role.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DL-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dl[x+]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis is an alias for \u003ccode class=\"command\"\u003e\\lo_list\u003c/code\u003e, which shows a list of large objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each large object is listed with its associated permissions, if any.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DL-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dL[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists procedural languages. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only languages whose names match the pattern are listed. By default, only user-created languages are shown; supply the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each language is listed with its call handler, validator, access privileges, and whether it is a system object.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dn[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists schemas (namespaces). If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only schemas whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each object is listed with its associated permissions and description, if any.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DO-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\do[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003earg_pattern\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003earg_pattern\u003c/code\u003e\u003c/em\u003e ] ] ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists operators with their operand and result types. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only operators whose names match the pattern are listed. If one \u003cem class=\"replaceable\"\u003e\u003ccode\u003earg_pattern\u003c/code\u003e\u003c/em\u003e is specified, only prefix operators whose right argument's type name matches that pattern are listed. If two \u003cem class=\"replaceable\"\u003e\u003ccode\u003earg_pattern\u003c/code\u003e\u003c/em\u003es are specified, only binary operators whose argument type names match those patterns are listed. (Alternatively, write \u003ccode class=\"literal\"\u003e-\u003c/code\u003e for the unused argument of a unary operator.) By default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DO-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dO[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists collations. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only collations whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DP-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dp[Sx] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists tables, views and sequences with their associated access privileges. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e 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 \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003cp\u003eThe \u003ca class=\"link\" href=\"/docs/18/sql-grant.html\" title=\"GRANT\"\u003e\u003ccode class=\"command\"\u003eGRANT\u003c/code\u003e\u003c/a\u003e and \u003ca class=\"link\" href=\"/docs/18/sql-revoke.html\" title=\"REVOKE\"\u003e\u003ccode class=\"command\"\u003eREVOKE\u003c/code\u003e\u003c/a\u003e commands are used to set access privileges. The meaning of the privilege display is explained in \u003ca class=\"xref\" href=\"/docs/18/ddl-priv.html\" title=\"5.8. Privileges\"\u003eSection 5.8\u003c/a\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DP-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dP[itnx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists partitioned relations. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only entries whose name matches the pattern are listed. The modifiers \u003ccode class=\"literal\"\u003et\u003c/code\u003e (tables) and \u003ccode class=\"literal\"\u003ei\u003c/code\u003e (indexes) can be appended to the command, filtering the kind of relations to list. By default, partitioned tables and indexes are listed.\u003c/p\u003e\n\u003cp\u003eIf the modifier \u003ccode class=\"literal\"\u003en\u003c/code\u003e (\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003enested\u003c/span\u003e”\u003c/span\u003e) is used, or a pattern is specified, then non-root partitioned relations are included, and a column is shown displaying the parent of each partitioned relation.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, the sum of the sizes of each relation's partitions is also displayed, along with the relation's description. If \u003ccode class=\"literal\"\u003en\u003c/code\u003e is combined with \u003ccode class=\"literal\"\u003e+\u003c/code\u003e, two sizes are shown: one including the total size of directly-attached leaf partitions, and another showing the total size of all partitions, including indirectly attached sub-partitions.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DRDS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\drds[x] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003erole-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003edatabase-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ] ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists defined configuration settings. These settings can be role-specific, database-specific, or both. \u003cem class=\"replaceable\"\u003e\u003ccode\u003erole-pattern\u003c/code\u003e\u003c/em\u003e and \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatabase-pattern\u003c/code\u003e\u003c/em\u003e are used to select specific roles and databases to list, respectively. If omitted, or if \u003ccode class=\"literal\"\u003e*\u003c/code\u003e is specified, all settings are listed, including those not role-specific or database-specific, respectively. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003cp\u003eThe \u003ca class=\"link\" href=\"/docs/18/sql-alterrole.html\" title=\"ALTER ROLE\"\u003e\u003ccode class=\"command\"\u003eALTER ROLE\u003c/code\u003e\u003c/a\u003e and \u003ca class=\"link\" href=\"/docs/18/sql-alterdatabase.html\" title=\"ALTER DATABASE\"\u003e\u003ccode class=\"command\"\u003eALTER DATABASE\u003c/code\u003e\u003c/a\u003e commands are used to define per-role and per-database configuration settings.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DRG\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\drg[Sx] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists information about each granted role membership, including assigned options (\u003ccode class=\"literal\"\u003eADMIN\u003c/code\u003e, \u003ccode class=\"literal\"\u003eINHERIT\u003c/code\u003e and/or \u003ccode class=\"literal\"\u003eSET\u003c/code\u003e) and grantor. See the \u003ca class=\"link\" href=\"/docs/18/sql-grant.html\" title=\"GRANT\"\u003e\u003ccode class=\"command\"\u003eGRANT\u003c/code\u003e\u003c/a\u003e command for information about role memberships.\u003c/p\u003e\n\u003cp\u003eBy default, only grants to user-created roles are shown; supply the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system roles. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only grants to those roles whose names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DRP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dRp[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists replication publications. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those publications whose names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, the tables and schemas associated with each publication are shown as well.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DRS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dRs[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists replication subscriptions. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those subscriptions whose names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, additional properties of the subscriptions are shown.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dT[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists data types. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only types whose names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each type is listed with its internal name and size, its allowed values if it is an \u003ccode class=\"type\"\u003eenum\u003c/code\u003e type, and its associated permissions. By default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DU\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\du[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists database roles. (Since the concepts of \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eusers\u003c/span\u003e”\u003c/span\u003e and \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003egroups\u003c/span\u003e”\u003c/span\u003e have been unified into \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eroles\u003c/span\u003e”\u003c/span\u003e, this command is now equivalent to \u003ccode class=\"literal\"\u003e\\dg\u003c/code\u003e.) By default, only user-created roles are shown; supply the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system roles. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those roles whose names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, additional information is shown about each role; currently this adds the comment for each role.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DX-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dx[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists installed extensions. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those extensions whose names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, all the objects belonging to each matching extension are listed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DX-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dX[x] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists extended statistics. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those extended statistics whose names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003cp\u003eThe status of each kind of extended statistics is shown in a column named after its statistic kind (e.g. Ndistinct). \u003ccode class=\"literal\"\u003edefined\u003c/code\u003e means that it was requested when creating the statistics, and NULL means it wasn't requested. You can use \u003ccode class=\"structname\"\u003epg_stats_ext\u003c/code\u003e if you'd like to know whether \u003ca class=\"link\" href=\"/docs/18/sql-analyze.html\" title=\"ANALYZE\"\u003e\u003ccode class=\"command\"\u003eANALYZE\u003c/code\u003e\u003c/a\u003e was run and statistics are available to the planner.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DY\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dy[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists event triggers. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those event triggers whose names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each object is listed with its associated description.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-EDIT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\e\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\edit\u003c/code\u003e \u003ccode class=\"literal\"\u003e[ \u003cspan class=\"optional\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ] [ \u003cspan class=\"optional\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eline_number\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e is specified, the file is edited; after the editor exits, the file's content is copied into the current query buffer. If no \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e 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.\u003c/p\u003e\n\u003cp\u003eIf you edit a file or the previous query, and you quit the editor without modifying the file, the query buffer is cleared. Otherwise, the new contents of the query buffer are re-parsed according to the normal rules of \u003cspan class=\"application\"\u003epsql\u003c/span\u003e, treating the whole buffer as a single line. Any complete queries are immediately executed; that is, if the query buffer contains or ends with a semicolon, everything up to that point is executed and removed from the query buffer. Whatever remains in the query buffer is redisplayed. Type semicolon or \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e to send it, or \u003ccode class=\"literal\"\u003e\\r\u003c/code\u003e to cancel it by clearing the query buffer.\u003c/p\u003e\n\u003cp\u003eTreating the buffer as a single line primarily affects meta-commands: whatever is in the buffer after a meta-command will be taken as argument(s) to the meta-command, even if it spans multiple lines. (Thus you cannot make meta-command-using scripts this way. Use \u003ccode class=\"command\"\u003e\\i\u003c/code\u003e for that.)\u003c/p\u003e\n\u003cp\u003eIf a line number is specified, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will position the cursor on the specified line of the file or query buffer. Note that if a single all-digits argument is given, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e assumes it is a line number, not a file name.\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eSee \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-ENVIRONMENT\" title=\"Environment\"\u003eEnvironment\u003c/a\u003e, below, for how to configure and customize your editor.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-ECHO\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\echo \u003cem class=\"replaceable\"\u003e\u003ccode\u003etext\u003c/code\u003e\u003c/em\u003e [ ... ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrints 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:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\echo `date`\u003c/code\u003e\u003c/strong\u003e\nTue Oct 26 21:40:57 CEST 1999\n\u003c/pre\u003e\n\u003cp\u003eIf the first argument is an unquoted \u003ccode class=\"literal\"\u003e-n\u003c/code\u003e the trailing newline is not written (nor is the first argument).\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eIf you use the \u003ccode class=\"command\"\u003e\\o\u003c/code\u003e command to redirect your query output you might wish to use \u003ccode class=\"command\"\u003e\\qecho\u003c/code\u003e instead of this command. See also \u003ccode class=\"command\"\u003e\\warn\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-EF\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\ef [ \u003cspan class=\"optional\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003efunction_description\u003c/code\u003e\u003c/em\u003e [ \u003cspan class=\"optional\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eline_number\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ]\u003c/span\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command fetches and edits the definition of the named function or procedure, in the form of a \u003ccode class=\"command\"\u003eCREATE OR REPLACE FUNCTION\u003c/code\u003e or \u003ccode class=\"command\"\u003eCREATE OR REPLACE PROCEDURE\u003c/code\u003e command. Editing is done in the same way as for \u003ccode class=\"literal\"\u003e\\edit\u003c/code\u003e. 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 \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e to send it, or \u003ccode class=\"literal\"\u003e\\r\u003c/code\u003e to cancel.\u003c/p\u003e\n\u003cp\u003eThe target function can be specified by name alone, or by name and arguments, for example \u003ccode class=\"literal\"\u003efoo(integer, text)\u003c/code\u003e. The argument types must be given if there is more than one function of the same name.\u003c/p\u003e\n\u003cp\u003eIf no function is specified, a blank \u003ccode class=\"command\"\u003eCREATE FUNCTION\u003c/code\u003e template is presented for editing.\u003c/p\u003e\n\u003cp\u003eIf a line number is specified, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will position the cursor on the specified line of the function body. (Note that the function body typically does not begin on the first line of the file.)\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument(s) of \u003ccode class=\"command\"\u003e\\ef\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments.\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eSee \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-ENVIRONMENT\" title=\"Environment\"\u003eEnvironment\u003c/a\u003e, below, for how to configure and customize your editor.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-ENCODING\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\encoding [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eencoding\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the client character set encoding. Without an argument, this command shows the current encoding.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-ERRVERBOSE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\errverbose\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRepeats the most recent server error message at maximum verbosity, as though \u003ccode class=\"varname\"\u003eVERBOSITY\u003c/code\u003e were set to \u003ccode class=\"literal\"\u003everbose\u003c/code\u003e and \u003ccode class=\"varname\"\u003eSHOW_CONTEXT\u003c/code\u003e were set to \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-EV\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\ev [ \u003cspan class=\"optional\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eview_name\u003c/code\u003e\u003c/em\u003e [ \u003cspan class=\"optional\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eline_number\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ]\u003c/span\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command fetches and edits the definition of the named view, in the form of a \u003ccode class=\"command\"\u003eCREATE OR REPLACE VIEW\u003c/code\u003e command. Editing is done in the same way as for \u003ccode class=\"literal\"\u003e\\edit\u003c/code\u003e. 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 \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e to send it, or \u003ccode class=\"literal\"\u003e\\r\u003c/code\u003e to cancel.\u003c/p\u003e\n\u003cp\u003eIf no view is specified, a blank \u003ccode class=\"command\"\u003eCREATE VIEW\u003c/code\u003e template is presented for editing.\u003c/p\u003e\n\u003cp\u003eIf a line number is specified, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will position the cursor on the specified line of the view definition.\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument(s) of \u003ccode class=\"command\"\u003e\\ev\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-F\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\f [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the field separator for unaligned query output. The default is the vertical bar (\u003ccode class=\"literal\"\u003e|\u003c/code\u003e). It is equivalent to \u003ccode class=\"command\"\u003e\\pset fieldsep\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-G\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\g [ (\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [...]) ] [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\g [ (\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [...]) ] [ |\u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSends the current query buffer to the server for execution.\u003c/p\u003e\n\u003cp\u003eIf parentheses appear after \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e, they surround a space-separated list of \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e\u003ccode class=\"literal\"\u003e=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e formatting-option clauses, which are interpreted in the same way as \u003ccode class=\"literal\"\u003e\\pset\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e commands, but take effect only for the duration of this query. In this list, spaces are not allowed around \u003ccode class=\"literal\"\u003e=\u003c/code\u003e signs, but are required between option clauses. If \u003ccode class=\"literal\"\u003e=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is omitted, the named \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e is changed in the same way as for \u003ccode class=\"literal\"\u003e\\pset\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e with no explicit \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eIf a \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e or \u003ccode class=\"literal\"\u003e|\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e argument is given, the query's output is written to the named file or piped to the given shell command, instead of displaying it as usual. The file or command is written to only if the query successfully returns zero or more tuples, not if the query fails or is a non-data-returning SQL command.\u003c/p\u003e\n\u003cp\u003eIf the current query buffer is empty, the most recently sent query is re-executed instead. Except for that behavior, \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e without any arguments is essentially equivalent to a semicolon. With arguments, \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e provides a \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eone-shot\u003c/span\u003e”\u003c/span\u003e alternative to the \u003ccode class=\"command\"\u003e\\o\u003c/code\u003e command, and additionally allows one-shot adjustments of the output formatting options normally set by \u003ccode class=\"literal\"\u003e\\pset\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eWhen the last argument begins with \u003ccode class=\"literal\"\u003e|\u003c/code\u003e, the entire remainder of the line is taken to be the \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e to execute, and neither variable interpolation nor backquote expansion are performed in it. The rest of the line is simply passed literally to the shell.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-GDESC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\gdesc\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShows 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.\u003c/p\u003e\n\u003cp\u003eIf the current query buffer is empty, the most recently sent query is described instead.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-GETENV\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\getenv \u003cem class=\"replaceable\"\u003e\u003ccode\u003epsql_var\u003c/code\u003e\u003c/em\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eenv_var\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eGets the value of the environment variable \u003cem class=\"replaceable\"\u003e\u003ccode\u003eenv_var\u003c/code\u003e\u003c/em\u003e and assigns it to the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variable \u003cem class=\"replaceable\"\u003e\u003ccode\u003epsql_var\u003c/code\u003e\u003c/em\u003e. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003eenv_var\u003c/code\u003e\u003c/em\u003e is not defined in the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e process's environment, \u003cem class=\"replaceable\"\u003e\u003ccode\u003epsql_var\u003c/code\u003e\u003c/em\u003e is not changed. Example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\getenv home HOME\u003c/code\u003e\u003c/strong\u003e\n=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\echo :home\u003c/code\u003e\u003c/strong\u003e\n/home/postgres\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-GEXEC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\gexec\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSends 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 \u003ccode class=\"structname\"\u003emy_table\u003c/code\u003e:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT format('create index on my_table(%I)', attname)\u003c/code\u003e\u003c/strong\u003e\n-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eFROM pg_attribute\u003c/code\u003e\u003c/strong\u003e\n-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eWHERE attrelid = 'my_table'::regclass AND attnum \u0026gt; 0\u003c/code\u003e\u003c/strong\u003e\n-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eORDER BY attnum\u003c/code\u003e\u003c/strong\u003e\n-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\gexec\u003c/code\u003e\u003c/strong\u003e\nCREATE INDEX\nCREATE INDEX\nCREATE INDEX\nCREATE INDEX\n\u003c/pre\u003e\n\u003cp\u003eThe generated queries are executed in the order in which the rows are returned, and left-to-right within each row if there is more than one column. NULL fields are ignored. The generated queries are sent literally to the server for processing, so they cannot be \u003cspan class=\"application\"\u003epsql\u003c/span\u003e meta-commands nor contain \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variable references. If any individual query fails, execution of the remaining queries continues unless \u003ccode class=\"varname\"\u003eON_ERROR_STOP\u003c/code\u003e is set. Execution of each query is subject to \u003ccode class=\"varname\"\u003eECHO\u003c/code\u003e processing. (Setting \u003ccode class=\"varname\"\u003eECHO\u003c/code\u003e to \u003ccode class=\"literal\"\u003eall\u003c/code\u003e or \u003ccode class=\"literal\"\u003equeries\u003c/code\u003e is often advisable when using \u003ccode class=\"command\"\u003e\\gexec\u003c/code\u003e.) Query logging, single-step mode, timing, and other query execution features apply to each generated query as well.\u003c/p\u003e\n\u003cp\u003eIf the current query buffer is empty, the most recently sent query is re-executed instead.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-GSET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\gset [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSends the current query buffer to the server and stores the query's output into \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variables (see \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-VARIABLES\" title=\"Variables\"\u003eVariables\u003c/a\u003e 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:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT 'hello' AS var1, 10 AS var2\u003c/code\u003e\u003c/strong\u003e\n-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\gset\u003c/code\u003e\u003c/strong\u003e\n=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\echo :var1 :var2\u003c/code\u003e\u003c/strong\u003e\nhello 10\n\u003c/pre\u003e\n\u003cp\u003eIf you specify a \u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e, that string is prepended to the query's column names to create the variable names to use:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT 'hello' AS var1, 10 AS var2\u003c/code\u003e\u003c/strong\u003e\n-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\gset result_\u003c/code\u003e\u003c/strong\u003e\n=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\echo :result_var1 :result_var2\u003c/code\u003e\u003c/strong\u003e\nhello 10\n\u003c/pre\u003e\n\u003cp\u003eIf a column result is NULL, the corresponding variable is unset rather than being set.\u003c/p\u003e\n\u003cp\u003eIf the query fails or does not return one row, no variables are changed.\u003c/p\u003e\n\u003cp\u003eIf the current query buffer is empty, the most recently sent query is re-executed instead.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-GX\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\gx [ (\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [...]) ] [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\gx [ (\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [...]) ] [ |\u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e\\gx\u003c/code\u003e is equivalent to \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e, except that it forces expanded output mode for this query, as if \u003ccode class=\"literal\"\u003eexpanded=on\u003c/code\u003e were included in the list of \u003ccode class=\"literal\"\u003e\\pset\u003c/code\u003e options. See also \u003ccode class=\"literal\"\u003e\\x\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-HELP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\h\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\help\u003c/code\u003e \u003ccode class=\"literal\"\u003e[ \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eGives syntax help on the specified SQL command. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e is not specified, then \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will list all the commands for which syntax help is available. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e is an asterisk (\u003ccode class=\"literal\"\u003e*\u003c/code\u003e), then syntax help on all SQL commands is shown.\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument(s) of \u003ccode class=\"command\"\u003e\\help\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eTo simplify typing, commands that consists of several words do not have to be quoted. Thus it is fine to type \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\help alter table\u003c/code\u003e\u003c/strong\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-HTML\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\H\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\html\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eTurns 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 \u003ccode class=\"command\"\u003e\\pset\u003c/code\u003e about setting other output options.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-INCLUDE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\i\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\include\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eReads input from the file \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e and executes it as though it had been typed on the keyboard.\u003c/p\u003e\n\u003cp\u003eIf \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e is \u003ccode class=\"literal\"\u003e-\u003c/code\u003e (hyphen), then standard input is read until an EOF indication or \u003ccode class=\"command\"\u003e\\q\u003c/code\u003e meta-command. This can be used to intersperse interactive input with input from files. Note that Readline behavior will be used only if it is active at the outermost level.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eIf you want to see the lines on the screen as they are read you must set the variable \u003ccode class=\"varname\"\u003eECHO\u003c/code\u003e to \u003ccode class=\"literal\"\u003eall\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PSQL-METACOMMAND-IF\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\if\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\elif\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\else\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\endif\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis group of commands implements nestable conditional blocks. A conditional block must begin with an \u003ccode class=\"command\"\u003e\\if\u003c/code\u003e and end with an \u003ccode class=\"command\"\u003e\\endif\u003c/code\u003e. In between there may be any number of \u003ccode class=\"command\"\u003e\\elif\u003c/code\u003e clauses, which may optionally be followed by a single \u003ccode class=\"command\"\u003e\\else\u003c/code\u003e clause. Ordinary queries and other types of backslash commands may (and usually do) appear between the commands forming a conditional block.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode class=\"command\"\u003e\\if\u003c/code\u003e and \u003ccode class=\"command\"\u003e\\elif\u003c/code\u003e commands read their argument(s) and evaluate them as a Boolean expression. If the expression yields \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e then processing continues normally; otherwise, lines are skipped until a matching \u003ccode class=\"command\"\u003e\\elif\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\else\u003c/code\u003e, or \u003ccode class=\"command\"\u003e\\endif\u003c/code\u003e is reached. Once an \u003ccode class=\"command\"\u003e\\if\u003c/code\u003e or \u003ccode class=\"command\"\u003e\\elif\u003c/code\u003e test has succeeded, the arguments of later \u003ccode class=\"command\"\u003e\\elif\u003c/code\u003e commands in the same block are not evaluated but are treated as false. Lines following an \u003ccode class=\"command\"\u003e\\else\u003c/code\u003e are processed only if no earlier matching \u003ccode class=\"command\"\u003e\\if\u003c/code\u003e or \u003ccode class=\"command\"\u003e\\elif\u003c/code\u003e succeeded.\u003c/p\u003e\n\u003cp\u003eThe \u003cem class=\"replaceable\"\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e argument of an \u003ccode class=\"command\"\u003e\\if\u003c/code\u003e or \u003ccode class=\"command\"\u003e\\elif\u003c/code\u003e command is subject to variable interpolation and backquote expansion, just like any other backslash command argument. After that it is evaluated like the value of an on/off option variable. So a valid value is any unambiguous case-insensitive match for one of: \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e, \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e, \u003ccode class=\"literal\"\u003e1\u003c/code\u003e, \u003ccode class=\"literal\"\u003e0\u003c/code\u003e, \u003ccode class=\"literal\"\u003eon\u003c/code\u003e, \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e, \u003ccode class=\"literal\"\u003eyes\u003c/code\u003e, \u003ccode class=\"literal\"\u003eno\u003c/code\u003e. For example, \u003ccode class=\"literal\"\u003et\u003c/code\u003e, \u003ccode class=\"literal\"\u003eT\u003c/code\u003e, and \u003ccode class=\"literal\"\u003etR\u003c/code\u003e will all be considered to be \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eExpressions that do not properly evaluate to true or false will generate a warning and be treated as false.\u003c/p\u003e\n\u003cp\u003eLines being skipped are parsed normally to identify queries and backslash commands, but queries are not sent to the server, and backslash commands other than conditionals (\u003ccode class=\"command\"\u003e\\if\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\elif\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\else\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\endif\u003c/code\u003e) are ignored. Conditional commands are checked only for valid nesting. Variable references in skipped lines are not expanded, and backquote expansion is not performed either.\u003c/p\u003e\n\u003cp\u003eAll the backslash commands of a given conditional block must appear in the same source file. If EOF is reached on the main input file or an \u003ccode class=\"command\"\u003e\\include\u003c/code\u003e-ed file before all local \u003ccode class=\"command\"\u003e\\if\u003c/code\u003e-blocks have been closed, then \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will raise an error.\u003c/p\u003e\n\u003cp\u003eHere is an example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e-- check for the existence of two separate records in the database and store\n-- the results in separate psql variables\nSELECT\n    EXISTS(SELECT 1 FROM customer WHERE customer_id = 123) as is_customer,\n    EXISTS(SELECT 1 FROM employee WHERE employee_id = 456) as is_employee\n\\gset\n\\if :is_customer\n    SELECT * FROM customer WHERE customer_id = 123;\n\\elif :is_employee\n    \\echo 'is not a customer but is an employee'\n    SELECT * FROM employee WHERE employee_id = 456;\n\\else\n    \\if yes\n        \\echo 'not a customer or employee'\n    \\else\n        \\echo 'this will never print'\n    \\endif\n\\endif\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-INCLUDE-RELATIVE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\ir\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\include_relative\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe \u003ccode class=\"literal\"\u003e\\ir\u003c/code\u003e command is similar to \u003ccode class=\"literal\"\u003e\\i\u003c/code\u003e, but resolves relative file names differently. When executing in interactive mode, the two commands behave identically. However, when invoked from a script, \u003ccode class=\"literal\"\u003e\\ir\u003c/code\u003e interprets file names relative to the directory in which the script is located, rather than the current working directory.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-LIST\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\l[x+]\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\list[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eList the databases in the server and show their names, owners, character set encodings, and access privileges. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only databases whose names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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 \u003ccode class=\"literal\"\u003eCONNECT\u003c/code\u003e privilege, or if the current user is a superuser or has privileges of the \u003ccode class=\"literal\"\u003epg_read_all_stats\u003c/code\u003e role.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-LO-EXPORT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\lo_export \u003cem class=\"replaceable\"\u003e\u003ccode\u003eloid\u003c/code\u003e\u003c/em\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eReads the large object with OID \u003cem class=\"replaceable\"\u003e\u003ccode\u003eloid\u003c/code\u003e\u003c/em\u003e from the database and writes it to \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e. Note that this is subtly different from the server function \u003ccode class=\"function\"\u003elo_export\u003c/code\u003e, which acts with the permissions of the user that the database server runs as and on the server's file system.\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eUse \u003ccode class=\"command\"\u003e\\lo_list\u003c/code\u003e to find out the large object's OID.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-LO-IMPORT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\lo_import \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecomment\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eStores the file into a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e large object. Optionally, it associates the given comment with the object. Example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003efoo=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\lo_import '/home/peter/pictures/photo.xcf' 'a picture of me'\u003c/code\u003e\u003c/strong\u003e\nlo_import 152801\n\u003c/pre\u003e\n\u003cp\u003eThe response indicates that the large object received object ID 152801, which can be used to access the newly-created large object in the future. For the sake of readability, it is recommended to always associate a human-readable comment with every object. Both OIDs and comments can be viewed with the \u003ccode class=\"command\"\u003e\\lo_list\u003c/code\u003e command.\u003c/p\u003e\n\u003cp\u003eNote that this command is subtly different from the server-side \u003ccode class=\"function\"\u003elo_import\u003c/code\u003e because it acts as the local user on the local file system, rather than the server's user and file system.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-LO-LIST\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\lo_list[x+]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShows a list of all \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e large objects currently stored in the database, along with any comments provided for them. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each large object is listed with its associated permissions, if any.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-LO-UNLINK\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\lo_unlink \u003cem class=\"replaceable\"\u003e\u003ccode\u003eloid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDeletes the large object with OID \u003cem class=\"replaceable\"\u003e\u003ccode\u003eloid\u003c/code\u003e\u003c/em\u003e from the database.\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eUse \u003ccode class=\"command\"\u003e\\lo_list\u003c/code\u003e to find out the large object's OID.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-OUT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\o\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\out [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\o\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\out [ |\u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eArranges to save future query results to the file \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e or pipe future results to the shell command \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e. If no argument is specified, the query output is reset to the standard output.\u003c/p\u003e\n\u003cp\u003eIf the argument begins with \u003ccode class=\"literal\"\u003e|\u003c/code\u003e, then the entire remainder of the line is taken to be the \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e to execute, and neither variable interpolation nor backquote expansion are performed in it. The rest of the line is simply passed literally to the shell.\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eQuery results\u003c/span\u003e”\u003c/span\u003e includes all tables, command responses, and notices obtained from the database server, as well as output of various backslash commands that query the database (such as \u003ccode class=\"command\"\u003e\\d\u003c/code\u003e); but not error messages.\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eTo intersperse text output in between query results, use \u003ccode class=\"command\"\u003e\\qecho\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PRINT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\p\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\print\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint the current query buffer to the standard output. If the current query buffer is empty, the most recently executed query is printed instead.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PARSE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\parse \u003cem class=\"replaceable\"\u003e\u003ccode\u003estatement_name\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreates 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.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT $1 \\parse stmt1\n\u003c/pre\u003e\n\u003cp\u003eThis command causes the extended query protocol to be used, unlike normal \u003cspan class=\"application\"\u003epsql\u003c/span\u003e operation, which uses the simple query protocol. A \u003ca class=\"xref\" href=\"/docs/18/protocol-message-formats.html#PROTOCOL-MESSAGE-FORMATS-PARSE\"\u003eParse (F)\u003c/a\u003e message will be issued by this command so it can be useful to test the extended query protocol from \u003cspan class=\"application\"\u003epsql\u003c/span\u003e. This command affects only the next query executed; all subsequent queries will use the simple query protocol by default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PASSWORD\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\password [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eChanges 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 \u003ccode class=\"command\"\u003eALTER ROLE\u003c/code\u003e command. This makes sure that the new password does not appear in cleartext in the command history, the server log, or elsewhere.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PROMPT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\prompt [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003etext\u003c/code\u003e\u003c/em\u003e ] \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrompts the user to supply text, which is assigned to the variable \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e. An optional prompt string, \u003cem class=\"replaceable\"\u003e\u003ccode\u003etext\u003c/code\u003e\u003c/em\u003e, can be specified. (For multiword prompts, surround the text with single quotes.)\u003c/p\u003e\n\u003cp\u003eBy default, \u003ccode class=\"literal\"\u003e\\prompt\u003c/code\u003e uses the terminal for input and output. However, if the \u003ccode class=\"option\"\u003e-f\u003c/code\u003e command line switch was used, \u003ccode class=\"literal\"\u003e\\prompt\u003c/code\u003e uses standard input and standard output.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\pset [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e ] ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command sets options affecting the output of query result tables. \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e indicates which option is to be set. The semantics of \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e vary depending on the selected option. For some options, omitting \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e causes the option to be toggled or unset, as described under the particular option. If no such behavior is mentioned, then omitting \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e just results in the current setting being displayed.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003e\\pset\u003c/code\u003e without any arguments displays the current status of all printing options.\u003c/p\u003e\n\u003cp\u003eAdjustable printing options are:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-BORDER\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eborder\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e must be a number. In general, the higher the number the more borders and lines the tables will have, but details depend on the particular format. In HTML format, this will translate directly into the \u003ccode class=\"literal\"\u003eborder=...\u003c/code\u003e attribute. In most other formats only values 0 (no border), 1 (internal dividing lines), and 2 (table frame) make sense, and values above 2 will be treated the same as \u003ccode class=\"literal\"\u003eborder = 2\u003c/code\u003e. The \u003ccode class=\"literal\"\u003elatex\u003c/code\u003e and \u003ccode class=\"literal\"\u003elatex-longtable\u003c/code\u003e formats additionally allow a value of 3 to add dividing lines between data rows.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-COLUMNS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ecolumns\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the target width for the \u003ccode class=\"literal\"\u003ewrapped\u003c/code\u003e format, and also the width limit for determining whether output is wide enough to require the pager or switch to the vertical display in expanded auto mode. Zero (the default) causes the target width to be controlled by the environment variable \u003ccode class=\"envar\"\u003eCOLUMNS\u003c/code\u003e, or the detected screen width if \u003ccode class=\"envar\"\u003eCOLUMNS\u003c/code\u003e is not set. In addition, if \u003ccode class=\"literal\"\u003ecolumns\u003c/code\u003e is zero then the \u003ccode class=\"literal\"\u003ewrapped\u003c/code\u003e format only affects screen output. If \u003ccode class=\"literal\"\u003ecolumns\u003c/code\u003e is nonzero then file and pipe output is wrapped to that width as well.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-CSV-FIELDSEP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ecsv_fieldsep\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the field separator to be used in CSV output format. If the separator character appears in a field's value, that field is output within double quotes, following standard CSV rules. The default is a comma.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-EXPANDED\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eexpanded\u003c/code\u003e (or \u003ccode class=\"literal\"\u003ex\u003c/code\u003e)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is specified it must be either \u003ccode class=\"literal\"\u003eon\u003c/code\u003e or \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e, which will enable or disable expanded mode, or \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is omitted the command toggles between the on and off settings. When expanded mode 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 \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003ehorizontal\u003c/span\u003e”\u003c/span\u003e mode. In the auto setting, the expanded mode is used whenever the query output has more than one column and is wider than the screen; otherwise, the regular mode is used. The auto setting is only effective in the aligned and wrapped formats. In other formats, it always behaves as if the expanded mode is off.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-FIELDSEP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003efieldsep\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the field separator to be used in unaligned output format. That way one can create, for example, tab-separated output, which other programs might prefer. To set a tab as field separator, type \u003ccode class=\"literal\"\u003e\\pset fieldsep '\\t'\u003c/code\u003e. The default field separator is \u003ccode class=\"literal\"\u003e'|'\u003c/code\u003e (a vertical bar).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-FIELDSEP-ZERO\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003efieldsep_zero\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the field separator to use in unaligned output format to a zero byte.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-FOOTER\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003efooter\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is specified it must be either \u003ccode class=\"literal\"\u003eon\u003c/code\u003e or \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e which will enable or disable display of the table footer (the \u003ccode class=\"literal\"\u003e(\u003cem class=\"replaceable\"\u003e\u003ccode\u003en\u003c/code\u003e\u003c/em\u003e rows)\u003c/code\u003e count). If \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is omitted the command toggles footer display on or off.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-FORMAT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eformat\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the output format to one of \u003ccode class=\"literal\"\u003ealigned\u003c/code\u003e, \u003ccode class=\"literal\"\u003easciidoc\u003c/code\u003e, \u003ccode class=\"literal\"\u003ecsv\u003c/code\u003e, \u003ccode class=\"literal\"\u003ehtml\u003c/code\u003e, \u003ccode class=\"literal\"\u003elatex\u003c/code\u003e, \u003ccode class=\"literal\"\u003elatex-longtable\u003c/code\u003e, \u003ccode class=\"literal\"\u003etroff-ms\u003c/code\u003e, \u003ccode class=\"literal\"\u003eunaligned\u003c/code\u003e, or \u003ccode class=\"literal\"\u003ewrapped\u003c/code\u003e. Unique abbreviations are allowed.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003ealigned\u003c/code\u003e format is the standard, human-readable, nicely formatted text output; this is the default.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eunaligned\u003c/code\u003e format writes all columns of a row on one line, separated by the currently active field separator. This is useful for creating output that might be intended to be read in by other programs, for example, tab-separated or comma-separated format. However, the field separator character is not treated specially if it appears in a column's value; so CSV format may be better suited for such purposes.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003ecsv\u003c/code\u003e format  writes column values separated by commas, applying the quoting rules described in \u003ca class=\"ulink\" href=\"https://datatracker.ietf.org/doc/html/rfc4180\"\u003eRFC 4180\u003c/a\u003e. This output is compatible with the CSV format of the server's \u003ccode class=\"command\"\u003eCOPY\u003c/code\u003e command. A header line with column names is generated unless the \u003ccode class=\"literal\"\u003etuples_only\u003c/code\u003e parameter is \u003ccode class=\"literal\"\u003eon\u003c/code\u003e. Titles and footers are not printed. Each row is terminated by the system-dependent end-of-line character, which is typically a single newline (\u003ccode class=\"literal\"\u003e\\n\u003c/code\u003e) for Unix-like systems or a carriage return and newline sequence (\u003ccode class=\"literal\"\u003e\\r\\n\u003c/code\u003e) for Microsoft Windows. Field separator characters other than comma can be selected with \u003ccode class=\"command\"\u003e\\pset csv_fieldsep\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003ewrapped\u003c/code\u003e format is like \u003ccode class=\"literal\"\u003ealigned\u003c/code\u003e but wraps wide data values across lines to make the output fit in the target column width. The target width is determined as described under the \u003ccode class=\"literal\"\u003ecolumns\u003c/code\u003e option. Note that \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will not attempt to wrap column header titles; therefore, \u003ccode class=\"literal\"\u003ewrapped\u003c/code\u003e format behaves the same as \u003ccode class=\"literal\"\u003ealigned\u003c/code\u003e if the total width needed for column headers exceeds the target.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode class=\"literal\"\u003easciidoc\u003c/code\u003e, \u003ccode class=\"literal\"\u003ehtml\u003c/code\u003e, \u003ccode class=\"literal\"\u003elatex\u003c/code\u003e, \u003ccode class=\"literal\"\u003elatex-longtable\u003c/code\u003e, and \u003ccode class=\"literal\"\u003etroff-ms\u003c/code\u003e formats 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 necessary in HTML, but in \u003cspan class=\"application\"\u003eLaTeX\u003c/span\u003e you must have a complete document wrapper. The \u003ccode class=\"literal\"\u003elatex\u003c/code\u003e format uses \u003cspan class=\"application\"\u003eLaTeX\u003c/span\u003e's \u003ccode class=\"literal\"\u003etabular\u003c/code\u003e environment. The \u003ccode class=\"literal\"\u003elatex-longtable\u003c/code\u003e format requires the \u003cspan class=\"application\"\u003eLaTeX\u003c/span\u003e \u003ccode class=\"literal\"\u003elongtable\u003c/code\u003e and \u003ccode class=\"literal\"\u003ebooktabs\u003c/code\u003e packages.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-LINESTYLE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003elinestyle\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the border line drawing style to one of \u003ccode class=\"literal\"\u003eascii\u003c/code\u003e, \u003ccode class=\"literal\"\u003eold-ascii\u003c/code\u003e, or \u003ccode class=\"literal\"\u003eunicode\u003c/code\u003e. Unique abbreviations are allowed. (That would mean one letter is enough.) The default setting is \u003ccode class=\"literal\"\u003eascii\u003c/code\u003e. This option only affects the \u003ccode class=\"literal\"\u003ealigned\u003c/code\u003e and \u003ccode class=\"literal\"\u003ewrapped\u003c/code\u003e output formats.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eascii\u003c/code\u003e style uses plain ASCII characters. Newlines in data are shown using a \u003ccode class=\"literal\"\u003e+\u003c/code\u003e symbol in the right-hand margin. When the \u003ccode class=\"literal\"\u003ewrapped\u003c/code\u003e format wraps data from one line to the next without a newline character, a dot (\u003ccode class=\"literal\"\u003e.\u003c/code\u003e) is shown in the right-hand margin of the first line, and again in the left-hand margin of the following line.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eold-ascii\u003c/code\u003e style uses plain ASCII characters, using the formatting style used in \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 8.4 and earlier. Newlines in data are shown using a \u003ccode class=\"literal\"\u003e:\u003c/code\u003e symbol in place of the left-hand column separator. When the data is wrapped from one line to the next without a newline character, a \u003ccode class=\"literal\"\u003e;\u003c/code\u003e symbol is used in place of the left-hand column separator.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eunicode\u003c/code\u003e style uses Unicode box-drawing characters. Newlines in data are shown using a carriage return symbol in the right-hand margin. When the data is wrapped from one line to the next without a newline character, an ellipsis symbol is shown in the right-hand margin of the first line, and again in the left-hand margin of the following line.\u003c/p\u003e\n\u003cp\u003eWhen the \u003ccode class=\"literal\"\u003eborder\u003c/code\u003e setting is greater than zero, the \u003ccode class=\"literal\"\u003elinestyle\u003c/code\u003e option also determines the characters with which the border lines are drawn. Plain ASCII characters work everywhere, but Unicode characters look nicer on displays that recognize them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-NULL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003enull\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the string to be printed in place of a null value. The default is to print nothing, which can easily be mistaken for an empty string. For example, one might prefer \u003ccode class=\"literal\"\u003e\\pset null '(null)'\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-NUMERICLOCALE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003enumericlocale\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is specified it must be either \u003ccode class=\"literal\"\u003eon\u003c/code\u003e or \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e which will enable or disable display of a locale-specific character to separate groups of digits to the left of the decimal marker. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is omitted the command toggles between regular and locale-specific numeric output.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-PAGER\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003epager\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eControls use of a pager program for query and \u003cspan class=\"application\"\u003epsql\u003c/span\u003e help output. When the \u003ccode class=\"literal\"\u003epager\u003c/code\u003e option is \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e, the pager program is not used. When the \u003ccode class=\"literal\"\u003epager\u003c/code\u003e option is \u003ccode class=\"literal\"\u003eon\u003c/code\u003e, the pager is used when appropriate, i.e., when the output is to a terminal and will not fit on the screen. The \u003ccode class=\"literal\"\u003epager\u003c/code\u003e option can also be set to \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e, which causes the pager to be used for all terminal output regardless of whether it fits on the screen. \u003ccode class=\"literal\"\u003e\\pset pager\u003c/code\u003e without a \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e toggles pager use on and off.\u003c/p\u003e\n\u003cp\u003eIf the environment variable \u003ccode class=\"envar\"\u003ePSQL_PAGER\u003c/code\u003e or \u003ccode class=\"envar\"\u003ePAGER\u003c/code\u003e is set, output to be paged is piped to the specified program. Otherwise a platform-dependent default program (such as \u003ccode class=\"filename\"\u003emore\u003c/code\u003e) is used.\u003c/p\u003e\n\u003cp\u003eWhen using the \u003ccode class=\"literal\"\u003e\\watch\u003c/code\u003e command to execute a query repeatedly, the environment variable \u003ccode class=\"envar\"\u003ePSQL_WATCH_PAGER\u003c/code\u003e is used to find the pager program instead, on Unix systems. This is configured separately because it may confuse traditional pagers, but can be used to send output to tools that understand \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's output format (such as \u003ccode class=\"filename\"\u003epspg --stream\u003c/code\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-PAGER-MIN-LINES\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003epager_min_lines\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003ccode class=\"literal\"\u003epager_min_lines\u003c/code\u003e is set to a number greater than the page height, the pager program will not be called unless there are at least this many lines of output to show. The default setting is 0.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-RECORDSEP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003erecordsep\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the record (line) separator to use in unaligned output format. The default is a newline character.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-RECORDSEP-ZERO\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003erecordsep_zero\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the record separator to use in unaligned output format to a zero byte.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-TABLEATTR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003etableattr\u003c/code\u003e (or \u003ccode class=\"literal\"\u003eT\u003c/code\u003e)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIn HTML format, this specifies attributes to be placed inside the \u003ccode class=\"sgmltag-element\"\u003etable\u003c/code\u003e tag. This could for example be \u003ccode class=\"literal\"\u003ecellpadding\u003c/code\u003e or \u003ccode class=\"literal\"\u003ebgcolor\u003c/code\u003e. Note that you probably don't want to specify \u003ccode class=\"literal\"\u003eborder\u003c/code\u003e here, as that is already taken care of by \u003ccode class=\"literal\"\u003e\\pset border\u003c/code\u003e. If no \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is given, the table attributes are unset.\u003c/p\u003e\n\u003cp\u003eIn \u003ccode class=\"literal\"\u003elatex-longtable\u003c/code\u003e format, this controls the proportional width of each column containing a left-aligned data type. It is specified as a whitespace-separated list of values, e.g., \u003ccode class=\"literal\"\u003e'0.2 0.2 0.6'\u003c/code\u003e. Unspecified output columns use the last specified value.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-TITLE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003etitle\u003c/code\u003e (or \u003ccode class=\"literal\"\u003eC\u003c/code\u003e)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the table title for any subsequently printed tables. This can be used to give your output descriptive tags. If no \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is given, the title is unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-TUPLES-ONLY\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003etuples_only\u003c/code\u003e (or \u003ccode class=\"literal\"\u003et\u003c/code\u003e)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is specified it must be either \u003ccode class=\"literal\"\u003eon\u003c/code\u003e or \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e which will enable or disable tuples-only mode. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is omitted the command toggles between regular and tuples-only output. Regular output includes extra information such as column headers, titles, and various footers. In tuples-only mode, only actual table data is shown.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-UNICODE-BORDER-LINESTYLE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eunicode_border_linestyle\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the border drawing style for the \u003ccode class=\"literal\"\u003eunicode\u003c/code\u003e line style to one of \u003ccode class=\"literal\"\u003esingle\u003c/code\u003e or \u003ccode class=\"literal\"\u003edouble\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-UNICODE-COLUMN-LINESTYLE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eunicode_column_linestyle\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the column drawing style for the \u003ccode class=\"literal\"\u003eunicode\u003c/code\u003e line style to one of \u003ccode class=\"literal\"\u003esingle\u003c/code\u003e or \u003ccode class=\"literal\"\u003edouble\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-UNICODE-HEADER-LINESTYLE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eunicode_header_linestyle\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the header drawing style for the \u003ccode class=\"literal\"\u003eunicode\u003c/code\u003e line style to one of \u003ccode class=\"literal\"\u003esingle\u003c/code\u003e or \u003ccode class=\"literal\"\u003edouble\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-XHEADER-WIDTH\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003exheader_width\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the maximum width of the header for expanded output to one of \u003ccode class=\"literal\"\u003efull\u003c/code\u003e (the default value), \u003ccode class=\"literal\"\u003ecolumn\u003c/code\u003e, \u003ccode class=\"literal\"\u003epage\u003c/code\u003e, or an \u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger value\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003efull\u003c/code\u003e: the expanded header is not truncated, and will be as wide as the widest output line.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003ecolumn\u003c/code\u003e: truncate the header line to the width of the first column.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003epage\u003c/code\u003e: truncate the header line to the terminal width.\u003c/p\u003e\n\u003cp\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger value\u003c/code\u003e\u003c/em\u003e: specify the exact maximum width of the header line.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eIllustrations of how these different formats look can be seen in \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-EXAMPLES\" title=\"Examples\"\u003eExamples\u003c/a\u003e, below.\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eThere are various shortcut commands for \u003ccode class=\"command\"\u003e\\pset\u003c/code\u003e. See \u003ccode class=\"command\"\u003e\\a\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\C\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\f\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\H\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\t\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\T\u003c/code\u003e, and \u003ccode class=\"command\"\u003e\\x\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-QUIT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\q\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\quit\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eQuits the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e program. In a script file, only execution of that script is terminated.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-QECHO\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\qecho \u003cem class=\"replaceable\"\u003e\u003ccode\u003etext\u003c/code\u003e\u003c/em\u003e [ ... ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command is identical to \u003ccode class=\"command\"\u003e\\echo\u003c/code\u003e except that the output will be written to the query output channel, as set by \u003ccode class=\"command\"\u003e\\o\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-RESET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\r\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\reset\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eResets (clears) the query buffer.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-RESTRICT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\restrict \u003cem class=\"replaceable\"\u003e\u003ccode\u003erestrict_key\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnter \"restricted\" mode with the provided key. In this mode, the only allowed meta-command is \u003ccode class=\"command\"\u003e\\unrestrict\u003c/code\u003e, to exit restricted mode. The key may contain only alphanumeric characters.\u003c/p\u003e\n\u003cp\u003eThis command is primarily intended for use in plain-text dumps generated by \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e, \u003cspan class=\"application\"\u003epg_dumpall\u003c/span\u003e, and \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e, but it may be useful elsewhere.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-S\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\s [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's command line history to \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e is omitted, the history is written to the standard output (using the pager if appropriate). This command is not available if \u003cspan class=\"application\"\u003epsql\u003c/span\u003e was built without \u003cspan class=\"application\"\u003eReadline\u003c/span\u003e support.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-SET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\set [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [ ... ] ] ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variable \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e to \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e, 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 \u003ccode class=\"command\"\u003e\\unset\u003c/code\u003e command.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003e\\set\u003c/code\u003e without any arguments displays the names and values of all currently-set \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variables.\u003c/p\u003e\n\u003cp\u003eValid variable names can contain letters, digits, and underscores. See \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-VARIABLES\" title=\"Variables\"\u003eVariables\u003c/a\u003e below for details. Variable names are case-sensitive.\u003c/p\u003e\n\u003cp\u003eCertain variables are special, in that they control \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's behavior or are automatically set to reflect connection state. These variables are documented in \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-VARIABLES\" title=\"Variables\"\u003eVariables\u003c/a\u003e, below.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis command is unrelated to the SQL command \u003ca class=\"link\" href=\"/docs/18/sql-set.html\" title=\"SET\"\u003e\u003ccode class=\"command\"\u003eSET\u003c/code\u003e\u003c/a\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-SETENV\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\setenv \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the environment variable \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e to \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e, or if the \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is not supplied, unsets the environment variable. Example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\setenv PAGER less\u003c/code\u003e\u003c/strong\u003e\ntestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\setenv LESS -imx4F\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-SF\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\sf[+] \u003cem class=\"replaceable\"\u003e\u003ccode\u003efunction_description\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command fetches and shows the definition of the named function or procedure, in the form of a \u003ccode class=\"command\"\u003eCREATE OR REPLACE FUNCTION\u003c/code\u003e or \u003ccode class=\"command\"\u003eCREATE OR REPLACE PROCEDURE\u003c/code\u003e command. The definition is printed to the current query output channel, as set by \u003ccode class=\"command\"\u003e\\o\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe target function can be specified by name alone, or by name and arguments, for example \u003ccode class=\"literal\"\u003efoo(integer, text)\u003c/code\u003e. The argument types must be given if there is more than one function of the same name.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, then the output lines are numbered, with the first line of the function body being line 1.\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument(s) of \u003ccode class=\"command\"\u003e\\sf\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-SV\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\sv[+] \u003cem class=\"replaceable\"\u003e\u003ccode\u003eview_name\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command fetches and shows the definition of the named view, in the form of a \u003ccode class=\"command\"\u003eCREATE OR REPLACE VIEW\u003c/code\u003e command. The definition is printed to the current query output channel, as set by \u003ccode class=\"command\"\u003e\\o\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, then the output lines are numbered from 1.\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument(s) of \u003ccode class=\"command\"\u003e\\sv\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PIPELINE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\startpipeline\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\sendpipeline\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\syncpipeline\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\endpipeline\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\flushrequest\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\flush\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\getresults [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber_results\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis group of commands implements pipelining of SQL statements. A pipeline must begin with a \u003ccode class=\"command\"\u003e\\startpipeline\u003c/code\u003e and end with an \u003ccode class=\"command\"\u003e\\endpipeline\u003c/code\u003e. In between there may be any number of \u003ccode class=\"command\"\u003e\\syncpipeline\u003c/code\u003e commands, which sends a \u003ca class=\"link\" href=\"/docs/18/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY\" title=\"54.2.3. Extended Query\"\u003esync message\u003c/a\u003e 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 \u003ca class=\"xref\" href=\"/docs/18/libpq-pipeline-mode.html\" title=\"32.5. Pipeline Mode\"\u003eSection 32.5\u003c/a\u003e for more details.\u003c/p\u003e\n\u003cp\u003eAll queries executed while a pipeline is ongoing use the extended query protocol. Queries are appended to the pipeline when ending with a semicolon. The meta-commands \u003ccode class=\"literal\"\u003e\\bind\u003c/code\u003e, \u003ccode class=\"literal\"\u003e\\bind_named\u003c/code\u003e, \u003ccode class=\"literal\"\u003e\\close_prepared\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\parse\u003c/code\u003e can be used in an ongoing pipeline. While a pipeline is ongoing, \u003ccode class=\"literal\"\u003e\\sendpipeline\u003c/code\u003e will append the current query buffer to the pipeline. Other meta-commands like \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e, \u003ccode class=\"literal\"\u003e\\gx\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\gdesc\u003c/code\u003e are not allowed in pipeline mode.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003e\\flushrequest\u003c/code\u003e appends a flush command to the pipeline, allowing to read results with \u003ccode class=\"command\"\u003e\\getresults\u003c/code\u003e without issuing a sync or ending the pipeline. \u003ccode class=\"command\"\u003e\\getresults\u003c/code\u003e will automatically push unsent data to the server. \u003ccode class=\"command\"\u003e\\flush\u003c/code\u003e can be used to manually push unsent data.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003e\\getresults\u003c/code\u003e accepts an optional \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber_results\u003c/code\u003e\u003c/em\u003e parameter. If provided, only the first \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber_results\u003c/code\u003e\u003c/em\u003e pending results will be read. If not provided or \u003ccode class=\"literal\"\u003e0\u003c/code\u003e, all pending results are read.\u003c/p\u003e\n\u003cp\u003eWhen pipeline mode is active, a dedicated prompt variable is available to report the pipeline status. See \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PROMPTING-P-UC\"\u003e\u003ccode class=\"literal\"\u003e%P\u003c/code\u003e\u003c/a\u003e for more details\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003eCOPY\u003c/code\u003e is not supported while in pipeline mode.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e\\startpipeline\nSELECT * FROM pg_class;\nSELECT 1 \\bind \\sendpipeline\n\\flushrequest\n\\getresults\n\\endpipeline\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-T-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\t\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eToggles the display of output column name headings and row count footer. This command is equivalent to \u003ccode class=\"literal\"\u003e\\pset tuples_only\u003c/code\u003e and is provided for convenience.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-T-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\T \u003cem class=\"replaceable\"\u003e\u003ccode\u003etable_options\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies attributes to be placed within the \u003ccode class=\"sgmltag-element\"\u003etable\u003c/code\u003e tag in HTML output format. This command is equivalent to \u003ccode class=\"literal\"\u003e\\pset tableattr \u003cem class=\"replaceable\"\u003e\u003ccode\u003etable_options\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-TIMING\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\timing [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eon\u003c/code\u003e\u003c/em\u003e | \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoff\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWith 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-UNRESTRICT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\unrestrict \u003cem class=\"replaceable\"\u003e\u003ccode\u003erestrict_key\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eExit \"restricted\" mode (i.e., where all other meta-commands are blocked), provided the specified key matches the one given to \u003ccode class=\"command\"\u003e\\restrict\u003c/code\u003e when restricted mode was entered.\u003c/p\u003e\n\u003cp\u003eThis command is primarily intended for use in plain-text dumps generated by \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e, \u003cspan class=\"application\"\u003epg_dumpall\u003c/span\u003e, and \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e, but it may be useful elsewhere.\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument of \u003ccode class=\"command\"\u003e\\unrestrict\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-UNSET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\unset \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUnsets (deletes) the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variable \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eMost variables that control \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's behavior cannot be unset; instead, an \u003ccode class=\"literal\"\u003e\\unset\u003c/code\u003e command is interpreted as setting them to their default values. See \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-VARIABLES\" title=\"Variables\"\u003eVariables\u003c/a\u003e below.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-WRITE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\w\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\write\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\w\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\write\u003c/code\u003e \u003ccode class=\"literal\"\u003e|\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWrites the current query buffer to the file \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e or pipes it to the shell command \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e. If the current query buffer is empty, the most recently executed query is written instead.\u003c/p\u003e\n\u003cp\u003eIf the argument begins with \u003ccode class=\"literal\"\u003e|\u003c/code\u003e, then the entire remainder of the line is taken to be the \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e to execute, and neither variable interpolation nor backquote expansion are performed in it. The rest of the line is simply passed literally to the shell.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-WARN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\warn \u003cem class=\"replaceable\"\u003e\u003ccode\u003etext\u003c/code\u003e\u003c/em\u003e [ ... ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command is identical to \u003ccode class=\"command\"\u003e\\echo\u003c/code\u003e except that the output will be written to \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's standard error channel, rather than standard output.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-WATCH\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\watch [ i[nterval]=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e ] [ c[ount]=\u003cem class=\"replaceable\"\u003e\u003ccode\u003etimes\u003c/code\u003e\u003c/em\u003e ] [ m[in_rows]=\u003cem class=\"replaceable\"\u003e\u003ccode\u003erows\u003c/code\u003e\u003c/em\u003e ] [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRepeatedly execute the current query buffer (as \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e 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 \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-VARIABLES-WATCH-INTERVAL\"\u003e\u003ccode class=\"varname\"\u003eWATCH_INTERVAL\u003c/code\u003e\u003c/a\u003e. For backwards compatibility, \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e can be specified with or without an \u003ccode class=\"literal\"\u003einterval=\u003c/code\u003e prefix. Each query result is displayed with a header that includes the \u003ccode class=\"literal\"\u003e\\pset title\u003c/code\u003e string (if any), the time as of query start, and the delay interval.\u003c/p\u003e\n\u003cp\u003eIf the current query buffer is empty, the most recently sent query is re-executed instead.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-X\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\x [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eon\u003c/code\u003e\u003c/em\u003e | \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoff\u003c/code\u003e\u003c/em\u003e | \u003cem class=\"replaceable\"\u003e\u003ccode\u003eauto\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets or toggles expanded table formatting mode. As such it is equivalent to \u003ccode class=\"literal\"\u003e\\pset expanded\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-Z\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\z[Sx] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists tables, views and sequences with their associated access privileges. If a \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e 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 \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003cp\u003eThis is an alias for \u003ccode class=\"command\"\u003e\\dp\u003c/code\u003e (\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003edisplay privileges\u003c/span\u003e”\u003c/span\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-EXCLAMATION-MARK\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\! [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWith no argument, escapes to a sub-shell; \u003cspan class=\"application\"\u003epsql\u003c/span\u003e resumes when the sub-shell exits. With an argument, executes the shell command \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument(s) of \u003ccode class=\"command\"\u003e\\!\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments. The rest of the line is simply passed literally to the shell.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-QUESTION-MARK\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\? [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003etopic\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShows help information. The optional \u003cem class=\"replaceable\"\u003e\u003ccode\u003etopic\u003c/code\u003e\u003c/em\u003e parameter (defaulting to \u003ccode class=\"literal\"\u003ecommands\u003c/code\u003e) selects which part of \u003cspan class=\"application\"\u003epsql\u003c/span\u003e is explained: \u003ccode class=\"literal\"\u003ecommands\u003c/code\u003e describes \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's backslash commands; \u003ccode class=\"literal\"\u003eoptions\u003c/code\u003e describes the command-line options that can be passed to \u003cspan class=\"application\"\u003epsql\u003c/span\u003e; and \u003ccode class=\"literal\"\u003evariables\u003c/code\u003e shows help about \u003cspan class=\"application\"\u003epsql\u003c/span\u003e configuration variables.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-SEMICOLON\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\;\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBackslash-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.\u003c/p\u003e\n\u003cp\u003eNormally, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will dispatch an SQL command to the server as soon as it reaches the command-ending semicolon, even if more input remains on the current line. Thus for example entering\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eselect 1; select 2; select 3;\n\u003c/pre\u003e\n\u003cp\u003ewill result in the three SQL commands being individually sent to the server, with each one's results being displayed before continuing to the next command. However, a semicolon entered as \u003ccode class=\"literal\"\u003e\\;\u003c/code\u003e will not trigger command processing, so that the command before it and the one after are effectively combined and sent to the server in one request. So for example\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eselect 1\\; select 2\\; select 3;\n\u003c/pre\u003e\n\u003cp\u003eresults in sending the three SQL commands to the server in a single request, when the non-backslashed semicolon is reached. The server executes such a request as a single transaction, unless there are explicit \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e/\u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e commands included in the string to divide it into multiple transactions. (See \u003ca class=\"xref\" href=\"/docs/18/protocol-flow.html#PROTOCOL-FLOW-MULTI-STATEMENT\" title=\"54.2.2.1. Multiple Statements in a Simple Query\"\u003eSection 54.2.2.1\u003c/a\u003e for more details about how the server handles multi-query strings.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect3\" id=\"APP-PSQL-PATTERNS\"\u003e\n\u003ch4\u003ePatterns\u003c/h4\u003e\n\u003cp\u003eThe various \u003ccode class=\"literal\"\u003e\\d\u003c/code\u003e commands accept a \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e parameter to specify the object name(s) to be displayed. In the simplest case, a pattern is just the exact name of the object. The characters within a pattern are normally folded to lower case, just as in SQL names; for example, \u003ccode class=\"literal\"\u003e\\dt FOO\u003c/code\u003e will display the table named \u003ccode class=\"literal\"\u003efoo\u003c/code\u003e. As in SQL names, placing double quotes around a pattern stops folding to lower case. Should you need to include an actual double quote character in a pattern, write it as a pair of double quotes within a double-quote sequence; again this is in accord with the rules for SQL quoted identifiers. For example, \u003ccode class=\"literal\"\u003e\\dt \"FOO\"\"BAR\"\u003c/code\u003e will display the table named \u003ccode class=\"literal\"\u003eFOO\"BAR\u003c/code\u003e (not \u003ccode class=\"literal\"\u003efoo\"bar\u003c/code\u003e). Unlike the normal rules for SQL names, you can put double quotes around just part of a pattern, for instance \u003ccode class=\"literal\"\u003e\\dt FOO\"FOO\"BAR\u003c/code\u003e will display the table named \u003ccode class=\"literal\"\u003efooFOObar\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eWhenever the \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e parameter is omitted completely, the \u003ccode class=\"literal\"\u003e\\d\u003c/code\u003e commands display all objects that are visible in the current schema search path — this is equivalent to using \u003ccode class=\"literal\"\u003e*\u003c/code\u003e as the pattern. (An object is said to be \u003cem class=\"firstterm\"\u003evisible\u003c/em\u003e if its containing schema is in the search path and no object of the same kind and name appears earlier in the search path. This is equivalent to the statement that the object can be referenced by name without explicit schema qualification.) To see all objects in the database regardless of visibility, use \u003ccode class=\"literal\"\u003e*.*\u003c/code\u003e as the pattern.\u003c/p\u003e\n\u003cp\u003eWithin a pattern, \u003ccode class=\"literal\"\u003e*\u003c/code\u003e matches any sequence of characters (including no characters) and \u003ccode class=\"literal\"\u003e?\u003c/code\u003e matches any single character. (This notation is comparable to Unix shell file name patterns.) For example, \u003ccode class=\"literal\"\u003e\\dt int*\u003c/code\u003e displays tables whose names begin with \u003ccode class=\"literal\"\u003eint\u003c/code\u003e. But within double quotes, \u003ccode class=\"literal\"\u003e*\u003c/code\u003e and \u003ccode class=\"literal\"\u003e?\u003c/code\u003e lose these special meanings and are just matched literally.\u003c/p\u003e\n\u003cp\u003eA relation pattern that contains a dot (\u003ccode class=\"literal\"\u003e.\u003c/code\u003e) is interpreted as a schema name pattern followed by an object name pattern. For example, \u003ccode class=\"literal\"\u003e\\dt foo*.*bar*\u003c/code\u003e displays all tables whose table name includes \u003ccode class=\"literal\"\u003ebar\u003c/code\u003e that are in schemas whose schema name starts with \u003ccode class=\"literal\"\u003efoo\u003c/code\u003e. When no dot appears, then the pattern matches only objects that are visible in the current schema search path. Again, a dot within double quotes loses its special meaning and is matched literally. A relation pattern that contains two dots (\u003ccode class=\"literal\"\u003e.\u003c/code\u003e) is interpreted as a database name followed by a schema name pattern followed by an object name pattern. The database name portion will not be treated as a pattern and must match the name of the currently connected database, else an error will be raised.\u003c/p\u003e\n\u003cp\u003eA schema pattern that contains a dot (\u003ccode class=\"literal\"\u003e.\u003c/code\u003e) is interpreted as a database name followed by a schema name pattern. For example, \u003ccode class=\"literal\"\u003e\\dn mydb.*foo*\u003c/code\u003e displays all schemas whose schema name includes \u003ccode class=\"literal\"\u003efoo\u003c/code\u003e. The database name portion will not be treated as a pattern and must match the name of the currently connected database, else an error will be raised.\u003c/p\u003e\n\u003cp\u003eAdvanced users can use regular-expression notations such as character classes, for example \u003ccode class=\"literal\"\u003e[0-9]\u003c/code\u003e to match any digit. All regular expression special characters work as specified in \u003ca class=\"xref\" href=\"/docs/18/functions-matching.html#FUNCTIONS-POSIX-REGEXP\" title=\"9.7.3. POSIX Regular Expressions\"\u003eSection 9.7.3\u003c/a\u003e, except for \u003ccode class=\"literal\"\u003e.\u003c/code\u003e which is taken as a separator as mentioned above, \u003ccode class=\"literal\"\u003e*\u003c/code\u003e which is translated to the regular-expression notation \u003ccode class=\"literal\"\u003e.*\u003c/code\u003e, \u003ccode class=\"literal\"\u003e?\u003c/code\u003e which is translated to \u003ccode class=\"literal\"\u003e.\u003c/code\u003e, and \u003ccode class=\"literal\"\u003e$\u003c/code\u003e which is matched literally. You can emulate these pattern characters at need by writing \u003ccode class=\"literal\"\u003e?\u003c/code\u003e for \u003ccode class=\"literal\"\u003e.\u003c/code\u003e, \u003ccode class=\"literal\"\u003e(\u003cem class=\"replaceable\"\u003e\u003ccode\u003eR\u003c/code\u003e\u003c/em\u003e+|)\u003c/code\u003e for \u003ccode class=\"literal\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eR\u003c/code\u003e\u003c/em\u003e*\u003c/code\u003e, or \u003ccode class=\"literal\"\u003e(\u003cem class=\"replaceable\"\u003e\u003ccode\u003eR\u003c/code\u003e\u003c/em\u003e|)\u003c/code\u003e for \u003ccode class=\"literal\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eR\u003c/code\u003e\u003c/em\u003e?\u003c/code\u003e. \u003ccode class=\"literal\"\u003e$\u003c/code\u003e is not needed as a regular-expression character since the pattern must match the whole name, unlike the usual interpretation of regular expressions (in other words, \u003ccode class=\"literal\"\u003e$\u003c/code\u003e is automatically appended to your pattern). Write \u003ccode class=\"literal\"\u003e*\u003c/code\u003e at the beginning and/or end if you don't wish the pattern to be anchored. Note that within double quotes, all regular expression special characters lose their special meanings and are matched literally. Also, the regular expression special characters are matched literally in operator name patterns (i.e., the argument of \u003ccode class=\"literal\"\u003e\\do\u003c/code\u003e).\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"id-1.9.4.21.8.5\"\u003e\n\u003ch3\u003eAdvanced Features\u003c/h3\u003e\n\u003cdiv class=\"refsect3\" id=\"APP-PSQL-VARIABLES\"\u003e\n\u003ch4\u003eVariables\u003c/h4\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e provides variable substitution features similar to common Unix command shells. Variables are simply name/value pairs, where the value can be any string of any length. The name must consist of letters (including non-Latin letters), digits, and underscores.\u003c/p\u003e\n\u003cp\u003eTo set a variable, use the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e meta-command \u003ccode class=\"command\"\u003e\\set\u003c/code\u003e. For example,\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\set foo bar\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003esets the variable \u003ccode class=\"literal\"\u003efoo\u003c/code\u003e to the value \u003ccode class=\"literal\"\u003ebar\u003c/code\u003e. To retrieve the content of the variable, precede the name with a colon, for example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\echo :foo\u003c/code\u003e\u003c/strong\u003e\nbar\n\u003c/pre\u003e\n\u003cp\u003eThis works in both regular SQL commands and meta-commands; there is more detail in \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-INTERPOLATION\" title=\"SQL Interpolation\"\u003eSQL Interpolation\u003c/a\u003e, below.\u003c/p\u003e\n\u003cp\u003eIf you call \u003ccode class=\"command\"\u003e\\set\u003c/code\u003e without a second argument, the variable is set to an empty-string value. To unset (i.e., delete) a variable, use the command \u003ccode class=\"command\"\u003e\\unset\u003c/code\u003e. To show the values of all variables, call \u003ccode class=\"command\"\u003e\\set\u003c/code\u003e without any argument.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eThe arguments of \u003ccode class=\"command\"\u003e\\set\u003c/code\u003e are subject to the same substitution rules as with other commands. Thus you can construct interesting references such as \u003ccode class=\"literal\"\u003e\\set :foo 'something'\u003c/code\u003e and get \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003esoft links\u003c/span\u003e”\u003c/span\u003e or \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003evariable variables\u003c/span\u003e”\u003c/span\u003e of \u003cspan class=\"productname\"\u003ePerl\u003c/span\u003e or \u003cspan class=\"productname\"\u003ePHP\u003c/span\u003e fame, respectively. Unfortunately (or fortunately?), there is no way to do anything useful with these constructs. On the other hand, \u003ccode class=\"literal\"\u003e\\set bar :foo\u003c/code\u003e is a perfectly valid way to copy a variable.\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eA number of these variables are treated specially by \u003cspan class=\"application\"\u003epsql\u003c/span\u003e. They represent certain option settings that can be changed at run time by altering the value of the variable, or in some cases represent changeable state of \u003cspan class=\"application\"\u003epsql\u003c/span\u003e. By convention, all specially treated variables' names consist of all upper-case ASCII letters (and possibly digits and underscores). To ensure maximum compatibility in the future, avoid using such variable names for your own purposes.\u003c/p\u003e\n\u003cp\u003eVariables that control \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's behavior generally cannot be unset or set to invalid values. An \u003ccode class=\"literal\"\u003e\\unset\u003c/code\u003e command is allowed but is interpreted as setting the variable to its default value. A \u003ccode class=\"literal\"\u003e\\set\u003c/code\u003e command without a second argument is interpreted as setting the variable to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e, for control variables that accept that value, and is rejected for others. Also, control variables that accept the values \u003ccode class=\"literal\"\u003eon\u003c/code\u003e and \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e will also accept other common spellings of Boolean values, such as \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e and \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe specially treated variables are:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-AUTOCOMMIT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eAUTOCOMMIT\u003c/code\u003e \u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen \u003ccode class=\"literal\"\u003eon\u003c/code\u003e (the default), each SQL command is automatically committed upon successful completion. To postpone commit in this mode, you must enter a \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e or \u003ccode class=\"command\"\u003eSTART TRANSACTION\u003c/code\u003e SQL command. When \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e or unset, SQL commands are not committed until you explicitly issue \u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e or \u003ccode class=\"command\"\u003eEND\u003c/code\u003e. The autocommit-off mode works by issuing an implicit \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e for you, just before any command that is not already in a transaction block and is not itself a \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e or other transaction-control command, nor a command that cannot be executed inside a transaction block (such as \u003ccode class=\"command\"\u003eVACUUM\u003c/code\u003e).\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eIn autocommit-off mode, you must explicitly abandon any failed transaction by entering \u003ccode class=\"command\"\u003eABORT\u003c/code\u003e or \u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e. Also keep in mind that if you exit the session without committing, your work will be lost.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eThe autocommit-on mode is \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e's traditional behavior, but autocommit-off is closer to the SQL spec. If you prefer autocommit-off, you might wish to set it in the system-wide \u003ccode class=\"filename\"\u003epsqlrc\u003c/code\u003e file or your \u003ccode class=\"filename\"\u003e~/.psqlrc\u003c/code\u003e file.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-COMP-KEYWORD-CASE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eCOMP_KEYWORD_CASE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDetermines which letter case to use when completing an SQL key word. If set to \u003ccode class=\"literal\"\u003elower\u003c/code\u003e or \u003ccode class=\"literal\"\u003eupper\u003c/code\u003e, the completed word will be in lower or upper case, respectively. If set to \u003ccode class=\"literal\"\u003epreserve-lower\u003c/code\u003e or \u003ccode class=\"literal\"\u003epreserve-upper\u003c/code\u003e (the default), the completed word will be in the case of the word already entered, but words being completed without anything entered will be in lower or upper case, respectively.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-DBNAME\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eDBNAME\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe name of the database you are currently connected to. This is set every time you connect to a database (including program start-up), but can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ECHO\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eECHO\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf set to \u003ccode class=\"literal\"\u003eall\u003c/code\u003e, all nonempty input lines are printed to standard output as they are read. (This does not apply to lines read interactively.) To select this behavior on program start-up, use the switch \u003ccode class=\"option\"\u003e-a\u003c/code\u003e. If set to \u003ccode class=\"literal\"\u003equeries\u003c/code\u003e, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e prints each query to standard output as it is sent to the server. The switch to select this behavior is \u003ccode class=\"option\"\u003e-e\u003c/code\u003e. If set to \u003ccode class=\"literal\"\u003eerrors\u003c/code\u003e, then only failed queries are displayed on standard error output. The switch for this behavior is \u003ccode class=\"option\"\u003e-b\u003c/code\u003e. If set to \u003ccode class=\"literal\"\u003enone\u003c/code\u003e (the default), then no queries are displayed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ECHO-HIDDEN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eECHO_HIDDEN\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen this variable is set to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e and a backslash command queries the database, the query is first shown. This feature helps you to study \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e internals and provide similar functionality in your own programs. (To select this behavior on program start-up, use the switch \u003ccode class=\"option\"\u003e-E\u003c/code\u003e.) If you set this variable to the value \u003ccode class=\"literal\"\u003enoexec\u003c/code\u003e, the queries are just shown but are not actually sent to the server and executed. The default value is \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ENCODING\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eENCODING\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe current client character set encoding. This is set every time you connect to a database (including program start-up), and when you change the encoding with \u003ccode class=\"literal\"\u003e\\encoding\u003c/code\u003e, but it can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ERROR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eERROR\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003etrue\u003c/code\u003e if the last SQL query failed, \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e if it succeeded. See also \u003ccode class=\"varname\"\u003eSQLSTATE\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-FETCH-COUNT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eFETCH_COUNT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf this variable is set to an integer value greater than zero, the results of \u003ccode class=\"command\"\u003eSELECT\u003c/code\u003e queries are fetched and displayed in groups of that many rows, rather than the default behavior of collecting the entire result set before display. Therefore only a limited amount of memory is used, regardless of the size of the result set. Settings of 100 to 1000 are commonly used when enabling this feature. Keep in mind that when using this feature, a query might fail after having already displayed some rows.\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eAlthough you can use any output format with this feature, the default \u003ccode class=\"literal\"\u003ealigned\u003c/code\u003e format tends to look bad because each group of \u003ccode class=\"varname\"\u003eFETCH_COUNT\u003c/code\u003e rows will be formatted separately, leading to varying column widths across the row groups. The other output formats work better.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-HIDE-TABLEAM\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eHIDE_TABLEAM\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf this variable is set to \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e, a table's access method details are not displayed. This is mainly useful for regression tests.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-HIDE-TOAST-COMPRESSION\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eHIDE_TOAST_COMPRESSION\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf this variable is set to \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e, column compression method details are not displayed. This is mainly useful for regression tests.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-HISTCONTROL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eHISTCONTROL\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf this variable is set to \u003ccode class=\"literal\"\u003eignorespace\u003c/code\u003e, lines which begin with a space are not entered into the history list. If set to a value of \u003ccode class=\"literal\"\u003eignoredups\u003c/code\u003e, lines matching the previous history line are not entered. A value of \u003ccode class=\"literal\"\u003eignoreboth\u003c/code\u003e combines the two options. If set to \u003ccode class=\"literal\"\u003enone\u003c/code\u003e (the default), all lines read in interactive mode are saved on the history list.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis feature was shamelessly plagiarized from \u003cspan class=\"application\"\u003eBash\u003c/span\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-HISTFILE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eHISTFILE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe file name that will be used to store the history list. If unset, the file name is taken from the \u003ccode class=\"envar\"\u003ePSQL_HISTORY\u003c/code\u003e environment variable. If that is not set either, the default is \u003ccode class=\"filename\"\u003e~/.psql_history\u003c/code\u003e, or \u003ccode class=\"filename\"\u003e%APPDATA%\\postgresql\\psql_history\u003c/code\u003e on Windows. For example, putting:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e\\set HISTFILE ~/.psql_history-:DBNAME\n\u003c/pre\u003e\n\u003cp\u003ein \u003ccode class=\"filename\"\u003e~/.psqlrc\u003c/code\u003e will cause \u003cspan class=\"application\"\u003epsql\u003c/span\u003e to maintain a separate history for each database.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis feature was shamelessly plagiarized from \u003cspan class=\"application\"\u003eBash\u003c/span\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-HISTSIZE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eHISTSIZE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe maximum number of commands to store in the command history (default 500). If set to a negative value, no limit is applied.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis feature was shamelessly plagiarized from \u003cspan class=\"application\"\u003eBash\u003c/span\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-HOST\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eHOST\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe database server host you are currently connected to. This is set every time you connect to a database (including program start-up), but can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-IGNOREEOF\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eIGNOREEOF\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf set to 1 or less, sending an EOF character (usually \u003cspan class=\"keycap\"\u003e\u003cstrong\u003eControl\u003c/strong\u003e\u003c/span\u003e+\u003cspan class=\"keycap\"\u003e\u003cstrong\u003eD\u003c/strong\u003e\u003c/span\u003e) to an interactive session of \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will terminate the application. If set to a larger numeric value, that many consecutive EOF characters must be typed to make an interactive session terminate. If the variable is set to a non-numeric value, it is interpreted as 10. The default is 0.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis feature was shamelessly plagiarized from \u003cspan class=\"application\"\u003eBash\u003c/span\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-LASTOID\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eLASTOID\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe value of the last affected OID, as returned from an \u003ccode class=\"command\"\u003eINSERT\u003c/code\u003e or \u003ccode class=\"command\"\u003e\\lo_import\u003c/code\u003e command. This variable is only guaranteed to be valid until after the result of the next SQL command has been displayed. \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e servers since version 12 do not support OID system columns anymore, thus LASTOID will always be 0 following \u003ccode class=\"command\"\u003eINSERT\u003c/code\u003e when targeting such servers.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-LAST-ERROR-MESSAGE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eLAST_ERROR_MESSAGE\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eLAST_ERROR_SQLSTATE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe primary error message and associated SQLSTATE code for the most recent failed query in the current \u003cspan class=\"application\"\u003epsql\u003c/span\u003e session, or an empty string and \u003ccode class=\"literal\"\u003e00000\u003c/code\u003e if no error has occurred in the current session.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ON-ERROR-ROLLBACK\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eON_ERROR_ROLLBACK\u003c/code\u003e \u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen set to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e, if a statement in a transaction block generates an error, the error is ignored and the transaction continues. When set to \u003ccode class=\"literal\"\u003einteractive\u003c/code\u003e, such errors are only ignored in interactive sessions, and not when reading script files. When set to \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e (the default), a statement in a transaction block that generates an error aborts the entire transaction. The error rollback mode works by issuing an implicit \u003ccode class=\"command\"\u003eSAVEPOINT\u003c/code\u003e for you, just before each command that is in a transaction block, and then rolling back to the savepoint if the command fails.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ON-ERROR-STOP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eON_ERROR_STOP\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, command processing continues after an error. When this variable is set to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e, processing will instead stop immediately. In interactive mode, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will return to the command prompt; otherwise, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will exit, returning error code 3 to distinguish this case from fatal error conditions, which are reported using error code 1. In either case, any currently running scripts (the top-level script, if any, and any other scripts which it may have in invoked) will be terminated immediately. If the top-level command string contained multiple SQL commands, processing will stop with the current command.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-PIPELINE-COMMAND-COUNT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003ePIPELINE_COMMAND_COUNT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe number of commands queued in an ongoing pipeline.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-PIPELINE-RESULT-COUNT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003ePIPELINE_RESULT_COUNT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe number of commands of an ongoing pipeline that were followed by either a \u003ccode class=\"command\"\u003e\\flushrequest\u003c/code\u003e or a \u003ccode class=\"command\"\u003e\\syncpipeline\u003c/code\u003e, forcing the server to send the results. These results can be retrieved with \u003ccode class=\"command\"\u003e\\getresults\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-PIPELINE-SYNC-COUNT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003ePIPELINE_SYNC_COUNT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe number of sync messages queued in an ongoing pipeline.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-PORT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003ePORT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe database server port to which you are currently connected. This is set every time you connect to a database (including program start-up), but can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-PROMPT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003ePROMPT1\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003ePROMPT2\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003ePROMPT3\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThese specify what the prompts \u003cspan class=\"application\"\u003epsql\u003c/span\u003e issues should look like. See \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PROMPTING\" title=\"Prompting\"\u003ePrompting\u003c/a\u003e below.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-QUIET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eQUIET\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSetting this variable to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e is equivalent to the command line option \u003ccode class=\"option\"\u003e-q\u003c/code\u003e. It is probably not too useful in interactive mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ROW-COUNT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eROW_COUNT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe number of rows returned or affected by the last SQL query, or 0 if the query failed or did not report a row count.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SERVER-VERSION-NAME\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eSERVER_VERSION_NAME\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eSERVER_VERSION_NUM\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server's version number as a string, for example \u003ccode class=\"literal\"\u003e9.6.2\u003c/code\u003e, \u003ccode class=\"literal\"\u003e10.1\u003c/code\u003e or \u003ccode class=\"literal\"\u003e11beta1\u003c/code\u003e, and in numeric form, for example \u003ccode class=\"literal\"\u003e90602\u003c/code\u003e or \u003ccode class=\"literal\"\u003e100001\u003c/code\u003e. These are set every time you connect to a database (including program start-up), but can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SERVICE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eSERVICE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe service name, if applicable.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SHELL-ERROR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eSHELL_ERROR\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003etrue\u003c/code\u003e if the last shell command failed, \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e if it succeeded. This applies to shell commands invoked via the \u003ccode class=\"literal\"\u003e\\!\u003c/code\u003e, \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e, \u003ccode class=\"literal\"\u003e\\o\u003c/code\u003e, \u003ccode class=\"literal\"\u003e\\w\u003c/code\u003e, and \u003ccode class=\"literal\"\u003e\\copy\u003c/code\u003e meta-commands, as well as backquote (\u003ccode class=\"literal\"\u003e`\u003c/code\u003e) expansion. Note that for \u003ccode class=\"literal\"\u003e\\o\u003c/code\u003e, this variable is updated when the output pipe is closed by the next \u003ccode class=\"literal\"\u003e\\o\u003c/code\u003e command. See also \u003ccode class=\"varname\"\u003eSHELL_EXIT_CODE\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SHELL-EXIT-CODE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eSHELL_EXIT_CODE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe exit status returned by the last shell command. 0–127 represent program exit codes, 128–255 indicate termination by a signal, and -1 indicates failure to launch a program or to collect its exit status. This applies to shell commands invoked via the \u003ccode class=\"literal\"\u003e\\!\u003c/code\u003e, \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e, \u003ccode class=\"literal\"\u003e\\o\u003c/code\u003e, \u003ccode class=\"literal\"\u003e\\w\u003c/code\u003e, and \u003ccode class=\"literal\"\u003e\\copy\u003c/code\u003e meta-commands, as well as backquote (\u003ccode class=\"literal\"\u003e`\u003c/code\u003e) expansion. Note that for \u003ccode class=\"literal\"\u003e\\o\u003c/code\u003e, this variable is updated when the output pipe is closed by the next \u003ccode class=\"literal\"\u003e\\o\u003c/code\u003e command. See also \u003ccode class=\"varname\"\u003eSHELL_ERROR\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SHOW-ALL-RESULTS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eSHOW_ALL_RESULTS\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen this variable is set to \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e, only the last result of a combined query (\u003ccode class=\"literal\"\u003e\\;\u003c/code\u003e) is shown instead of all of them. The default is \u003ccode class=\"literal\"\u003eon\u003c/code\u003e. The off behavior is for compatibility with older versions of \u003cspan class=\"application\"\u003epsql\u003c/span\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SHOW-CONTEXT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eSHOW_CONTEXT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis variable can be set to the values \u003ccode class=\"literal\"\u003enever\u003c/code\u003e, \u003ccode class=\"literal\"\u003eerrors\u003c/code\u003e, or \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e to control whether \u003ccode class=\"literal\"\u003eCONTEXT\u003c/code\u003e fields are displayed in messages from the server. The default is \u003ccode class=\"literal\"\u003eerrors\u003c/code\u003e (meaning that context will be shown in error messages, but not in notice or warning messages). This setting has no effect when \u003ccode class=\"varname\"\u003eVERBOSITY\u003c/code\u003e is set to \u003ccode class=\"literal\"\u003eterse\u003c/code\u003e or \u003ccode class=\"literal\"\u003esqlstate\u003c/code\u003e. (See also \u003ccode class=\"command\"\u003e\\errverbose\u003c/code\u003e, for use when you want a verbose version of the error you just got.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SINGLELINE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eSINGLELINE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSetting this variable to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e is equivalent to the command line option \u003ccode class=\"option\"\u003e-S\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SINGLESTEP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eSINGLESTEP\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSetting this variable to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e is equivalent to the command line option \u003ccode class=\"option\"\u003e-s\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SQLSTATE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eSQLSTATE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe error code (see \u003ca class=\"xref\" href=\"/docs/18/errcodes-appendix.html\" title=\"Appendix A. PostgreSQL Error Codes\"\u003eAppendix A\u003c/a\u003e) associated with the last SQL query's failure, or \u003ccode class=\"literal\"\u003e00000\u003c/code\u003e if it succeeded.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-USER\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eUSER\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe database user you are currently connected as. This is set every time you connect to a database (including program start-up), but can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-VERBOSITY\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eVERBOSITY\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis variable can be set to the values \u003ccode class=\"literal\"\u003edefault\u003c/code\u003e, \u003ccode class=\"literal\"\u003everbose\u003c/code\u003e, \u003ccode class=\"literal\"\u003eterse\u003c/code\u003e, or \u003ccode class=\"literal\"\u003esqlstate\u003c/code\u003e to control the verbosity of error reports. (See also \u003ccode class=\"command\"\u003e\\errverbose\u003c/code\u003e, for use when you want a verbose version of the error you just got.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-VERSION\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eVERSION\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eVERSION_NAME\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eVERSION_NUM\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThese variables are set at program start-up to reflect \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's version, respectively as a verbose string, a short string (e.g., \u003ccode class=\"literal\"\u003e9.6.2\u003c/code\u003e, \u003ccode class=\"literal\"\u003e10.1\u003c/code\u003e, or \u003ccode class=\"literal\"\u003e11beta1\u003c/code\u003e), and a number (e.g., \u003ccode class=\"literal\"\u003e90602\u003c/code\u003e or \u003ccode class=\"literal\"\u003e100001\u003c/code\u003e). They can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-WATCH-INTERVAL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eWATCH_INTERVAL\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis variable sets the default interval, in seconds, which \u003ccode class=\"command\"\u003e\\watch\u003c/code\u003e waits between executing the query. The default is 2 seconds. Specifying an interval in the command overrides this variable.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect3\" id=\"APP-PSQL-INTERPOLATION\"\u003e\n\u003ch4\u003eSQL Interpolation\u003c/h4\u003e\n\u003cp\u003eA key feature of \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variables is that you can substitute (\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003einterpolate\u003c/span\u003e”\u003c/span\u003e) them into regular SQL statements, as well as the arguments of meta-commands. Furthermore, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e provides facilities for ensuring that variable values used as SQL literals and identifiers are properly quoted. The syntax for interpolating a value without any quoting is to prepend the variable name with a colon (\u003ccode class=\"literal\"\u003e:\u003c/code\u003e). For example,\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\set foo 'my_table'\u003c/code\u003e\u003c/strong\u003e\ntestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT * FROM :foo;\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003ewould query the table \u003ccode class=\"literal\"\u003emy_table\u003c/code\u003e. Note that this may be unsafe: the value of the variable is copied literally, so it can contain unbalanced quotes, or even backslash commands. You must make sure that it makes sense where you put it.\u003c/p\u003e\n\u003cp\u003eWhen a value is to be used as an SQL literal or identifier, it is safest to arrange for it to be quoted. To quote the value of a variable as an SQL literal, write a colon followed by the variable name in single quotes. To quote the value as an SQL identifier, write a colon followed by the variable name in double quotes. These constructs deal correctly with quotes and other special characters embedded within the variable value. The previous example would be more safely written this way:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\set foo 'my_table'\u003c/code\u003e\u003c/strong\u003e\ntestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT * FROM :\"foo\";\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eVariable interpolation will not be performed within quoted SQL literals and identifiers. Therefore, a construction such as \u003ccode class=\"literal\"\u003e':foo'\u003c/code\u003e doesn't work to produce a quoted literal from a variable's value (and it would be unsafe if it did work, since it wouldn't correctly handle quotes embedded in the value).\u003c/p\u003e\n\u003cp\u003eOne example use of this mechanism is to copy the contents of a file into a table column. First load the file into a variable and then interpolate the variable's value as a quoted string:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\set content `cat my_file.txt`\u003c/code\u003e\u003c/strong\u003e\ntestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eINSERT INTO my_table VALUES (:'content');\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003e(Note that this still won't work if \u003ccode class=\"filename\"\u003emy_file.txt\u003c/code\u003e contains NUL bytes. \u003cspan class=\"application\"\u003epsql\u003c/span\u003e does not support embedded NUL bytes in variable values.)\u003c/p\u003e\n\u003cp\u003eSince colons can legally appear in SQL commands, an apparent attempt at interpolation (that is, \u003ccode class=\"literal\"\u003e:name\u003c/code\u003e, \u003ccode class=\"literal\"\u003e:'name'\u003c/code\u003e, or \u003ccode class=\"literal\"\u003e:\"name\"\u003c/code\u003e) is not replaced unless the named variable is currently set. In any case, you can escape a colon with a backslash to protect it from substitution.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode class=\"literal\"\u003e:{?\u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e}\u003c/code\u003e special syntax returns TRUE or FALSE depending on whether the variable exists or not, and is thus always substituted, unless the colon is backslash-escaped.\u003c/p\u003e\n\u003cp\u003eThe colon syntax for variables is standard SQL for embedded query languages, such as \u003cspan class=\"application\"\u003eECPG\u003c/span\u003e. The colon syntaxes for array slices and type casts are \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e extensions, which can sometimes conflict with the standard usage. The colon-quote syntax for escaping a variable's value as an SQL literal or identifier is a \u003cspan class=\"application\"\u003epsql\u003c/span\u003e extension.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect3\" id=\"APP-PSQL-PROMPTING\"\u003e\n\u003ch4\u003ePrompting\u003c/h4\u003e\n\u003cp\u003eThe prompts \u003cspan class=\"application\"\u003epsql\u003c/span\u003e issues can be customized to your preference. The three variables \u003ccode class=\"varname\"\u003ePROMPT1\u003c/code\u003e, \u003ccode class=\"varname\"\u003ePROMPT2\u003c/code\u003e, and \u003ccode class=\"varname\"\u003ePROMPT3\u003c/code\u003e contain strings and special escape sequences that describe the appearance of the prompt. Prompt 1 is the normal prompt that is issued when \u003cspan class=\"application\"\u003epsql\u003c/span\u003e requests a new command. Prompt 2 is issued when more input is expected during command entry, for example because the command was not terminated with a semicolon or a quote was not closed. Prompt 3 is issued when you are running an SQL \u003ccode class=\"command\"\u003eCOPY FROM STDIN\u003c/code\u003e command and you need to type in a row value on the terminal.\u003c/p\u003e\n\u003cp\u003eThe value of the selected prompt variable is printed literally, except where a percent sign (\u003ccode class=\"literal\"\u003e%\u003c/code\u003e) is encountered. Depending on the next character, certain other text is substituted instead. Defined substitutions are:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-M-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%M\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe full host name (with domain name) of the database server, or \u003ccode class=\"literal\"\u003e[local]\u003c/code\u003e if the connection is over a Unix domain socket, or \u003ccode class=\"literal\"\u003e[local:\u003cem class=\"replaceable\"\u003e\u003ccode\u003e/dir/name\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e, if the Unix domain socket is not at the compiled in default location.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-M-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%m\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe host name of the database server, truncated at the first dot, or \u003ccode class=\"literal\"\u003e[local]\u003c/code\u003e if the connection is over a Unix domain socket.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-GT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%\u0026gt;\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe port number at which the database server is listening.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-N\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%n\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe database session user name. (The expansion of this value might change during a database session as the result of the command \u003ccode class=\"command\"\u003eSET SESSION AUTHORIZATION\u003c/code\u003e.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-S\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%s\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe name of the service.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-SLASH\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%/\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe name of the current database.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-TILDE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%~\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLike \u003ccode class=\"literal\"\u003e%/\u003c/code\u003e, but the output is \u003ccode class=\"literal\"\u003e~\u003c/code\u003e (tilde) if the database is your default database.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-NUMBERSIGN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%#\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf the session user is a database superuser, then a \u003ccode class=\"literal\"\u003e#\u003c/code\u003e, otherwise a \u003ccode class=\"literal\"\u003e\u0026gt;\u003c/code\u003e. (The expansion of this value might change during a database session as the result of the command \u003ccode class=\"command\"\u003eSET SESSION AUTHORIZATION\u003c/code\u003e.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-P\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%p\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe process ID of the backend currently connected to.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-P-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%P\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePipeline status: \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e when not in a pipeline, \u003ccode class=\"literal\"\u003eon\u003c/code\u003e when in an ongoing pipeline or \u003ccode class=\"literal\"\u003eabort\u003c/code\u003e when in an aborted pipeline.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-R\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%R\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIn prompt 1 normally \u003ccode class=\"literal\"\u003e=\u003c/code\u003e, but \u003ccode class=\"literal\"\u003e@\u003c/code\u003e if the session is in an inactive branch of a conditional block, or \u003ccode class=\"literal\"\u003e^\u003c/code\u003e if in single-line mode, or \u003ccode class=\"literal\"\u003e!\u003c/code\u003e if the session is disconnected from the database (which can happen if \u003ccode class=\"command\"\u003e\\connect\u003c/code\u003e fails). In prompt 2 \u003ccode class=\"literal\"\u003e%R\u003c/code\u003e is replaced by a character that depends on why \u003cspan class=\"application\"\u003epsql\u003c/span\u003e expects more input: \u003ccode class=\"literal\"\u003e-\u003c/code\u003e if the command simply wasn't terminated yet, but \u003ccode class=\"literal\"\u003e*\u003c/code\u003e if there is an unfinished \u003ccode class=\"literal\"\u003e/* ... */\u003c/code\u003e comment, a single quote if there is an unfinished quoted string, a double quote if there is an unfinished quoted identifier, a dollar sign if there is an unfinished dollar-quoted string, or \u003ccode class=\"literal\"\u003e(\u003c/code\u003e if there is an unmatched left parenthesis. In prompt 3 \u003ccode class=\"literal\"\u003e%R\u003c/code\u003e doesn't produce anything.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-X\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%x\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eTransaction status: an empty string when not in a transaction block, or \u003ccode class=\"literal\"\u003e*\u003c/code\u003e when in a transaction block, or \u003ccode class=\"literal\"\u003e!\u003c/code\u003e when in a failed transaction block, or \u003ccode class=\"literal\"\u003e?\u003c/code\u003e when the transaction state is indeterminate (for example, because there is no connection).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-L\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%l\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe line number inside the current statement, starting from \u003ccode class=\"literal\"\u003e1\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-DIGITS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003edigits\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe character with the indicated octal code is substituted.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-NAME\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%:\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003ccode class=\"literal\"\u003e:\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe value of the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variable \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e. See \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-VARIABLES\" title=\"Variables\"\u003eVariables\u003c/a\u003e, above, for details.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-COMMAND\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%`\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e\u003ccode class=\"literal\"\u003e`\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe output of \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e, similar to ordinary \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eback-tick\u003c/span\u003e”\u003c/span\u003e substitution.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-SQUARE-BRACKETS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%[\u003c/code\u003e ... \u003ccode class=\"literal\"\u003e%]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrompts can contain terminal control characters which, for example, change the color, background, or style of the prompt text, or change the title of the terminal window. In order for the line editing features of \u003cspan class=\"application\"\u003eReadline\u003c/span\u003e to work properly, these non-printing control characters must be designated as invisible by surrounding them with \u003ccode class=\"literal\"\u003e%[\u003c/code\u003e and \u003ccode class=\"literal\"\u003e%]\u003c/code\u003e. Multiple pairs of these can occur within the prompt. For example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \\set PROMPT1 '%[%033[1;33;40m%]%n@%/%R%[%033[0m%]%# '\n\u003c/pre\u003e\n\u003cp\u003eresults in a boldfaced (\u003ccode class=\"literal\"\u003e1;\u003c/code\u003e) yellow-on-black (\u003ccode class=\"literal\"\u003e33;40\u003c/code\u003e) prompt on VT100-compatible, color-capable terminals.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-W\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%w\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhitespace of the same width as the most recent output of \u003ccode class=\"varname\"\u003ePROMPT1\u003c/code\u003e. This can be used as a \u003ccode class=\"varname\"\u003ePROMPT2\u003c/code\u003e setting, so that multi-line statements are aligned with the first line, but there is no visible secondary prompt.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eTo insert a percent sign into your prompt, write \u003ccode class=\"literal\"\u003e%%\u003c/code\u003e. The default prompts are \u003ccode class=\"literal\"\u003e'%/%R%x%# '\u003c/code\u003e for prompts 1 and 2, and \u003ccode class=\"literal\"\u003e'\u0026gt;\u0026gt; '\u003c/code\u003e for prompt 3.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis feature was shamelessly plagiarized from \u003cspan class=\"application\"\u003etcsh\u003c/span\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect3\" id=\"APP-PSQL-READLINE\"\u003e\n\u003ch4\u003eCommand-Line Editing\u003c/h4\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e uses the \u003cspan class=\"application\"\u003eReadline\u003c/span\u003e or \u003cspan class=\"application\"\u003elibedit\u003c/span\u003e library, if available, for convenient line editing and retrieval. The command history is automatically saved when \u003cspan class=\"application\"\u003epsql\u003c/span\u003e exits and is reloaded when \u003cspan class=\"application\"\u003epsql\u003c/span\u003e starts up. Type up-arrow or control-P to retrieve previous lines.\u003c/p\u003e\n\u003cp\u003eYou can also use tab completion to fill in partially-typed keywords and SQL object names in many (by no means all) contexts. For example, at the start of a command, typing \u003ccode class=\"literal\"\u003eins\u003c/code\u003e and pressing TAB will fill in \u003ccode class=\"literal\"\u003einsert into\u003c/code\u003e . Then, typing a few characters of a table or schema name and pressing \u003ccode class=\"literal\"\u003eTAB\u003c/code\u003e will fill in the unfinished name, or offer a menu of possible completions when there's more than one. (Depending on the library in use, you may need to press \u003ccode class=\"literal\"\u003eTAB\u003c/code\u003e more than once to get a menu.)\u003c/p\u003e\n\u003cp\u003eTab completion for SQL object names requires sending queries to the server to find possible matches. In some contexts this can interfere with other operations. For example, after \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e it will be too late to issue \u003ccode class=\"command\"\u003eSET TRANSACTION ISOLATION LEVEL\u003c/code\u003e if a tab-completion query is issued in between. If you do not want tab completion at all, you can turn it off permanently by putting this in a file named \u003ccode class=\"filename\"\u003e.inputrc\u003c/code\u003e in your home directory:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e$if psql\nset disable-completion on\n$endif\n\u003c/pre\u003e\n\u003cp\u003e(This is not a \u003cspan class=\"application\"\u003epsql\u003c/span\u003e but a \u003cspan class=\"application\"\u003eReadline\u003c/span\u003e feature. Read its documentation for further details.)\u003c/p\u003e\n\u003cp\u003eThe \u003ccode class=\"option\"\u003e-n\u003c/code\u003e (\u003ccode class=\"option\"\u003e--no-readline\u003c/code\u003e) command line option can also be useful to disable use of \u003cspan class=\"application\"\u003eReadline\u003c/span\u003e for a single run of \u003cspan class=\"application\"\u003epsql\u003c/span\u003e. This prevents tab completion, use or recording of command line history, and editing of multi-line commands. It is particularly useful when you need to copy-and-paste text that contains \u003ccode class=\"literal\"\u003eTAB\u003c/code\u003e characters.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"APP-PSQL-ENVIRONMENT\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-COLUMNS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003eCOLUMNS\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003ccode class=\"literal\"\u003e\\pset columns\u003c/code\u003e is zero, controls the width for the \u003ccode class=\"literal\"\u003ewrapped\u003c/code\u003e format and width for determining if wide output requires the pager or should be switched to the vertical format in expanded auto mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PGDATABASE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGDATABASE\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGHOST\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGUSER\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDefault connection parameters (see \u003ca class=\"xref\" href=\"/docs/18/libpq-envars.html\" title=\"32.15. Environment Variables\"\u003eSection 32.15\u003c/a\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PG-COLOR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePG_COLOR\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies whether to use color in diagnostic messages. Possible values are \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e, \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e and \u003ccode class=\"literal\"\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PSQL-EDITOR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePSQL_EDITOR\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003eEDITOR\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003eVISUAL\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEditor used by the \u003ccode class=\"command\"\u003e\\e\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\ef\u003c/code\u003e, and \u003ccode class=\"command\"\u003e\\ev\u003c/code\u003e commands. These variables are examined in the order listed; the first that is set is used. If none of them is set, the default is to use \u003ccode class=\"filename\"\u003evi\u003c/code\u003e on Unix systems or \u003ccode class=\"filename\"\u003enotepad.exe\u003c/code\u003e on Windows systems.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PSQL-EDITOR-LINENUMBER-ARG\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePSQL_EDITOR_LINENUMBER_ARG\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen \u003ccode class=\"command\"\u003e\\e\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\ef\u003c/code\u003e, or \u003ccode class=\"command\"\u003e\\ev\u003c/code\u003e is used with a line number argument, this variable specifies the command-line argument used to pass the starting line number to the user's editor. For editors such as \u003cspan class=\"productname\"\u003eEmacs\u003c/span\u003e or \u003cspan class=\"productname\"\u003evi\u003c/span\u003e, this is a plus sign. Include a trailing space in the value of the variable if there needs to be space between the option name and the line number. Examples:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003ePSQL_EDITOR_LINENUMBER_ARG='+'\nPSQL_EDITOR_LINENUMBER_ARG='--line '\n\u003c/pre\u003e\n\u003cp\u003eThe default is \u003ccode class=\"literal\"\u003e+\u003c/code\u003e on Unix systems (corresponding to the default editor \u003ccode class=\"filename\"\u003evi\u003c/code\u003e, and useful for many other common editors); but there is no default on Windows systems.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PSQL-HISTORY\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePSQL_HISTORY\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAlternative location for the command history file. Tilde (\u003ccode class=\"literal\"\u003e~\u003c/code\u003e) expansion is performed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PAGER\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePSQL_PAGER\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePAGER\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf a query's results do not fit on the screen, they are piped through this command. Typical values are \u003ccode class=\"literal\"\u003emore\u003c/code\u003e or \u003ccode class=\"literal\"\u003eless\u003c/code\u003e. Use of the pager can be disabled by setting \u003ccode class=\"envar\"\u003ePSQL_PAGER\u003c/code\u003e or \u003ccode class=\"envar\"\u003ePAGER\u003c/code\u003e to an empty string, or by adjusting the pager-related options of the \u003ccode class=\"command\"\u003e\\pset\u003c/code\u003e command. These variables are examined in the order listed; the first that is set is used. If neither of them is set, the default is to use \u003ccode class=\"literal\"\u003emore\u003c/code\u003e on most platforms, but \u003ccode class=\"literal\"\u003eless\u003c/code\u003e on Cygwin.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PSQL-WATCH-PAGER\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePSQL_WATCH_PAGER\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen a query is executed repeatedly with the \u003ccode class=\"command\"\u003e\\watch\u003c/code\u003e command, a pager is not used by default. This behavior can be changed by setting \u003ccode class=\"envar\"\u003ePSQL_WATCH_PAGER\u003c/code\u003e to a pager command, on Unix systems. The \u003ccode class=\"literal\"\u003epspg\u003c/code\u003e pager (not part of \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e but available in many open source software distributions) can display the output of \u003ccode class=\"command\"\u003e\\watch\u003c/code\u003e if started with the option \u003ccode class=\"literal\"\u003e--stream\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PSQLRC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePSQLRC\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAlternative location of the user's \u003ccode class=\"filename\"\u003e.psqlrc\u003c/code\u003e file. Tilde (\u003ccode class=\"literal\"\u003e~\u003c/code\u003e) expansion is performed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-SHELL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003eSHELL\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCommand executed by the \u003ccode class=\"command\"\u003e\\!\u003c/code\u003e command.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-TMPDIR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003eTMPDIR\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDirectory for storing temporary files. The default is \u003ccode class=\"filename\"\u003e/tmp\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThis utility, like most other \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e utilities, also uses the environment variables supported by \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e (see \u003ca class=\"xref\" href=\"/docs/18/libpq-envars.html\" title=\"32.15. Environment Variables\"\u003eSection 32.15\u003c/a\u003e).\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.21.10\"\u003e\n\u003ch2\u003eFiles\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-PSQL-FILES-PSQLRC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"filename\"\u003epsqlrc\u003c/code\u003e and \u003ccode class=\"filename\"\u003e~/.psqlrc\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUnless it is passed an \u003ccode class=\"option\"\u003e-X\u003c/code\u003e option, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e attempts to read and execute commands from the system-wide startup file (\u003ccode class=\"filename\"\u003epsqlrc\u003c/code\u003e) and then the user's personal startup file (\u003ccode class=\"filename\"\u003e~/.psqlrc\u003c/code\u003e), after connecting to the database but before accepting normal commands. These files can be used to set up the client and/or the server to taste, typically with \u003ccode class=\"command\"\u003e\\set\u003c/code\u003e and \u003ccode class=\"command\"\u003eSET\u003c/code\u003e commands.\u003c/p\u003e\n\u003cp\u003eThe system-wide startup file is named \u003ccode class=\"filename\"\u003epsqlrc\u003c/code\u003e. By default it is sought in the installation's \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003esystem configuration\u003c/span\u003e”\u003c/span\u003e directory, which is most reliably identified by running \u003ccode class=\"literal\"\u003epg_config --sysconfdir\u003c/code\u003e. Typically this directory will be \u003ccode class=\"filename\"\u003e../etc/\u003c/code\u003e relative to the directory containing the \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e executables. The directory to look in can be set explicitly via the \u003ccode class=\"envar\"\u003ePGSYSCONFDIR\u003c/code\u003e environment variable.\u003c/p\u003e\n\u003cp\u003eThe user's personal startup file is named \u003ccode class=\"filename\"\u003e.psqlrc\u003c/code\u003e and is sought in the invoking user's home directory. On Windows the personal startup file is instead named \u003ccode class=\"filename\"\u003e%APPDATA%\\postgresql\\psqlrc.conf\u003c/code\u003e. In either case, this default file path can be overridden by setting the \u003ccode class=\"envar\"\u003ePSQLRC\u003c/code\u003e environment variable.\u003c/p\u003e\n\u003cp\u003eBoth the system-wide startup file and the user's personal startup file can be made \u003cspan class=\"application\"\u003epsql\u003c/span\u003e-version-specific by appending a dash and the \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e major or minor release identifier to the file name, for example \u003ccode class=\"filename\"\u003e~/.psqlrc-18\u003c/code\u003e or \u003ccode class=\"filename\"\u003e~/.psqlrc-18.6\u003c/code\u003e. The most specific version-matching file will be read in preference to a non-version-specific file. These version suffixes are added after determining the file path as explained above.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-FILES-PSQL-HISTORY\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"filename\"\u003e.psql_history\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe command-line history is stored in the file \u003ccode class=\"filename\"\u003e~/.psql_history\u003c/code\u003e, or \u003ccode class=\"filename\"\u003e%APPDATA%\\postgresql\\psql_history\u003c/code\u003e on Windows.\u003c/p\u003e\n\u003cp\u003eThe location of the history file can be set explicitly via the \u003ccode class=\"varname\"\u003eHISTFILE\u003c/code\u003e \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variable or the \u003ccode class=\"envar\"\u003ePSQL_HISTORY\u003c/code\u003e environment variable.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.21.11\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e works best with servers of the same or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than \u003cspan class=\"application\"\u003epsql\u003c/span\u003e itself. However, backslash commands of the \u003ccode class=\"literal\"\u003e\\d\u003c/code\u003e family should work with servers of versions back to 9.2, though not necessarily with servers newer than \u003cspan class=\"application\"\u003epsql\u003c/span\u003e itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot be guaranteed in all cases.\u003c/p\u003e\n\u003cp\u003eIf you want to use \u003cspan class=\"application\"\u003epsql\u003c/span\u003e to connect to several servers of different major versions, it is recommended that you use the newest version of \u003cspan class=\"application\"\u003epsql\u003c/span\u003e. Alternatively, you can keep around a copy of \u003cspan class=\"application\"\u003epsql\u003c/span\u003e from each major version and be sure to use the version that matches the respective server. But in practice, this additional complication should not be necessary.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eBefore \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 9.6, the \u003ccode class=\"option\"\u003e-c\u003c/code\u003e option implied \u003ccode class=\"option\"\u003e-X\u003c/code\u003e (\u003ccode class=\"option\"\u003e--no-psqlrc\u003c/code\u003e); this is no longer the case.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eBefore \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 8.4, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e allowed the first argument of a single-letter backslash command to start directly after the command, without intervening whitespace. Now, some whitespace is required.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.21.12\"\u003e\n\u003ch2\u003eNotes for Windows Users\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e is built as a \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003econsole application\u003c/span\u003e”\u003c/span\u003e. Since the Windows console windows use a different encoding than the rest of the system, you must take special care when using 8-bit characters within \u003cspan class=\"application\"\u003epsql\u003c/span\u003e. If \u003cspan class=\"application\"\u003epsql\u003c/span\u003e detects a problematic console code page, it will warn you at startup. To change the console code page, two things are necessary:\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eSet the code page by entering \u003cstrong class=\"userinput\"\u003e\u003ccode\u003ecmd.exe /c chcp 1252\u003c/code\u003e\u003c/strong\u003e. (1252 is a code page that is appropriate for German; replace it with your value.) If you are using Cygwin, you can put this command in \u003ccode class=\"filename\"\u003e/etc/profile\u003c/code\u003e.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eSet the console font to \u003ccode class=\"literal\"\u003eLucida Console\u003c/code\u003e, because the raster font does not work with the ANSI code page.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"APP-PSQL-EXAMPLES\"\u003e\n\u003ch2\u003eExamples\u003c/h2\u003e\n\u003cp\u003eThe first example shows how to spread a command over several lines of input. Notice the changing prompt:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eCREATE TABLE my_table (\u003c/code\u003e\u003c/strong\u003e\ntestdb(\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e first integer not null default 0,\u003c/code\u003e\u003c/strong\u003e\ntestdb(\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e second text)\u003c/code\u003e\u003c/strong\u003e\ntestdb-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e;\u003c/code\u003e\u003c/strong\u003e\nCREATE TABLE\n\u003c/pre\u003e\n\u003cp\u003eNow look at the table definition again:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\d my_table\u003c/code\u003e\u003c/strong\u003e\n              Table \"public.my_table\"\n Column |  Type   | Collation | Nullable | Default\n--------+---------+-----------+----------+---------\n first  | integer |           | not null | 0\n second | text    |           |          |\n\u003c/pre\u003e\n\u003cp\u003eNow we change the prompt to something more interesting:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\set PROMPT1 '%n@%m %~%R%# '\u003c/code\u003e\u003c/strong\u003e\npeter@localhost testdb=\u0026gt;\n\u003c/pre\u003e\n\u003cp\u003eLet's assume you have filled the table with data and want to take a look at it:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003epeter@localhost testdb=\u0026gt; SELECT * FROM my_table;\n first | second\n-------+--------\n     1 | one\n     2 | two\n     3 | three\n     4 | four\n(4 rows)\n\u003c/pre\u003e\n\u003cp\u003eYou can display tables in different ways by using the \u003ccode class=\"command\"\u003e\\pset\u003c/code\u003e command:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003epeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\pset border 2\u003c/code\u003e\u003c/strong\u003e\nBorder style is 2.\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT * FROM my_table;\u003c/code\u003e\u003c/strong\u003e\n+-------+--------+\n| first | second |\n+-------+--------+\n|     1 | one    |\n|     2 | two    |\n|     3 | three  |\n|     4 | four   |\n+-------+--------+\n(4 rows)\n\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\pset border 0\u003c/code\u003e\u003c/strong\u003e\nBorder style is 0.\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT * FROM my_table;\u003c/code\u003e\u003c/strong\u003e\nfirst second\n----- ------\n    1 one\n    2 two\n    3 three\n    4 four\n(4 rows)\n\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\pset border 1\u003c/code\u003e\u003c/strong\u003e\nBorder style is 1.\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\pset format csv\u003c/code\u003e\u003c/strong\u003e\nOutput format is csv.\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\pset tuples_only\u003c/code\u003e\u003c/strong\u003e\nTuples only is on.\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT second, first FROM my_table;\u003c/code\u003e\u003c/strong\u003e\none,1\ntwo,2\nthree,3\nfour,4\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\pset format unaligned\u003c/code\u003e\u003c/strong\u003e\nOutput format is unaligned.\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\pset fieldsep '\\t'\u003c/code\u003e\u003c/strong\u003e\nField separator is \"    \".\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT second, first FROM my_table;\u003c/code\u003e\u003c/strong\u003e\none     1\ntwo     2\nthree   3\nfour    4\n\u003c/pre\u003e\n\u003cp\u003eAlternatively, use the short commands:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003epeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\a \\t \\x\u003c/code\u003e\u003c/strong\u003e\nOutput format is aligned.\nTuples only is off.\nExpanded display is on.\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT * FROM my_table;\u003c/code\u003e\u003c/strong\u003e\n-[ RECORD 1 ]-\nfirst  | 1\nsecond | one\n-[ RECORD 2 ]-\nfirst  | 2\nsecond | two\n-[ RECORD 3 ]-\nfirst  | 3\nsecond | three\n-[ RECORD 4 ]-\nfirst  | 4\nsecond | four\n\u003c/pre\u003e\n\u003cp\u003eAlso, these output format options can be set for just one query by using \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003epeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT * FROM my_table\u003c/code\u003e\u003c/strong\u003e\npeter@localhost testdb-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\g (format=aligned tuples_only=off expanded=on)\u003c/code\u003e\u003c/strong\u003e\n-[ RECORD 1 ]-\nfirst  | 1\nsecond | one\n-[ RECORD 2 ]-\nfirst  | 2\nsecond | two\n-[ RECORD 3 ]-\nfirst  | 3\nsecond | three\n-[ RECORD 4 ]-\nfirst  | 4\nsecond | four\n\u003c/pre\u003e\n\u003cp\u003eHere is an example of using the \u003ccode class=\"command\"\u003e\\df\u003c/code\u003e command to find only functions with names matching \u003ccode class=\"literal\"\u003eint*pl\u003c/code\u003e and whose second argument is of type \u003ccode class=\"type\"\u003ebigint\u003c/code\u003e:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\df int*pl * bigint\u003c/code\u003e\u003c/strong\u003e\n                          List of functions\n   Schema   |  Name   | Result data type | Argument data types | Type\n------------+---------+------------------+---------------------+------\n pg_catalog | int28pl | bigint           | smallint, bigint    | func\n pg_catalog | int48pl | bigint           | integer, bigint     | func\n pg_catalog | int8pl  | bigint           | bigint, bigint      | func\n(3 rows)\n\u003c/pre\u003e\n\u003cp\u003eHere, the \u003ccode class=\"literal\"\u003e+\u003c/code\u003e option is used to display additional information about one of these functions, and \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is used to display the results in expanded mode:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\df+x int*pl integer bigint\u003c/code\u003e\u003c/strong\u003e\nList of functions\n-[ RECORD 1 ]-------+-----------------------------\nSchema              | pg_catalog\nName                | int48pl\nResult data type    | bigint\nArgument data types | integer, bigint\nType                | func\nVolatility          | immutable\nParallel            | safe\nOwner               | postgres\nSecurity            | invoker\nLeakproof?          | no\nAccess privileges   |\nLanguage            | internal\nInternal name       | int48pl\nDescription         | implementation of + operator\n\u003c/pre\u003e\n\u003cp\u003eWhen suitable, query results can be shown in a crosstab representation with the \u003ccode class=\"command\"\u003e\\crosstabview\u003c/code\u003e command:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT first, second, first \u0026gt; 2 AS gt2 FROM my_table;\u003c/code\u003e\u003c/strong\u003e\n first | second | gt2\n-------+--------+-----\n     1 | one    | f\n     2 | two    | f\n     3 | three  | t\n     4 | four   | t\n(4 rows)\n\ntestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\crosstabview first second\u003c/code\u003e\u003c/strong\u003e\n first | one | two | three | four\n-------+-----+-----+-------+------\n     1 | f   |     |       |\n     2 |     | f   |       |\n     3 |     |     | t     |\n     4 |     |     |       | t\n(4 rows)\n\u003c/pre\u003e\n\u003cp\u003eThis second example shows a multiplication table with rows sorted in reverse numerical order and columns with an independent, ascending numerical order.\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT t1.first as \"A\", t2.first+100 AS \"B\", t1.first*(t2.first+100) as \"AxB\",\u003c/code\u003e\u003c/strong\u003e\ntestdb-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003erow_number() over(order by t2.first) AS ord\u003c/code\u003e\u003c/strong\u003e\ntestdb-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eFROM my_table t1 CROSS JOIN my_table t2 ORDER BY 1 DESC\u003c/code\u003e\u003c/strong\u003e\ntestdb-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\crosstabview \"A\" \"B\" \"AxB\" ord\u003c/code\u003e\u003c/strong\u003e\n A | 101 | 102 | 103 | 104\n---+-----+-----+-----+-----\n 4 | 404 | 408 | 412 | 416\n 3 | 303 | 306 | 309 | 312\n 2 | 202 | 204 | 206 | 208\n 1 | 101 | 102 | 103 | 104\n(4 rows)\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","manual_path":"app-psql.html","options":[{"description":"Print all nonempty input lines to standard output as they are read. (This does not apply to lines read interactively.) This is equivalent to setting the variable ECHO to all .","names":["-a","--echo-all"],"signature":"-a --echo-all","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-ECHO-ALL","summary":"Print all nonempty input lines to standard output as they are read. (This does not apply to lines read interactively.) This is equivalent to setting the variable ECHO to all ."},{"description":"Switches to unaligned output mode. (The default output mode is aligned .) This is equivalent to \\pset format unaligned .","names":["-A","--no-align"],"signature":"-A --no-align","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-NO-ALIGN","summary":"Switches to unaligned output mode. (The default output mode is aligned .) This is equivalent to \\pset format unaligned ."},{"description":"Print failed SQL commands to standard error output. This is equivalent to setting the variable ECHO to errors .","names":["-b","--echo-errors"],"signature":"-b --echo-errors","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-ECHO-ERRORS","summary":"Print failed SQL commands to standard error output. This is equivalent to setting the variable ECHO to errors ."},{"description":"Specifies that psql is to execute the given command string, command . This option can be repeated and combined in any order with the -f option. When either -c or -f is specified, psql does not read commands from standard input; instead it terminates after processing all the -c and -f options in sequence. command must be either a command string that is completely parsable by the server (i.e., it contains no psql -specific features), or a single backslash command. Thus you cannot mix SQL and psql meta-commands within a -c option. To achieve that, you could use repeated -c options or pipe the string into psql , for example: psql -c '\\x' -c 'SELECT * FROM foo;' or echo '\\x \\\\ SELECT * FROM foo;' | psql ( \\\\ is the separator meta-command.) Each SQL command string passed to -c is sent to the server as a single request. Because of this, the server executes it as a single transaction even if the string contains multiple SQL commands, unless there are explicit BEGIN / COMMIT commands included in the string to divide it into multiple transactions. (See Section 54.2.2.1 for more details about how the server handles multi-query strings.) If having several commands executed in one transaction is not desired, use repeated -c commands or feed multiple commands to psql 's standard input, either using echo as illustrated above, or via a shell here-document, for example: psql \u003c\u003cEOF \\x SELECT * FROM foo; EOF","names":["-c command","--command= command"],"signature":"-c command --command= command","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-COMMAND","summary":"Specifies that psql is to execute the given command string, command . This option can be repeated and combined in any order with the -f option. When either -c or -f is specified, psql does not read commands from standard input; instead it terminates after processing all the -c and -f options in sequence."},{"description":"Switches to CSV (Comma-Separated Values) output mode. This is equivalent to \\pset format csv .","names":["--csv"],"signature":"--csv","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-CSV","summary":"Switches to CSV (Comma-Separated Values) output mode. This is equivalent to \\pset format csv ."},{"description":"Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.","names":["-d dbname","--dbname= dbname"],"signature":"-d dbname --dbname= dbname","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-DBNAME","summary":"Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."},{"description":"Copy all SQL commands sent to the server to standard output as well. This is equivalent to setting the variable ECHO to queries .","names":["-e","--echo-queries"],"signature":"-e --echo-queries","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-ECHO-QUERIES","summary":"Copy all SQL commands sent to the server to standard output as well. This is equivalent to setting the variable ECHO to queries ."},{"description":"Echo the actual queries generated by \\d and other backslash commands. You can use this to study psql 's internal operations. This is equivalent to setting the variable ECHO_HIDDEN to on .","names":["-E","--echo-hidden"],"signature":"-E --echo-hidden","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-ECHO-HIDDEN","summary":"Echo the actual queries generated by \\d and other backslash commands. You can use this to study psql 's internal operations. This is equivalent to setting the variable ECHO_HIDDEN to on ."},{"description":"Read commands from the file filename , rather than standard input. This option can be repeated and combined in any order with the -c option. When either -c or -f is specified, psql does not read commands from standard input; instead it terminates after processing all the -c and -f options in sequence. Except for that, this option is largely equivalent to the meta-command \\i . If filename is - (hyphen), then standard input is read until an EOF indication or \\q meta-command. This can be used to intersperse interactive input with input from files. Note however that Readline is not used in this case (much as if -n had been specified). Using this option is subtly different from writing psql \u003c filename . In general, both will do what you expect, but using -f enables some nice features such as error messages with line numbers. There is also a slight chance that using this option will reduce the start-up overhead. On the other hand, the variant using the shell's input redirection is (in theory) guaranteed to yield exactly the same output you would have received had you entered everything by hand.","names":["-f filename","--file= filename"],"signature":"-f filename --file= filename","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-FILE","summary":"Read commands from the file filename , rather than standard input. This option can be repeated and combined in any order with the -c option. When either -c or -f is specified, psql does not read commands from standard input; instead it terminates after processing all the -c and -f options in sequence. Except for that, this option is largely equivalent to the meta-command \\i ."},{"description":"Use separator as the field separator for unaligned output. This is equivalent to \\pset fieldsep or \\f .","names":["-F separator","--field-separator= separator"],"signature":"-F separator --field-separator= separator","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-FIELD-SEPARATOR","summary":"Use separator as the field separator for unaligned output. This is equivalent to \\pset fieldsep or \\f ."},{"description":"Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix-domain socket.","names":["-h hostname","--host= hostname"],"signature":"-h hostname --host= hostname","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-FIELD-HOST","summary":"Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix-domain socket."},{"description":"Switches to HTML output mode. This is equivalent to \\pset format html or the \\H command.","names":["-H","--html"],"signature":"-H --html","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-HTML","summary":"Switches to HTML output mode. This is equivalent to \\pset format html or the \\H command."},{"description":"List all available databases, then exit. Other non-connection options are ignored. This is similar to the meta-command \\list . When this option is used, psql will connect to the database postgres , unless a different database is named on the command line (option -d or non-option argument, possibly via a service entry, but not via an environment variable).","names":["-l","--list"],"signature":"-l --list","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-LIST","summary":"List all available databases, then exit. Other non-connection options are ignored. This is similar to the meta-command \\list ."},{"description":"Write all query output into file filename , in addition to the normal output destination.","names":["-L filename","--log-file= filename"],"signature":"-L filename --log-file= filename","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-LOG-FILE","summary":"Write all query output into file filename , in addition to the normal output destination."},{"description":"Do not use Readline for line editing and do not use the command history (see the section called “Command-Line Editing” below).","names":["-n","--no-readline"],"signature":"-n --no-readline","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-NO-READLINE","summary":"Do not use Readline for line editing and do not use the command history (see the section called “Command-Line Editing” below)."},{"description":"Put all query output into file filename . This is equivalent to the command \\o .","names":["-o filename","--output= filename"],"signature":"-o filename --output= filename","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-OUTPUT","summary":"Put all query output into file filename . This is equivalent to the command \\o ."},{"description":"Specifies the TCP port or the local Unix-domain socket file extension on which the server is listening for connections. Defaults to the value of the PGPORT environment variable or, if not set, to the port specified at compile time, usually 5432.","names":["-p port","--port= port"],"signature":"-p port --port= port","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-PORT","summary":"Specifies the TCP port or the local Unix-domain socket file extension on which the server is listening for connections. Defaults to the value of the PGPORT environment variable or, if not set, to the port specified at compile time, usually 5432."},{"description":"Specifies printing options, in the style of \\pset . Note that here you have to separate name and value with an equal sign instead of a space. For example, to set the output format to LaTeX , you could write -P format=latex .","names":["-P assignment","--pset= assignment"],"signature":"-P assignment --pset= assignment","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-PSET","summary":"Specifies printing options, in the style of \\pset . Note that here you have to separate name and value with an equal sign instead of a space. For example, to set the output format to LaTeX , you could write -P format=latex ."},{"description":"Specifies that psql should do its work quietly. By default, it prints welcome messages and various informational output. If this option is used, none of this happens. This is useful with the -c option. This is equivalent to setting the variable QUIET to on .","names":["-q","--quiet"],"signature":"-q --quiet","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-QUIET","summary":"Specifies that psql should do its work quietly. By default, it prints welcome messages and various informational output. If this option is used, none of this happens. This is useful with the -c option. This is equivalent to setting the variable QUIET to on ."},{"description":"Use separator as the record separator for unaligned output. This is equivalent to \\pset recordsep .","names":["-R separator","--record-separator= separator"],"signature":"-R separator --record-separator= separator","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-RECORD-SEPARATOR","summary":"Use separator as the record separator for unaligned output. This is equivalent to \\pset recordsep ."},{"description":"Run in single-step mode. That means the user is prompted before each command is sent to the server, with the option to cancel execution as well. Use this to debug scripts.","names":["-s","--single-step"],"signature":"-s --single-step","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-SINGLE-STEP","summary":"Run in single-step mode. That means the user is prompted before each command is sent to the server, with the option to cancel execution as well. Use this to debug scripts."},{"description":"Runs in single-line mode where a newline terminates an SQL command, as a semicolon does. Note This mode is provided for those who insist on it, but you are not necessarily encouraged to use it. In particular, if you mix SQL and meta-commands on a line the order of execution might not always be clear to the inexperienced user.","names":["-S","--single-line"],"signature":"-S --single-line","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-SINGLE-LINE","summary":"Runs in single-line mode where a newline terminates an SQL command, as a semicolon does."},{"description":"Turn off printing of column names and result row count footers, etc. This is equivalent to \\t or \\pset tuples_only .","names":["-t","--tuples-only"],"signature":"-t --tuples-only","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-TUPLES-ONLY","summary":"Turn off printing of column names and result row count footers, etc. This is equivalent to \\t or \\pset tuples_only ."},{"description":"Specifies options to be placed within the HTML table tag. See \\pset tableattr for details.","names":["-T table_options","--table-attr= table_options"],"signature":"-T table_options --table-attr= table_options","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-TABLE-ATTR","summary":"Specifies options to be placed within the HTML table tag. See \\pset tableattr for details."},{"description":"Connect to the database as the user username instead of the default. (You must have permission to do so, of course.)","names":["-U username","--username= username"],"signature":"-U username --username= username","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-USERNAME","summary":"Connect to the database as the user username instead of the default. (You must have permission to do so, of course.)"},{"description":"Perform a variable assignment, like the \\set meta-command. Note that you must separate name and value, if any, by an equal sign on the command line. To unset a variable, leave off the equal sign. To set a variable with an empty value, use the equal sign but leave off the value. These assignments are done during command line processing, so variables that reflect connection state will get overwritten later.","names":["-v assignment","--set= assignment","--variable= assignment"],"signature":"-v assignment --set= assignment --variable= assignment","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-VARIABLE","summary":"Perform a variable assignment, like the \\set meta-command. Note that you must separate name and value, if any, by an equal sign on the command line. To unset a variable, leave off the equal sign. To set a variable with an empty value, use the equal sign but leave off the value. These assignments are done during command line processing, so variables that reflect connection state will get overwritten later."},{"description":"Print the psql version and exit.","names":["-V","--version"],"signature":"-V --version","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-VERSION","summary":"Print the psql version and exit."},{"description":"Never issue a password prompt. If the server requires password authentication and a password is not available from other sources such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password. Note that this option will remain set for the entire session, and so it affects uses of the meta-command \\connect as well as the initial connection attempt.","names":["-w","--no-password"],"signature":"-w --no-password","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-NO-PASSWORD","summary":"Never issue a password prompt. If the server requires password authentication and a password is not available from other sources such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password."},{"description":"Force psql to prompt for a password before connecting to a database, even if the password will not be used. If the server requires password authentication and a password is not available from other sources such as a .pgpass file, psql will prompt for a password in any case. However, psql will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing -W to avoid the extra connection attempt. Note that this option will remain set for the entire session, and so it affects uses of the meta-command \\connect as well as the initial connection attempt.","names":["-W","--password"],"signature":"-W --password","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-PASSWORD","summary":"Force psql to prompt for a password before connecting to a database, even if the password will not be used."},{"description":"Turn on the expanded table formatting mode. This is equivalent to \\x or \\pset expanded .","names":["-x","--expanded"],"signature":"-x --expanded","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-EXPANDED","summary":"Turn on the expanded table formatting mode. This is equivalent to \\x or \\pset expanded ."},{"description":"Do not read the start-up file (neither the system-wide psqlrc file nor the user's ~/.psqlrc file).","names":["-X","--no-psqlrc"],"signature":"-X --no-psqlrc","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-NO-PSQLRC","summary":"Do not read the start-up file (neither the system-wide psqlrc file nor the user's ~/.psqlrc file)."},{"description":"Set the field separator for unaligned output to a zero byte. This is equivalent to \\pset fieldsep_zero .","names":["-z","--field-separator-zero"],"signature":"-z --field-separator-zero","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-FIELD-SEPARATOR-ZERO","summary":"Set the field separator for unaligned output to a zero byte. This is equivalent to \\pset fieldsep_zero ."},{"description":"Set the record separator for unaligned output to a zero byte. This is useful for interfacing, for example, with xargs -0 . This is equivalent to \\pset recordsep_zero .","names":["-0","--record-separator-zero"],"signature":"-0 --record-separator-zero","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-RECORD-SEPARATOR-ZERO","summary":"Set the record separator for unaligned output to a zero byte. This is useful for interfacing, for example, with xargs -0 . This is equivalent to \\pset recordsep_zero ."},{"description":"This option can only be used in combination with one or more -c and/or -f options. It causes psql to issue a BEGIN command before the first such option and a COMMIT command after the last one, thereby wrapping all the commands into a single transaction. If any of the commands fails and the variable ON_ERROR_STOP was set, a ROLLBACK command is sent instead. This ensures that either all the commands complete successfully, or no changes are applied. If the commands themselves contain BEGIN , COMMIT , or ROLLBACK , this option will not have the desired effects. Also, if an individual command cannot be executed inside a transaction block, specifying this option will cause the whole transaction to fail.","names":["-1","--single-transaction"],"signature":"-1 --single-transaction","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-SINGLE-TRANSACTION","summary":"This option can only be used in combination with one or more -c and/or -f options. It causes psql to issue a BEGIN command before the first such option and a COMMIT command after the last one, thereby wrapping all the commands into a single transaction. If any of the commands fails and the variable ON_ERROR_STOP was set, a ROLLBACK command is sent instead. This ensures that either all the commands complete successfully, or no changes are applied."},{"description":"Show help about psql and exit. The optional topic parameter (defaulting to options ) 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.","names":["-?","--help[= topic ]"],"signature":"-? --help[= topic ]","source_url":"/docs/18/app-psql.html#APP-PSQL-OPTION-HELP","summary":"Show help about psql and exit. The optional topic parameter (defaulting to options ) 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."}],"related":[{"label":"psql meta-commands","url":"/wiki/psql/?v=18"},{"label":"libpq connection parameters","url":"/wiki/conn/?v=18"}],"release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.6","major":"18","manifest":{"index":"index.html","major":"18","pages":1148,"pdf":{"A4":{"built_at":"2026-09-26","bytes":15865106,"pages":3154,"sha256":"19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190","url":"/files/documentation/pdf/18/postgresql-18-A4.pdf"},"US":{"built_at":"2026-09-26","bytes":15748059,"pages":3328,"sha256":"facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319","url":"/files/documentation/pdf/18/postgresql-18-US.pdf"}},"release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","svg_assets":3,"tree":"18"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sections":[],"signature":"psql [ option ...] [ dbname [ username ]]","sources":[{"anchor":"","file":"app-psql.html","label":"18.6 English manual · app-psql.html","sha256":"fa2a1d39294b8854318e82e93f71272c645ed88150ecc2786c28902c3f32782c","url":"/docs/18/app-psql.html"},{"anchor":"","file":"reference-client.html","label":"Client applications inventory","sha256":"68f726af77272fe73a827be2b7b5958d0f2239a6f8ed44264e9d42496bfa4fd0","url":"/docs/18/reference-client.html"}],"synopsis":["psql [ option ...] [ dbname [ username ]]"],"tables":[{"columns":[{"key":"signature","label":"Option and arguments"},{"key":"summary","label":"Description"}],"key":"options","rows":[{"signature":{"text":"-a --echo-all","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-ECHO-ALL"},"summary":"Print all nonempty input lines to standard output as they are read. (This does not apply to lines read interactively.) This is equivalent to setting the variable ECHO to all ."},{"signature":{"text":"-A --no-align","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-NO-ALIGN"},"summary":"Switches to unaligned output mode. (The default output mode is aligned .) This is equivalent to \\pset format unaligned ."},{"signature":{"text":"-b --echo-errors","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-ECHO-ERRORS"},"summary":"Print failed SQL commands to standard error output. This is equivalent to setting the variable ECHO to errors ."},{"signature":{"text":"-c command --command= command","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-COMMAND"},"summary":"Specifies that psql is to execute the given command string, command . This option can be repeated and combined in any order with the -f option. When either -c or -f is specified, psql does not read commands from standard input; instead it terminates after processing all the -c and -f options in sequence."},{"signature":{"text":"--csv","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-CSV"},"summary":"Switches to CSV (Comma-Separated Values) output mode. This is equivalent to \\pset format csv ."},{"signature":{"text":"-d dbname --dbname= dbname","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-DBNAME"},"summary":"Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."},{"signature":{"text":"-e --echo-queries","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-ECHO-QUERIES"},"summary":"Copy all SQL commands sent to the server to standard output as well. This is equivalent to setting the variable ECHO to queries ."},{"signature":{"text":"-E --echo-hidden","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-ECHO-HIDDEN"},"summary":"Echo the actual queries generated by \\d and other backslash commands. You can use this to study psql 's internal operations. This is equivalent to setting the variable ECHO_HIDDEN to on ."},{"signature":{"text":"-f filename --file= filename","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-FILE"},"summary":"Read commands from the file filename , rather than standard input. This option can be repeated and combined in any order with the -c option. When either -c or -f is specified, psql does not read commands from standard input; instead it terminates after processing all the -c and -f options in sequence. Except for that, this option is largely equivalent to the meta-command \\i ."},{"signature":{"text":"-F separator --field-separator= separator","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-FIELD-SEPARATOR"},"summary":"Use separator as the field separator for unaligned output. This is equivalent to \\pset fieldsep or \\f ."},{"signature":{"text":"-h hostname --host= hostname","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-FIELD-HOST"},"summary":"Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix-domain socket."},{"signature":{"text":"-H --html","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-HTML"},"summary":"Switches to HTML output mode. This is equivalent to \\pset format html or the \\H command."},{"signature":{"text":"-l --list","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-LIST"},"summary":"List all available databases, then exit. Other non-connection options are ignored. This is similar to the meta-command \\list ."},{"signature":{"text":"-L filename --log-file= filename","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-LOG-FILE"},"summary":"Write all query output into file filename , in addition to the normal output destination."},{"signature":{"text":"-n --no-readline","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-NO-READLINE"},"summary":"Do not use Readline for line editing and do not use the command history (see the section called “Command-Line Editing” below)."},{"signature":{"text":"-o filename --output= filename","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-OUTPUT"},"summary":"Put all query output into file filename . This is equivalent to the command \\o ."},{"signature":{"text":"-p port --port= port","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-PORT"},"summary":"Specifies the TCP port or the local Unix-domain socket file extension on which the server is listening for connections. Defaults to the value of the PGPORT environment variable or, if not set, to the port specified at compile time, usually 5432."},{"signature":{"text":"-P assignment --pset= assignment","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-PSET"},"summary":"Specifies printing options, in the style of \\pset . Note that here you have to separate name and value with an equal sign instead of a space. For example, to set the output format to LaTeX , you could write -P format=latex ."},{"signature":{"text":"-q --quiet","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-QUIET"},"summary":"Specifies that psql should do its work quietly. By default, it prints welcome messages and various informational output. If this option is used, none of this happens. This is useful with the -c option. This is equivalent to setting the variable QUIET to on ."},{"signature":{"text":"-R separator --record-separator= separator","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-RECORD-SEPARATOR"},"summary":"Use separator as the record separator for unaligned output. This is equivalent to \\pset recordsep ."},{"signature":{"text":"-s --single-step","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-SINGLE-STEP"},"summary":"Run in single-step mode. That means the user is prompted before each command is sent to the server, with the option to cancel execution as well. Use this to debug scripts."},{"signature":{"text":"-S --single-line","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-SINGLE-LINE"},"summary":"Runs in single-line mode where a newline terminates an SQL command, as a semicolon does."},{"signature":{"text":"-t --tuples-only","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-TUPLES-ONLY"},"summary":"Turn off printing of column names and result row count footers, etc. This is equivalent to \\t or \\pset tuples_only ."},{"signature":{"text":"-T table_options --table-attr= table_options","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-TABLE-ATTR"},"summary":"Specifies options to be placed within the HTML table tag. See \\pset tableattr for details."},{"signature":{"text":"-U username --username= username","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-USERNAME"},"summary":"Connect to the database as the user username instead of the default. (You must have permission to do so, of course.)"},{"signature":{"text":"-v assignment --set= assignment --variable= assignment","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-VARIABLE"},"summary":"Perform a variable assignment, like the \\set meta-command. Note that you must separate name and value, if any, by an equal sign on the command line. To unset a variable, leave off the equal sign. To set a variable with an empty value, use the equal sign but leave off the value. These assignments are done during command line processing, so variables that reflect connection state will get overwritten later."},{"signature":{"text":"-V --version","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-VERSION"},"summary":"Print the psql version and exit."},{"signature":{"text":"-w --no-password","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-NO-PASSWORD"},"summary":"Never issue a password prompt. If the server requires password authentication and a password is not available from other sources such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password."},{"signature":{"text":"-W --password","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-PASSWORD"},"summary":"Force psql to prompt for a password before connecting to a database, even if the password will not be used."},{"signature":{"text":"-x --expanded","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-EXPANDED"},"summary":"Turn on the expanded table formatting mode. This is equivalent to \\x or \\pset expanded ."},{"signature":{"text":"-X --no-psqlrc","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-NO-PSQLRC"},"summary":"Do not read the start-up file (neither the system-wide psqlrc file nor the user's ~/.psqlrc file)."},{"signature":{"text":"-z --field-separator-zero","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-FIELD-SEPARATOR-ZERO"},"summary":"Set the field separator for unaligned output to a zero byte. This is equivalent to \\pset fieldsep_zero ."},{"signature":{"text":"-0 --record-separator-zero","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-RECORD-SEPARATOR-ZERO"},"summary":"Set the record separator for unaligned output to a zero byte. This is useful for interfacing, for example, with xargs -0 . This is equivalent to \\pset recordsep_zero ."},{"signature":{"text":"-1 --single-transaction","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-SINGLE-TRANSACTION"},"summary":"This option can only be used in combination with one or more -c and/or -f options. It causes psql to issue a BEGIN command before the first such option and a COMMIT command after the last one, thereby wrapping all the commands into a single transaction. If any of the commands fails and the variable ON_ERROR_STOP was set, a ROLLBACK command is sent instead. This ensures that either all the commands complete successfully, or no changes are applied."},{"signature":{"text":"-? --help[= topic ]","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-HELP"},"summary":"Show help about psql and exit. The optional topic parameter (defaulting to options ) 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."}],"title":"Documented options"},{"columns":[{"key":"name","label":"Variable"},{"key":"description","label":"Meaning"}],"key":"environment","rows":[{"description":"If \\pset columns is zero, controls the width for the wrapped format and width for determining if wide output requires the pager or should be switched to the vertical format in expanded auto mode.","name":"COLUMNS"},{"description":"Default connection parameters (see Section 32.15 ).","name":"PGDATABASE PGHOST PGPORT PGUSER"},{"description":"Specifies whether to use color in diagnostic messages. Possible values are always , auto and never .","name":"PG_COLOR"},{"description":"Editor used by the \\e , \\ef , and \\ev commands. These variables are examined in the order listed; the first that is set is used. If none of them is set, the default is to use vi on Unix systems or notepad.exe on Windows systems.","name":"PSQL_EDITOR EDITOR VISUAL"},{"description":"When \\e , \\ef , or \\ev is used with a line number argument, this variable specifies the command-line argument used to pass the starting line number to the user's editor. For editors such as Emacs or vi , this is a plus sign. Include a trailing space in the value of the variable if there needs to be space between the option name and the line number. Examples: PSQL_EDITOR_LINENUMBER_ARG='+' PSQL_EDITOR_LINENUMBER_ARG='--line ' The default is + on Unix systems (corresponding to the default editor vi , and useful for many other common editors); but there is no default on Windows systems.","name":"PSQL_EDITOR_LINENUMBER_ARG"},{"description":"Alternative location for the command history file. Tilde ( ~ ) expansion is performed.","name":"PSQL_HISTORY"},{"description":"If a query's results do not fit on the screen, they are piped through this command. Typical values are more or less . Use of the pager can be disabled by setting PSQL_PAGER or PAGER to an empty string, or by adjusting the pager-related options of the \\pset command. These variables are examined in the order listed; the first that is set is used. If neither of them is set, the default is to use more on most platforms, but less on Cygwin.","name":"PSQL_PAGER PAGER"},{"description":"When a query is executed repeatedly with the \\watch command, a pager is not used by default. This behavior can be changed by setting PSQL_WATCH_PAGER to a pager command, on Unix systems. The pspg pager (not part of PostgreSQL but available in many open source software distributions) can display the output of \\watch if started with the option --stream .","name":"PSQL_WATCH_PAGER"},{"description":"Alternative location of the user's .psqlrc file. Tilde ( ~ ) expansion is performed.","name":"PSQLRC"},{"description":"Command executed by the \\! command.","name":"SHELL"},{"description":"Directory for storing temporary files. The default is /tmp .","name":"TMPDIR"}],"title":"Environment variables"}]},"ManualEvidence":{"manual_path":"app-psql.html","release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.6","major":"18","manifest":{"index":"index.html","major":"18","pages":1148,"pdf":{"A4":{"built_at":"2026-09-26","bytes":15865106,"pages":3154,"sha256":"19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190","url":"/files/documentation/pdf/18/postgresql-18-A4.pdf"},"US":{"built_at":"2026-09-26","bytes":15748059,"pages":3328,"sha256":"facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319","url":"/files/documentation/pdf/18/postgresql-18-US.pdf"}},"release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","svg_assets":3,"tree":"18"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sources":[{"anchor":"","file":"app-psql.html","label":"18.6 English manual · app-psql.html","sha256":"fa2a1d39294b8854318e82e93f71272c645ed88150ecc2786c28902c3f32782c","url":"/docs/18/app-psql.html"},{"anchor":"","file":"reference-client.html","label":"Client applications inventory","sha256":"68f726af77272fe73a827be2b7b5958d0f2239a6f8ed44264e9d42496bfa4fd0","url":"/docs/18/reference-client.html"}]},"MeasuredEvidence":{}},"Text":{"Collection":"tool","Key":"psql","SourceDatabase":"center","Version":"18","Locale":"en","Title":"psql","Summary":"psql — PostgreSQL interactive terminal","BodyHTML":"\u003cdiv\u003e\u003cdiv id=\"APP-PSQL\"\u003e\n\u003cdiv\u003e\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch2\u003e\u003cspan\u003e\u003cspan\u003epsql\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003e\u003cspan\u003epsql\u003c/span\u003e — \u003cspan\u003ePostgreSQL\u003c/span\u003e interactive terminal\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cp id=\"id-1.9.4.21.4.1\"\u003e\u003ccode\u003epsql\u003c/code\u003e [\u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...] [\u003cem\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e [\u003cem\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e]]\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.21.5\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003cspan\u003epsql\u003c/span\u003e is a terminal-based front-end to \u003cspan\u003ePostgreSQL\u003c/span\u003e. It enables you to type in queries interactively, issue them to \u003cspan\u003ePostgreSQL\u003c/span\u003e, and see the query results. Alternatively, input can be from a file or from command line arguments. In addition, \u003cspan\u003epsql\u003c/span\u003e provides a number of meta-commands and various shell-like features to facilitate writing scripts and automating a wide variety of tasks.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"R1-APP-PSQL-3\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt id=\"APP-PSQL-OPTION-ECHO-ALL\"\u003e\u003cspan\u003e\u003ccode\u003e-a\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--echo-all\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint all nonempty input lines to standard output as they are read. (This does not apply to lines read interactively.) This is equivalent to setting the variable \u003ccode\u003eECHO\u003c/code\u003e to \u003ccode\u003eall\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-NO-ALIGN\"\u003e\u003cspan\u003e\u003ccode\u003e-A\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--no-align\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSwitches to unaligned output mode. (The default output mode is \u003ccode\u003ealigned\u003c/code\u003e.) This is equivalent to \u003ccode\u003e\\pset format unaligned\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-ECHO-ERRORS\"\u003e\u003cspan\u003e\u003ccode\u003e-b\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--echo-errors\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint failed SQL commands to standard error output. This is equivalent to setting the variable \u003ccode\u003eECHO\u003c/code\u003e to \u003ccode\u003eerrors\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-COMMAND\"\u003e\u003cspan\u003e\u003ccode\u003e-c \u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--command=\u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies that \u003cspan\u003epsql\u003c/span\u003e is to execute the given command string, \u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e. This option can be repeated and combined in any order with the \u003ccode\u003e-f\u003c/code\u003e option. When either \u003ccode\u003e-c\u003c/code\u003e or \u003ccode\u003e-f\u003c/code\u003e is specified, \u003cspan\u003epsql\u003c/span\u003e does not read commands from standard input; instead it terminates after processing all the \u003ccode\u003e-c\u003c/code\u003e and \u003ccode\u003e-f\u003c/code\u003e options in sequence.\u003c/p\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e must be either a command string that is completely parsable by the server (i.e., it contains no \u003cspan\u003epsql\u003c/span\u003e-specific features), or a single backslash command. Thus you cannot mix SQL and \u003cspan\u003epsql\u003c/span\u003e meta-commands within a \u003ccode\u003e-c\u003c/code\u003e option. To achieve that, you could use repeated \u003ccode\u003e-c\u003c/code\u003e options or pipe the string into \u003cspan\u003epsql\u003c/span\u003e, for example:\u003c/p\u003e\n\u003cpre\u003epsql -c \u0026#39;\\x\u0026#39; -c \u0026#39;SELECT * FROM foo;\u0026#39;\n\u003c/pre\u003e\n\u003cp\u003eor\u003c/p\u003e\n\u003cpre\u003eecho \u0026#39;\\x \\\\ SELECT * FROM foo;\u0026#39; | psql\n\u003c/pre\u003e\n\u003cp\u003e(\u003ccode\u003e\\\\\u003c/code\u003e is the separator meta-command.)\u003c/p\u003e\n\u003cp\u003eEach SQL command string passed to \u003ccode\u003e-c\u003c/code\u003e is sent to the server as a single request. Because of this, the server executes it as a single transaction even if the string contains multiple SQL commands, unless there are explicit \u003ccode\u003eBEGIN\u003c/code\u003e/\u003ccode\u003eCOMMIT\u003c/code\u003e commands included in the string to divide it into multiple transactions. (See \u003ca href=\"/docs/18/protocol-flow.html#PROTOCOL-FLOW-MULTI-STATEMENT\" rel=\"nofollow\"\u003eSection 54.2.2.1\u003c/a\u003e for more details about how the server handles multi-query strings.)\u003c/p\u003e\n\u003cp\u003eIf having several commands executed in one transaction is not desired, use repeated \u003ccode\u003e-c\u003c/code\u003e commands or feed multiple commands to \u003cspan\u003epsql\u003c/span\u003e\u0026#39;s standard input, either using \u003cspan\u003eecho\u003c/span\u003e as illustrated above, or via a shell here-document, for example:\u003c/p\u003e\n\u003cpre\u003epsql \u0026lt;\u0026lt;EOF\n\\x\nSELECT * FROM foo;\nEOF\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-CSV\"\u003e\u003cspan\u003e\u003ccode\u003e--csv\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSwitches to CSV (Comma-Separated Values) output mode. This is equivalent to \u003ccode\u003e\\pset format csv\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-DBNAME\"\u003e\u003cspan\u003e\u003ccode\u003e-d \u003cem\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--dbname=\u003cem\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the name of the database to connect to. This is equivalent to specifying \u003cem\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e as the first non-option argument on the command line. The \u003cem\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e can be a \u003ca href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" rel=\"nofollow\"\u003econnection string\u003c/a\u003e. If so, connection string parameters will override any conflicting command line options.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-ECHO-QUERIES\"\u003e\u003cspan\u003e\u003ccode\u003e-e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--echo-queries\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCopy all SQL commands sent to the server to standard output as well. This is equivalent to setting the variable \u003ccode\u003eECHO\u003c/code\u003e to \u003ccode\u003equeries\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-ECHO-HIDDEN\"\u003e\u003cspan\u003e\u003ccode\u003e-E\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--echo-hidden\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEcho the actual queries generated by \u003ccode\u003e\\d\u003c/code\u003e and other backslash commands. You can use this to study \u003cspan\u003epsql\u003c/span\u003e\u0026#39;s internal operations. This is equivalent to setting the variable \u003ccode\u003eECHO_HIDDEN\u003c/code\u003e to \u003ccode\u003eon\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-FILE\"\u003e\u003cspan\u003e\u003ccode\u003e-f \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--file=\u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRead commands from the file \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e, rather than standard input. This option can be repeated and combined in any order with the \u003ccode\u003e-c\u003c/code\u003e option. When either \u003ccode\u003e-c\u003c/code\u003e or \u003ccode\u003e-f\u003c/code\u003e is specified, \u003cspan\u003epsql\u003c/span\u003e does not read commands from standard input; instead it terminates after processing all the \u003ccode\u003e-c\u003c/code\u003e and \u003ccode\u003e-f\u003c/code\u003e options in sequence. Except for that, this option is largely equivalent to the meta-command \u003ccode\u003e\\i\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eIf \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e is \u003ccode\u003e-\u003c/code\u003e (hyphen), then standard input is read until an EOF indication or \u003ccode\u003e\\q\u003c/code\u003e meta-command. This can be used to intersperse interactive input with input from files. Note however that Readline is not used in this case (much as if \u003ccode\u003e-n\u003c/code\u003e had been specified).\u003c/p\u003e\n\u003cp\u003eUsing this option is subtly different from writing \u003ccode\u003epsql \u0026lt; \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e. In general, both will do what you expect, but using \u003ccode\u003e-f\u003c/code\u003e enables some nice features such as error messages with line numbers. There is also a slight chance that using this option will reduce the start-up overhead. On the other hand, the variant using the shell\u0026#39;s input redirection is (in theory) guaranteed to yield exactly the same output you would have received had you entered everything by hand.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-FIELD-SEPARATOR\"\u003e\u003cspan\u003e\u003ccode\u003e-F \u003cem\u003e\u003ccode\u003eseparator\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--field-separator=\u003cem\u003e\u003ccode\u003eseparator\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUse \u003cem\u003e\u003ccode\u003eseparator\u003c/code\u003e\u003c/em\u003e as the field separator for unaligned output. This is equivalent to \u003ccode\u003e\\pset fieldsep\u003c/code\u003e or \u003ccode\u003e\\f\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-FIELD-HOST\"\u003e\u003cspan\u003e\u003ccode\u003e-h \u003cem\u003e\u003ccode\u003ehostname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--host=\u003cem\u003e\u003ccode\u003ehostname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix-domain socket.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-HTML\"\u003e\u003cspan\u003e\u003ccode\u003e-H\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--html\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSwitches to HTML output mode. This is equivalent to \u003ccode\u003e\\pset format html\u003c/code\u003e or the \u003ccode\u003e\\H\u003c/code\u003e command.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-LIST\"\u003e\u003cspan\u003e\u003ccode\u003e-l\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--list\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eList all available databases, then exit. Other non-connection options are ignored. This is similar to the meta-command \u003ccode\u003e\\list\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eWhen this option is used, \u003cspan\u003epsql\u003c/span\u003e will connect to the database \u003ccode\u003epostgres\u003c/code\u003e, unless a different database is named on the command line (option \u003ccode\u003e-d\u003c/code\u003e or non-option argument, possibly via a service entry, but not via an environment variable).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-LOG-FILE\"\u003e\u003cspan\u003e\u003ccode\u003e-L \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--log-file=\u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWrite all query output into file \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e, in addition to the normal output destination.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-NO-READLINE\"\u003e\u003cspan\u003e\u003ccode\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--no-readline\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not use \u003cspan\u003eReadline\u003c/span\u003e for line editing and do not use the command history (see \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-READLINE\" title=\"Command-Line Editing\" rel=\"nofollow\"\u003ethe section called “Command-Line Editing”\u003c/a\u003e below).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-OUTPUT\"\u003e\u003cspan\u003e\u003ccode\u003e-o \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--output=\u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePut all query output into file \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e. This is equivalent to the command \u003ccode\u003e\\o\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-PORT\"\u003e\u003cspan\u003e\u003ccode\u003e-p \u003cem\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--port=\u003cem\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the TCP port or the local Unix-domain socket file extension on which the server is listening for connections. Defaults to the value of the \u003ccode\u003ePGPORT\u003c/code\u003e environment variable or, if not set, to the port specified at compile time, usually 5432.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-PSET\"\u003e\u003cspan\u003e\u003ccode\u003e-P \u003cem\u003e\u003ccode\u003eassignment\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--pset=\u003cem\u003e\u003ccode\u003eassignment\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies printing options, in the style of \u003ccode\u003e\\pset\u003c/code\u003e. Note that here you have to separate name and value with an equal sign instead of a space. For example, to set the output format to \u003cspan\u003eLaTeX\u003c/span\u003e, you could write \u003ccode\u003e-P format=latex\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-QUIET\"\u003e\u003cspan\u003e\u003ccode\u003e-q\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--quiet\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies that \u003cspan\u003epsql\u003c/span\u003e should do its work quietly. By default, it prints welcome messages and various informational output. If this option is used, none of this happens. This is useful with the \u003ccode\u003e-c\u003c/code\u003e option. This is equivalent to setting the variable \u003ccode\u003eQUIET\u003c/code\u003e to \u003ccode\u003eon\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-RECORD-SEPARATOR\"\u003e\u003cspan\u003e\u003ccode\u003e-R \u003cem\u003e\u003ccode\u003eseparator\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--record-separator=\u003cem\u003e\u003ccode\u003eseparator\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUse \u003cem\u003e\u003ccode\u003eseparator\u003c/code\u003e\u003c/em\u003e as the record separator for unaligned output. This is equivalent to \u003ccode\u003e\\pset recordsep\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-SINGLE-STEP\"\u003e\u003cspan\u003e\u003ccode\u003e-s\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--single-step\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRun in single-step mode. That means the user is prompted before each command is sent to the server, with the option to cancel execution as well. Use this to debug scripts.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-SINGLE-LINE\"\u003e\u003cspan\u003e\u003ccode\u003e-S\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--single-line\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRuns in single-line mode where a newline terminates an SQL command, as a semicolon does.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis mode is provided for those who insist on it, but you are not necessarily encouraged to use it. In particular, if you mix SQL and meta-commands on a line the order of execution might not always be clear to the inexperienced user.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-TUPLES-ONLY\"\u003e\u003cspan\u003e\u003ccode\u003e-t\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--tuples-only\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eTurn off printing of column names and result row count footers, etc. This is equivalent to \u003ccode\u003e\\t\u003c/code\u003e or \u003ccode\u003e\\pset tuples_only\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-TABLE-ATTR\"\u003e\u003cspan\u003e\u003ccode\u003e-T \u003cem\u003e\u003ccode\u003etable_options\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--table-attr=\u003cem\u003e\u003ccode\u003etable_options\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies options to be placed within the HTML \u003ccode\u003etable\u003c/code\u003e tag. See \u003ccode\u003e\\pset tableattr\u003c/code\u003e for details.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-USERNAME\"\u003e\u003cspan\u003e\u003ccode\u003e-U \u003cem\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--username=\u003cem\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eConnect to the database as the user \u003cem\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e instead of the default. (You must have permission to do so, of course.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-VARIABLE\"\u003e\u003cspan\u003e\u003ccode\u003e-v \u003cem\u003e\u003ccode\u003eassignment\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--set=\u003cem\u003e\u003ccode\u003eassignment\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--variable=\u003cem\u003e\u003ccode\u003eassignment\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePerform a variable assignment, like the \u003ccode\u003e\\set\u003c/code\u003e meta-command. Note that you must separate name and value, if any, by an equal sign on the command line. To unset a variable, leave off the equal sign. To set a variable with an empty value, use the equal sign but leave off the value. These assignments are done during command line processing, so variables that reflect connection state will get overwritten later.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-VERSION\"\u003e\u003cspan\u003e\u003ccode\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--version\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint the \u003cspan\u003epsql\u003c/span\u003e version and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-NO-PASSWORD\"\u003e\u003cspan\u003e\u003ccode\u003e-w\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--no-password\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eNever issue a password prompt. If the server requires password authentication and a password is not available from other sources such as a \u003ccode\u003e.pgpass\u003c/code\u003e file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password.\u003c/p\u003e\n\u003cp\u003eNote that this option will remain set for the entire session, and so it affects uses of the meta-command \u003ccode\u003e\\connect\u003c/code\u003e as well as the initial connection attempt.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-PASSWORD\"\u003e\u003cspan\u003e\u003ccode\u003e-W\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--password\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eForce \u003cspan\u003epsql\u003c/span\u003e to prompt for a password before connecting to a database, even if the password will not be used.\u003c/p\u003e\n\u003cp\u003eIf the server requires password authentication and a password is not available from other sources such as a \u003ccode\u003e.pgpass\u003c/code\u003e file, \u003cspan\u003epsql\u003c/span\u003e will prompt for a password in any case. However, \u003cspan\u003epsql\u003c/span\u003e will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing \u003ccode\u003e-W\u003c/code\u003e to avoid the extra connection attempt.\u003c/p\u003e\n\u003cp\u003eNote that this option will remain set for the entire session, and so it affects uses of the meta-command \u003ccode\u003e\\connect\u003c/code\u003e as well as the initial connection attempt.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-EXPANDED\"\u003e\u003cspan\u003e\u003ccode\u003e-x\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--expanded\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eTurn on the expanded table formatting mode. This is equivalent to \u003ccode\u003e\\x\u003c/code\u003e or \u003ccode\u003e\\pset expanded\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-NO-PSQLRC\"\u003e\u003cspan\u003e\u003ccode\u003e-X\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--no-psqlrc\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not read the start-up file (neither the system-wide \u003ccode\u003epsqlrc\u003c/code\u003e file nor the user\u0026#39;s \u003ccode\u003e~/.psqlrc\u003c/code\u003e file).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-FIELD-SEPARATOR-ZERO\"\u003e\u003cspan\u003e\u003ccode\u003e-z\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--field-separator-zero\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSet the field separator for unaligned output to a zero byte. This is equivalent to \u003ccode\u003e\\pset fieldsep_zero\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-RECORD-SEPARATOR-ZERO\"\u003e\u003cspan\u003e\u003ccode\u003e-0\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--record-separator-zero\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSet the record separator for unaligned output to a zero byte. This is useful for interfacing, for example, with \u003ccode\u003exargs -0\u003c/code\u003e. This is equivalent to \u003ccode\u003e\\pset recordsep_zero\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-SINGLE-TRANSACTION\"\u003e\u003cspan\u003e\u003ccode\u003e-1\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--single-transaction\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option can only be used in combination with one or more \u003ccode\u003e-c\u003c/code\u003e and/or \u003ccode\u003e-f\u003c/code\u003e options. It causes \u003cspan\u003epsql\u003c/span\u003e to issue a \u003ccode\u003eBEGIN\u003c/code\u003e command before the first such option and a \u003ccode\u003eCOMMIT\u003c/code\u003e command after the last one, thereby wrapping all the commands into a single transaction. If any of the commands fails and the variable \u003ccode\u003eON_ERROR_STOP\u003c/code\u003e was set, a \u003ccode\u003eROLLBACK\u003c/code\u003e command is sent instead. This ensures that either all the commands complete successfully, or no changes are applied.\u003c/p\u003e\n\u003cp\u003eIf the commands themselves contain \u003ccode\u003eBEGIN\u003c/code\u003e, \u003ccode\u003eCOMMIT\u003c/code\u003e, or \u003ccode\u003eROLLBACK\u003c/code\u003e, this option will not have the desired effects. Also, if an individual command cannot be executed inside a transaction block, specifying this option will cause the whole transaction to fail.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-HELP\"\u003e\u003cspan\u003e\u003ccode\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--help[=\u003cem\u003e\u003ccode\u003etopic\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow help about \u003cspan\u003epsql\u003c/span\u003e and exit. The optional \u003cem\u003e\u003ccode\u003etopic\u003c/code\u003e\u003c/em\u003e parameter (defaulting to \u003ccode\u003eoptions\u003c/code\u003e) selects which part of \u003cspan\u003epsql\u003c/span\u003e is explained: \u003ccode\u003ecommands\u003c/code\u003e describes \u003cspan\u003epsql\u003c/span\u003e\u0026#39;s backslash commands; \u003ccode\u003eoptions\u003c/code\u003e describes the command-line options that can be passed to \u003cspan\u003epsql\u003c/span\u003e; and \u003ccode\u003evariables\u003c/code\u003e shows help about \u003cspan\u003epsql\u003c/span\u003e configuration variables.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.21.7\"\u003e\n\u003ch2\u003eExit Status\u003c/h2\u003e\n\u003cp\u003e\u003cspan\u003epsql\u003c/span\u003e returns 0 to the shell if it finished normally, 1 if a fatal error of its own occurs (e.g., out of memory, file not found), 2 if the connection to the server went bad and the session was not interactive, and 3 if an error occurred in a script and the variable \u003ccode\u003eON_ERROR_STOP\u003c/code\u003e was set.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.21.8\"\u003e\n\u003ch2\u003eUsage\u003c/h2\u003e\n\u003cdiv id=\"R2-APP-PSQL-CONNECTING\"\u003e\n\u003ch3\u003eConnecting to a Database\u003c/h3\u003e\n\u003cp\u003e\u003cspan\u003epsql\u003c/span\u003e is a regular \u003cspan\u003ePostgreSQL\u003c/span\u003e client application. In order to connect to a database you need to know the name of your target database, the host name and port number of the server, and what database user name you want to connect as. \u003cspan\u003epsql\u003c/span\u003e can be told about those parameters via command line options, namely \u003ccode\u003e-d\u003c/code\u003e, \u003ccode\u003e-h\u003c/code\u003e, \u003ccode\u003e-p\u003c/code\u003e, and \u003ccode\u003e-U\u003c/code\u003e respectively. If an argument is found that does not belong to any option it will be interpreted as the database name (or the database user name, if the database name is already given). Not all of these options are required; there are useful defaults. If you omit the host name, \u003cspan\u003epsql\u003c/span\u003e will connect via a Unix-domain socket to a server on the local host, or via TCP/IP to \u003ccode\u003elocalhost\u003c/code\u003e on Windows. The default port number is determined at compile time. Since the database server uses the same default, you will not have to specify the port in most cases. The default database user name is your operating-system user name. Once the database user name is determined, it is used as the default database name. Note that you cannot just connect to any database under any database user name. Your database administrator should have informed you about your access rights.\u003c/p\u003e\n\u003cp\u003eWhen the defaults aren\u0026#39;t quite right, you can save yourself some typing by setting the environment variables \u003ccode\u003ePGDATABASE\u003c/code\u003e, \u003ccode\u003ePGHOST\u003c/code\u003e, \u003ccode\u003ePGPORT\u003c/code\u003e and/or \u003ccode\u003ePGUSER\u003c/code\u003e to appropriate values. (For additional environment variables, see \u003ca href=\"/docs/18/libpq-envars.html\" rel=\"nofollow\"\u003eSection 32.15\u003c/a\u003e.) It is also convenient to have a \u003ccode\u003e~/.pgpass\u003c/code\u003e file to avoid regularly having to type in passwords. See \u003ca href=\"/docs/18/libpq-pgpass.html\" rel=\"nofollow\"\u003eSection 32.16\u003c/a\u003e for more information.\u003c/p\u003e\n\u003cp\u003eAn alternative way to specify connection parameters is in a \u003cem\u003e\u003ccode\u003econninfo\u003c/code\u003e\u003c/em\u003e string or a URI, which is used instead of a database name. This mechanism give you very wide control over the connection. For example:\u003c/p\u003e\n\u003cpre\u003e$ \u003cstrong\u003e\u003ccode\u003epsql \u0026#34;service=myservice sslmode=require\u0026#34;\u003c/code\u003e\u003c/strong\u003e\n$ \u003cstrong\u003e\u003ccode\u003epsql postgresql://dbmaster:5433/mydb?sslmode=require\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eThis way you can also use LDAP for connection parameter lookup as described in \u003ca href=\"/docs/18/libpq-ldap.html\" rel=\"nofollow\"\u003eSection 32.18\u003c/a\u003e. See \u003ca href=\"/docs/18/libpq-connect.html#LIBPQ-PARAMKEYWORDS\" rel=\"nofollow\"\u003eSection 32.1.2\u003c/a\u003e for more information on all the available connection options.\u003c/p\u003e\n\u003cp\u003eIf the connection could not be made for any reason (e.g., insufficient privileges, server is not running on the targeted host, etc.), \u003cspan\u003epsql\u003c/span\u003e will return an error and terminate.\u003c/p\u003e\n\u003cp\u003eIf both standard input and standard output are a terminal, then \u003cspan\u003epsql\u003c/span\u003e sets the client encoding to \u003cspan\u003e“\u003cspan\u003eauto\u003c/span\u003e”\u003c/span\u003e, which will detect the appropriate client encoding from the locale settings (\u003ccode\u003eLC_CTYPE\u003c/code\u003e environment variable on Unix systems). If this doesn\u0026#39;t work out as expected, the client encoding can be overridden using the environment variable \u003ccode\u003ePGCLIENTENCODING\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"R2-APP-PSQL-4\"\u003e\n\u003ch3\u003eEntering SQL Commands\u003c/h3\u003e\n\u003cp\u003eIn normal operation, \u003cspan\u003epsql\u003c/span\u003e provides a prompt with the name of the database to which \u003cspan\u003epsql\u003c/span\u003e is currently connected, followed by the string \u003ccode\u003e=\u0026gt;\u003c/code\u003e. For example:\u003c/p\u003e\n\u003cpre\u003e$ \u003cstrong\u003e\u003ccode\u003epsql testdb\u003c/code\u003e\u003c/strong\u003e\npsql (18.6)\nType \u0026#34;help\u0026#34; for help.\n\ntestdb=\u0026gt;\n\u003c/pre\u003e\n\u003cp\u003eAt the prompt, the user can type in SQL commands. Ordinarily, input lines are sent to the server when a command-terminating semicolon is reached. An end of line does not terminate a command. Thus commands can be spread over several lines for clarity. If the command was sent and executed without error, the results of the command are displayed on the screen.\u003c/p\u003e\n\u003cp\u003eIf untrusted users have access to a database that has not adopted a \u003ca href=\"/docs/18/ddl-schemas.html#DDL-SCHEMAS-PATTERNS\" rel=\"nofollow\"\u003esecure schema usage pattern\u003c/a\u003e, begin your session by removing publicly-writable schemas from \u003ccode\u003esearch_path\u003c/code\u003e. One can add \u003ccode\u003eoptions=-csearch_path=\u003c/code\u003e to the connection string or issue \u003ccode\u003eSELECT pg_catalog.set_config(\u0026#39;search_path\u0026#39;, \u0026#39;\u0026#39;, false)\u003c/code\u003e before other SQL commands. This consideration is not specific to \u003cspan\u003epsql\u003c/span\u003e; it applies to every interface for executing arbitrary SQL commands.\u003c/p\u003e\n\u003cp\u003eWhenever a command is executed, \u003cspan\u003epsql\u003c/span\u003e also polls for asynchronous notification events generated by \u003ca href=\"/docs/18/sql-listen.html\" title=\"LISTEN\" rel=\"nofollow\"\u003e\u003ccode\u003eLISTEN\u003c/code\u003e\u003c/a\u003e and \u003ca href=\"/docs/18/sql-notify.html\" title=\"NOTIFY\" rel=\"nofollow\"\u003e\u003ccode\u003eNOTIFY\u003c/code\u003e\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eWhile C-style block comments are passed to the server for processing and removal, SQL-standard comments are removed by \u003cspan\u003epsql\u003c/span\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"APP-PSQL-META-COMMANDS\"\u003e\n\u003ch3\u003eMeta-Commands\u003c/h3\u003e\n\u003cp\u003eAnything you enter in \u003cspan\u003epsql\u003c/span\u003e that begins with an unquoted backslash is a \u003cspan\u003epsql\u003c/span\u003e meta-command that is processed by \u003cspan\u003epsql\u003c/span\u003e itself. These commands make \u003cspan\u003epsql\u003c/span\u003e more useful for administration or scripting. Meta-commands are often called slash or backslash commands.\u003c/p\u003e\n\u003cp\u003eThe format of a \u003cspan\u003epsql\u003c/span\u003e command is the backslash, followed immediately by a command verb, then any arguments. The arguments are separated from the command verb and each other by any number of whitespace characters.\u003c/p\u003e\n\u003cp\u003eTo include whitespace in an argument you can quote it with single quotes. To include a single quote in an argument, write two single quotes within single-quoted text. Anything contained in single quotes is furthermore subject to C-like substitutions for \u003ccode\u003e\\n\u003c/code\u003e (new line), \u003ccode\u003e\\t\u003c/code\u003e (tab), \u003ccode\u003e\\b\u003c/code\u003e (backspace), \u003ccode\u003e\\r\u003c/code\u003e (carriage return), \u003ccode\u003e\\f\u003c/code\u003e (form feed), \u003ccode\u003e\\\u003c/code\u003e\u003cem\u003e\u003ccode\u003edigits\u003c/code\u003e\u003c/em\u003e (octal), and \u003ccode\u003e\\x\u003c/code\u003e\u003cem\u003e\u003ccode\u003edigits\u003c/code\u003e\u003c/em\u003e (hexadecimal). A backslash preceding any other character within single-quoted text quotes that single character, whatever it is.\u003c/p\u003e\n\u003cp\u003eIf an unquoted colon (\u003ccode\u003e:\u003c/code\u003e) followed by a \u003cspan\u003epsql\u003c/span\u003e variable name appears within an argument, it is replaced by the variable\u0026#39;s value, as described in \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-INTERPOLATION\" title=\"SQL Interpolation\" rel=\"nofollow\"\u003eSQL Interpolation\u003c/a\u003e below. The forms \u003ccode\u003e:\u0026#39;\u003cem\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e\u0026#39;\u003c/code\u003e and \u003ccode\u003e:\u0026#34;\u003cem\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e\u0026#34;\u003c/code\u003e described there work as well. The \u003ccode\u003e:{?\u003cem\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e}\u003c/code\u003e syntax allows testing whether a variable is defined. It is substituted by TRUE or FALSE. Escaping the colon with a backslash protects it from substitution.\u003c/p\u003e\n\u003cp\u003eWithin an argument, text that is enclosed in backquotes (\u003ccode\u003e`\u003c/code\u003e) is taken as a command line that is passed to the shell. The output of the command (with any trailing newline removed) replaces the backquoted text. Within the text enclosed in backquotes, no special quoting or other processing occurs, except that appearances of \u003ccode\u003e:\u003cem\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e where \u003cem\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e is a \u003cspan\u003epsql\u003c/span\u003e variable name are replaced by the variable\u0026#39;s value. Also, appearances of \u003ccode\u003e:\u0026#39;\u003cem\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e\u0026#39;\u003c/code\u003e are replaced by the variable\u0026#39;s value suitably quoted to become a single shell command argument. (The latter form is almost always preferable, unless you are very sure of what is in the variable.) Because carriage return and line feed characters cannot be safely quoted on all platforms, the \u003ccode\u003e:\u0026#39;\u003cem\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e\u0026#39;\u003c/code\u003e form prints an error message and does not substitute the variable value when such characters appear in the value.\u003c/p\u003e\n\u003cp\u003eSome commands take an SQL identifier (such as a table name) as argument. These arguments follow the syntax rules of SQL: Unquoted letters are forced to lowercase, while double quotes (\u003ccode\u003e\u0026#34;\u003c/code\u003e) protect letters from case conversion and allow incorporation of whitespace into the identifier. Within double quotes, paired double quotes reduce to a single double quote in the resulting name. For example, \u003ccode\u003eFOO\u0026#34;BAR\u0026#34;BAZ\u003c/code\u003e is interpreted as \u003ccode\u003efooBARbaz\u003c/code\u003e, and \u003ccode\u003e\u0026#34;A weird\u0026#34;\u0026#34; name\u0026#34;\u003c/code\u003e becomes \u003ccode\u003eA weird\u0026#34; name\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eParsing for arguments stops at the end of the line, or when another unquoted backslash is found. An unquoted backslash is taken as the beginning of a new meta-command. The special sequence \u003ccode\u003e\\\\\u003c/code\u003e (two backslashes) marks the end of arguments and continues parsing SQL commands, if any. That way SQL and \u003cspan\u003epsql\u003c/span\u003e commands can be freely mixed on a line. But in any case, the arguments of a meta-command cannot continue beyond the end of the line.\u003c/p\u003e\n\u003cp\u003eMany of the meta-commands act on the \u003cem\u003ecurrent query buffer\u003c/em\u003e. This is simply a buffer holding whatever SQL command text has been typed but not yet sent to the server for execution. This will include previous input lines as well as any text appearing before the meta-command on the same line.\u003c/p\u003e\n\u003cp\u003eMany of the meta-commands also allow \u003ccode\u003ex\u003c/code\u003e to be appended as an option. This will cause the results to be displayed in expanded mode, as if \u003ccode\u003e\\x\u003c/code\u003e or \u003ccode\u003e\\pset expanded\u003c/code\u003e had been used.\u003c/p\u003e\n\u003cp\u003eThe following meta-commands are defined:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-A\"\u003e\u003cspan\u003e\u003ccode\u003e\\a\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf 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 \u003ccode\u003e\\pset\u003c/code\u003e for a more general solution.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-BIND\"\u003e\u003cspan\u003e\u003ccode\u003e\\bind\u003c/code\u003e [ \u003cem\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e ] ...\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets query parameters for the next query execution, with the specified parameters passed for any parameter placeholders (\u003ccode\u003e$1\u003c/code\u003e etc.).\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre\u003eINSERT INTO tbl1 VALUES ($1, $2) \\bind \u0026#39;first value\u0026#39; \u0026#39;second value\u0026#39; \\g\n\u003c/pre\u003e\n\u003cp\u003eThis also works for query-execution commands besides \u003ccode\u003e\\g\u003c/code\u003e, such as \u003ccode\u003e\\gx\u003c/code\u003e and \u003ccode\u003e\\gset\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThis command causes the extended query protocol (see \u003ca href=\"/docs/18/protocol-overview.html#PROTOCOL-QUERY-CONCEPTS\" rel=\"nofollow\"\u003eSection 54.1.2\u003c/a\u003e) to be used, unlike normal \u003cspan\u003epsql\u003c/span\u003e operation, which uses the simple query protocol. So this command can be useful to test the extended query protocol from \u003cspan\u003epsql\u003c/span\u003e. (The extended query protocol is used even if the query has no parameters and this command specifies zero parameters.) This command affects only the next query executed; all subsequent queries will use the simple query protocol by default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-BIND-NAMED\"\u003e\u003cspan\u003e\u003ccode\u003e\\bind_named\u003c/code\u003e \u003cem\u003e\u003ccode\u003estatement_name\u003c/code\u003e\u003c/em\u003e [ \u003cem\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e ] ...\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003e\u003ccode\u003e\\bind_named\u003c/code\u003e is equivalent to \u003ccode\u003e\\bind\u003c/code\u003e, except that it takes the name of an existing prepared statement as first parameter. An empty string denotes the unnamed prepared statement.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre\u003eINSERT INTO tbls1 VALUES ($1, $2) \\parse stmt1\n\\bind_named stmt1 \u0026#39;first value\u0026#39; \u0026#39;second value\u0026#39; \\g\n\u003c/pre\u003e\n\u003cp\u003eThis command causes the extended query protocol (see \u003ca href=\"/docs/18/protocol-overview.html#PROTOCOL-QUERY-CONCEPTS\" rel=\"nofollow\"\u003eSection 54.1.2\u003c/a\u003e) to be used, unlike normal \u003cspan\u003epsql\u003c/span\u003e operation, which uses the simple query protocol. So this command can be useful to test the extended query protocol from \u003cspan\u003epsql\u003c/span\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-C-LC\"\u003e\u003cspan\u003e\u003ccode\u003e\\c\u003c/code\u003e or \u003ccode\u003e\\connect [ -reuse-previous=\u003cem\u003e\u003ccode\u003eon|off\u003c/code\u003e\u003c/em\u003e ] [ \u003cem\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e [ \u003cem\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e ] [ \u003cem\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e ] [ \u003cem\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e ] | \u003cem\u003e\u003ccode\u003econninfo\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEstablishes a new connection to a \u003cspan\u003ePostgreSQL\u003c/span\u003e 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 \u003cem\u003e\u003ccode\u003econninfo\u003c/code\u003e\u003c/em\u003e connection string as detailed in \u003ca href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" rel=\"nofollow\"\u003eSection 32.1.1\u003c/a\u003e. If no arguments are given, a new connection is made using the same parameters as before.\u003c/p\u003e\n\u003cp\u003eSpecifying any of \u003cem\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e, \u003cem\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e, \u003cem\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e or \u003cem\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e as \u003ccode\u003e-\u003c/code\u003e is equivalent to omitting that parameter.\u003c/p\u003e\n\u003cp\u003eThe new connection can re-use connection parameters from the previous connection; not only database name, user, host, and port, but other settings such as \u003cem\u003e\u003ccode\u003esslmode\u003c/code\u003e\u003c/em\u003e. By default, parameters are re-used in the positional syntax, but not when a \u003cem\u003e\u003ccode\u003econninfo\u003c/code\u003e\u003c/em\u003e string is given. Passing a first argument of \u003ccode\u003e-reuse-previous=on\u003c/code\u003e or \u003ccode\u003e-reuse-previous=off\u003c/code\u003e overrides that default. If parameters are re-used, then any parameter not explicitly specified as a positional parameter or in the \u003cem\u003e\u003ccode\u003econninfo\u003c/code\u003e\u003c/em\u003e string is taken from the existing connection\u0026#39;s parameters. An exception is that if the \u003cem\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e setting is changed from its previous value using the positional syntax, any \u003cem\u003e\u003ccode\u003ehostaddr\u003c/code\u003e\u003c/em\u003e setting present in the existing connection\u0026#39;s parameters is dropped. Also, any password used for the existing connection will be re-used only if the user, host, and port settings are not changed. When the command neither specifies nor reuses a particular parameter, the \u003cspan\u003elibpq\u003c/span\u003e default is used.\u003c/p\u003e\n\u003cp\u003eIf the new connection is successfully made, the previous connection is closed. If the connection attempt fails (wrong user name, access denied, etc.), the previous connection will be kept if \u003cspan\u003epsql\u003c/span\u003e is in interactive mode. But when executing a non-interactive script, the old connection is closed and an error is reported. That may or may not terminate the script; if it does not, all database-accessing commands will fail until another \u003ccode\u003e\\connect\u003c/code\u003e command is successfully executed. 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. Note that whenever a \u003ccode\u003e\\connect\u003c/code\u003e command attempts to re-use parameters, the values re-used are those of the last successful connection, not of any failed attempts made subsequently. However, in the case of a non-interactive \u003ccode\u003e\\connect\u003c/code\u003e failure, no parameters are allowed to be re-used later, since the script would likely be expecting the values from the failed \u003ccode\u003e\\connect\u003c/code\u003e to be re-used.\u003c/p\u003e\n\u003cp\u003eExamples:\u003c/p\u003e\n\u003cpre\u003e=\u0026gt; \\c mydb myuser host.dom 6432\n=\u0026gt; \\c service=foo\n=\u0026gt; \\c \u0026#34;host=localhost port=5432 dbname=mydb connect_timeout=10 sslmode=disable\u0026#34;\n=\u0026gt; \\c -reuse-previous=on sslmode=require    -- changes only sslmode\n=\u0026gt; \\c postgresql://tom@localhost/mydb?application_name=myapp\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-C-UC\"\u003e\u003cspan\u003e\u003ccode\u003e\\C [ \u003cem\u003e\u003ccode\u003etitle\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the title of any tables being printed as the result of a query or unset any such title. This command is equivalent to \u003ccode\u003e\\pset title \u003cem\u003e\u003ccode\u003etitle\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e. (The name of this command derives from \u003cspan\u003e“\u003cspan\u003ecaption\u003c/span\u003e”\u003c/span\u003e, as it was previously only used to set the caption in an HTML table.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-CD\"\u003e\u003cspan\u003e\u003ccode\u003e\\cd [ \u003cem\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eChanges the current working directory to \u003cem\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e. Without argument, changes to the current user\u0026#39;s home directory. For details on how home directories are found, see \u003ca href=\"/docs/18/libpq-pgpass.html\" rel=\"nofollow\"\u003eSection 32.16\u003c/a\u003e.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eTip\u003c/h3\u003e\n\u003cp\u003eTo print your current working directory, use \u003ccode\u003e\\! pwd\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-CLOSE-PREPARED\"\u003e\u003cspan\u003e\u003ccode\u003e\\close_prepared\u003c/code\u003e \u003cem\u003e\u003ccode\u003eprepared_statement_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCloses 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.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre\u003eSELECT $1 \\parse stmt1\n\\close_prepared stmt1\n\u003c/pre\u003e\n\u003cp\u003eThis command causes the extended query protocol to be used, unlike normal \u003cspan\u003epsql\u003c/span\u003e operation, which uses the simple query protocol. So this command can be useful to test the extended query protocol from \u003cspan\u003epsql\u003c/span\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-CONNINFO\"\u003e\u003cspan\u003e\u003ccode\u003e\\conninfo\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eOutputs information about the current database connection, including SSL-related information if SSL is in use.\u003c/p\u003e\n\u003cp\u003eNote that the \u003ccode\u003eClient User\u003c/code\u003e field shows the user at the time of connection, while the \u003ccode\u003eSuperuser\u003c/code\u003e field indicates whether the current user (in the current execution context) has superuser privileges. These users are usually the same, but they can differ, for example, if the current user was changed with the \u003ccode\u003eSET ROLE\u003c/code\u003e command.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMANDS-COPY\"\u003e\u003cspan\u003e\u003ccode\u003e\\copy { \u003cem\u003e\u003ccode\u003etable\u003c/code\u003e\u003c/em\u003e [ ( \u003cem\u003e\u003ccode\u003ecolumn_list\u003c/code\u003e\u003c/em\u003e ) ] } \u003ccode\u003efrom\u003c/code\u003e { \u003cem\u003e\u003ccode\u003e\u0026#39;filename\u0026#39;\u003c/code\u003e\u003c/em\u003e | program \u003cem\u003e\u003ccode\u003e\u0026#39;command\u0026#39;\u003c/code\u003e\u003c/em\u003e | stdin | pstdin } [ [ with ] ( \u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e [, ...] ) ] [ where \u003cem\u003e\u003ccode\u003econdition\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\copy { \u003cem\u003e\u003ccode\u003etable\u003c/code\u003e\u003c/em\u003e [ ( \u003cem\u003e\u003ccode\u003ecolumn_list\u003c/code\u003e\u003c/em\u003e ) ] | ( \u003cem\u003e\u003ccode\u003equery\u003c/code\u003e\u003c/em\u003e ) } \u003ccode\u003eto\u003c/code\u003e { \u003cem\u003e\u003ccode\u003e\u0026#39;filename\u0026#39;\u003c/code\u003e\u003c/em\u003e | program \u003cem\u003e\u003ccode\u003e\u0026#39;command\u0026#39;\u003c/code\u003e\u003c/em\u003e | stdout | pstdout } [ [ with ] ( \u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e [, ...] ) ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePerforms a frontend (client) copy. This is an operation that runs an SQL \u003ca href=\"/docs/18/sql-copy.html\" title=\"COPY\" rel=\"nofollow\"\u003e\u003ccode\u003eCOPY\u003c/code\u003e\u003c/a\u003e command, but instead of the server reading or writing the specified file, \u003cspan\u003epsql\u003c/span\u003e 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.\u003c/p\u003e\n\u003cp\u003eWhen \u003ccode\u003eprogram\u003c/code\u003e is specified, \u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e is executed by \u003cspan\u003epsql\u003c/span\u003e and the data passed from or to \u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e is routed between the server and the client. Again, the execution privileges are those of the local user, not the server, and no SQL superuser privileges are required.\u003c/p\u003e\n\u003cp\u003eFor \u003ccode\u003e\\copy ... from stdin\u003c/code\u003e, data rows are read from the same source that issued the command, continuing until a line containing only \u003ccode\u003e\\.\u003c/code\u003e is read or the stream reaches EOF. This option is useful for populating tables in-line within an SQL script file. For \u003ccode\u003e\\copy ... to stdout\u003c/code\u003e, output is sent to the same place as \u003cspan\u003epsql\u003c/span\u003e command output, and the \u003ccode\u003eCOPY \u003cem\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e command status is not printed (since it might be confused with a data row). To read/write \u003cspan\u003epsql\u003c/span\u003e\u0026#39;s standard input or output regardless of the current command source or \u003ccode\u003e\\o\u003c/code\u003e option, write \u003ccode\u003efrom pstdin\u003c/code\u003e or \u003ccode\u003eto pstdout\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe syntax of this command is similar to that of the SQL \u003ca href=\"/docs/18/sql-copy.html\" title=\"COPY\" rel=\"nofollow\"\u003e\u003ccode\u003eCOPY\u003c/code\u003e\u003c/a\u003e command. All options other than the data source/destination are as specified for \u003ccode\u003eCOPY\u003c/code\u003e. Because of this, special parsing rules apply to the \u003ccode\u003e\\copy\u003c/code\u003e meta-command. Unlike most other meta-commands, the entire remainder of the line is always taken to be the arguments of \u003ccode\u003e\\copy\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eTip\u003c/h3\u003e\n\u003cp\u003eAnother way to obtain the same result as \u003ccode\u003e\\copy ... to\u003c/code\u003e is to use the SQL \u003ccode\u003eCOPY ... TO STDOUT\u003c/code\u003e command and terminate it with \u003ccode\u003e\\g \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e or \u003ccode\u003e\\g |\u003cem\u003e\u003ccode\u003eprogram\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e. Unlike \u003ccode\u003e\\copy\u003c/code\u003e, this method allows the command to span multiple lines; also, variable interpolation and backquote expansion can be used.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch3\u003eTip\u003c/h3\u003e\n\u003cp\u003eThese operations are not as efficient as the SQL \u003ccode\u003eCOPY\u003c/code\u003e command with a file or program data source or destination, because all data must pass through the client/server connection. For large amounts of data the SQL command might be preferable.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-COPYRIGHT\"\u003e\u003cspan\u003e\u003ccode\u003e\\copyright\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShows the copyright and distribution terms of \u003cspan\u003ePostgreSQL\u003c/span\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMANDS-CROSSTABVIEW\"\u003e\u003cspan\u003e\u003ccode\u003e\\crosstabview [ \u003cem\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e [ \u003cem\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e [ \u003cem\u003e\u003ccode\u003ecolD\u003c/code\u003e\u003c/em\u003e [ \u003cem\u003e\u003ccode\u003esortcolH\u003c/code\u003e\u003c/em\u003e ] ] ] ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eExecutes the current query buffer (like \u003ccode\u003e\\g\u003c/code\u003e) and shows the results in a crosstab grid. The query must return at least three columns. The output column identified by \u003cem\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e becomes a vertical header and the output column identified by \u003cem\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e becomes a horizontal header. \u003cem\u003e\u003ccode\u003ecolD\u003c/code\u003e\u003c/em\u003e identifies the output column to display within the grid. \u003cem\u003e\u003ccode\u003esortcolH\u003c/code\u003e\u003c/em\u003e identifies an optional sort column for the horizontal header.\u003c/p\u003e\n\u003cp\u003eEach column specification can be a column number (starting at 1) or a column name. The usual SQL case folding and quoting rules apply to column names. If omitted, \u003cem\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e is taken as column 1 and \u003cem\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e as column 2. \u003cem\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e must differ from \u003cem\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e. If \u003cem\u003e\u003ccode\u003ecolD\u003c/code\u003e\u003c/em\u003e is not specified, then there must be exactly three columns in the query result, and the column that is neither \u003cem\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e nor \u003cem\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e is taken to be \u003cem\u003e\u003ccode\u003ecolD\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eThe vertical header, displayed as the leftmost column, contains the values found in column \u003cem\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e, in the same order as in the query results, but with duplicates removed.\u003c/p\u003e\n\u003cp\u003eThe horizontal header, displayed as the first row, contains the values found in column \u003cem\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e, with duplicates removed. By default, these appear in the same order as in the query results. But if the optional \u003cem\u003e\u003ccode\u003esortcolH\u003c/code\u003e\u003c/em\u003e argument is given, it identifies a column whose values must be integer numbers, and the values from \u003cem\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e will appear in the horizontal header sorted according to the corresponding \u003cem\u003e\u003ccode\u003esortcolH\u003c/code\u003e\u003c/em\u003e values.\u003c/p\u003e\n\u003cp\u003eInside the crosstab grid, for each distinct value \u003ccode\u003ex\u003c/code\u003e of \u003cem\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e and each distinct value \u003ccode\u003ey\u003c/code\u003e of \u003cem\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e, the cell located at the intersection \u003ccode\u003e(x,y)\u003c/code\u003e contains the value of the \u003ccode\u003ecolD\u003c/code\u003e column in the query result row for which the value of \u003cem\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e is \u003ccode\u003ex\u003c/code\u003e and the value of \u003cem\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e is \u003ccode\u003ey\u003c/code\u003e. If there is no such row, the cell is empty. If there are multiple such rows, an error is reported.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-D\"\u003e\u003cspan\u003e\u003ccode\u003e\\d[Sx+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eFor each relation (table, view, materialized view, index, sequence, or foreign table) or composite type matching the \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e, show all columns, their types, the tablespace (if not the default) and any special attributes such as \u003ccode\u003eNOT NULL\u003c/code\u003e or defaults. Associated indexes, constraints, rules, and triggers are also shown. For foreign tables, the associated foreign server is shown as well. (\u003cspan\u003e“\u003cspan\u003eMatching the pattern\u003c/span\u003e”\u003c/span\u003e is defined in \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003ePatterns\u003c/a\u003e below.)\u003c/p\u003e\n\u003cp\u003eFor some types of relation, \u003ccode\u003e\\d\u003c/code\u003e shows additional information for each column: column values for sequences, indexed expressions for indexes, and foreign data wrapper options for foreign tables.\u003c/p\u003e\n\u003cp\u003eThe command form \u003ccode\u003e\\d+\u003c/code\u003e 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, the view definition if the relation is a view, a non-default \u003ca href=\"/docs/18/sql-altertable.html#SQL-ALTERTABLE-REPLICA-IDENTITY\" rel=\"nofollow\"\u003ereplica identity\u003c/a\u003e setting and the \u003ca href=\"/docs/18/sql-create-access-method.html\" title=\"CREATE ACCESS METHOD\" rel=\"nofollow\"\u003eaccess method\u003c/a\u003e name if the relation has an access method.\u003c/p\u003e\n\u003cp\u003eBy default, only user-created objects are shown; supply a pattern or the \u003ccode\u003eS\u003c/code\u003e modifier to include system objects.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003eIf \u003ccode\u003e\\d\u003c/code\u003e is used without a \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e argument, it is equivalent to \u003ccode\u003e\\dtvmsE\u003c/code\u003e which will show a list of all visible tables, views, materialized views, sequences and foreign tables. This is purely a convenience measure.\u003c/p\u003e\n\u003cp\u003eAs with many other commands, if \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode, but note that this only applies when \u003ccode\u003e\\d\u003c/code\u003e is used without a \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e argument, and the \u003ccode\u003ex\u003c/code\u003e modifier cannot appear immediately after the \u003ccode\u003e\\d\u003c/code\u003e (because \u003ccode\u003e\\dx\u003c/code\u003e is a different command); the \u003ccode\u003ex\u003c/code\u003e modifier may only appear after an \u003ccode\u003eS\u003c/code\u003e or \u003ccode\u003e+\u003c/code\u003e modifier. For example, \u003ccode\u003e\\d+x\u003c/code\u003e is equivalent to \u003ccode\u003e\\dtvmsE+x\u003c/code\u003e and will show a list of all relations in expanded mode.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DA-LC\"\u003e\u003cspan\u003e\u003ccode\u003e\\da[Sx] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists aggregate functions, together with their return type and the data types they operate on. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only aggregates whose names match the pattern are shown. By default, only user-created objects are shown; supply a pattern or the \u003ccode\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DA-UC\"\u003e\u003cspan\u003e\u003ccode\u003e\\dA[x+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists access methods. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only access methods whose names match the pattern are shown. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, each access method is listed with its associated handler function and description.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DAC\"\u003e\u003cspan\u003e\u003ccode\u003e\\dAc[x+] [\u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [\u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003einput-type-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e]]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists operator classes (see \u003ca href=\"/docs/18/xindex.html#XINDEX-OPCLASS\" rel=\"nofollow\"\u003eSection 36.16.1\u003c/a\u003e). If \u003cem\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e is specified, only operator classes associated with access methods whose names match that pattern are listed. If \u003cem\u003e\u003ccode\u003einput-type-pattern\u003c/code\u003e\u003c/em\u003e is specified, only operator classes associated with input types whose names match that pattern are listed. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, each operator class is listed with its associated operator family and owner.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DAF\"\u003e\u003cspan\u003e\u003ccode\u003e\\dAf[x+] [\u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [\u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003einput-type-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e]]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists operator families (see \u003ca href=\"/docs/18/xindex.html#XINDEX-OPFAMILY\" rel=\"nofollow\"\u003eSection 36.16.5\u003c/a\u003e). If \u003cem\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e is specified, only operator families associated with access methods whose names match that pattern are listed. If \u003cem\u003e\u003ccode\u003einput-type-pattern\u003c/code\u003e\u003c/em\u003e is specified, only operator families associated with input types whose names match that pattern are listed. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, each operator family is listed with its owner.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DAO\"\u003e\u003cspan\u003e\u003ccode\u003e\\dAo[x+] [\u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [\u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003eoperator-family-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e]]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists operators associated with operator families (see \u003ca href=\"/docs/18/xindex.html#XINDEX-STRATEGIES\" rel=\"nofollow\"\u003eSection 36.16.2\u003c/a\u003e). If \u003cem\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e is specified, only members of operator families associated with access methods whose names match that pattern are listed. If \u003cem\u003e\u003ccode\u003eoperator-family-pattern\u003c/code\u003e\u003c/em\u003e is specified, only members of operator families whose names match that pattern are listed. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DAP\"\u003e\u003cspan\u003e\u003ccode\u003e\\dAp[x+] [\u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [\u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003eoperator-family-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e]]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists support functions associated with operator families (see \u003ca href=\"/docs/18/xindex.html#XINDEX-SUPPORT\" rel=\"nofollow\"\u003eSection 36.16.3\u003c/a\u003e). If \u003cem\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e is specified, only functions of operator families associated with access methods whose names match that pattern are listed. If \u003cem\u003e\u003ccode\u003eoperator-family-pattern\u003c/code\u003e\u003c/em\u003e is specified, only functions of operator families whose names match that pattern are listed. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, functions are displayed verbosely, with their actual parameter lists.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DB\"\u003e\u003cspan\u003e\u003ccode\u003e\\db[x+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists tablespaces. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only tablespaces whose names match the pattern are shown. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, each tablespace is listed with its associated options, on-disk size, permissions and description.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DC-LC\"\u003e\u003cspan\u003e\u003ccode\u003e\\dc[Sx+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists conversions between character-set encodings. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only conversions whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the \u003ccode\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, each object is listed with its associated description.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DCONFIG\"\u003e\u003cspan\u003e\u003ccode\u003e\\dconfig[x+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists server configuration parameters and their values. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only parameters whose names match the pattern are listed. Without a \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e, only parameters that are set to non-default values are listed. (Use \u003ccode\u003e\\dconfig *\u003c/code\u003e to see all parameters.) If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e 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).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DC-UC\"\u003e\u003cspan\u003e\u003ccode\u003e\\dC[x+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists type casts. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only casts whose source or target types match the pattern are listed. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, additional information about each cast is shown, including whether its underlying function is leakproof, and the cast\u0026#39;s description.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DD-LC\"\u003e\u003cspan\u003e\u003ccode\u003e\\dd[Sx] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShows the descriptions of objects of type \u003ccode\u003econstraint\u003c/code\u003e, \u003ccode\u003eoperator class\u003c/code\u003e, \u003ccode\u003eoperator family\u003c/code\u003e, \u003ccode\u003erule\u003c/code\u003e, and \u003ccode\u003etrigger\u003c/code\u003e. All other comments may be viewed by the respective backslash commands for those object types.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e\\dd\u003c/code\u003e displays descriptions for objects matching the \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e, or of visible objects of the appropriate type if no argument is given. But in either case, only objects that have a description are listed. By default, only user-created objects are shown; supply a pattern or the \u003ccode\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003cp\u003eDescriptions for objects can be created with the \u003ca href=\"/docs/18/sql-comment.html\" title=\"COMMENT\" rel=\"nofollow\"\u003e\u003ccode\u003eCOMMENT\u003c/code\u003e\u003c/a\u003e SQL command.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DD-UC\"\u003e\u003cspan\u003e\u003ccode\u003e\\dD[Sx+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists domains. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only domains whose names match the pattern are shown. By default, only user-created objects are shown; supply a pattern or the \u003ccode\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, each object is listed with its associated permissions and description.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DDP\"\u003e\u003cspan\u003e\u003ccode\u003e\\ddp[x] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists 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 \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only entries whose role name or schema name matches the pattern are listed. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003cp\u003eThe \u003ca href=\"/docs/18/sql-alterdefaultprivileges.html\" title=\"ALTER DEFAULT PRIVILEGES\" rel=\"nofollow\"\u003e\u003ccode\u003eALTER DEFAULT PRIVILEGES\u003c/code\u003e\u003c/a\u003e command is used to set default access privileges. The meaning of the privilege display is explained in \u003ca href=\"/docs/18/ddl-priv.html\" rel=\"nofollow\"\u003eSection 5.8\u003c/a\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DE\"\u003e\u003cspan\u003e\u003ccode\u003e\\dE[Sx+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\di[Sx+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\dm[Sx+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\ds[Sx+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\dt[Sx+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\dv[Sx+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIn this group of commands, the letters \u003ccode\u003eE\u003c/code\u003e, \u003ccode\u003ei\u003c/code\u003e, \u003ccode\u003em\u003c/code\u003e, \u003ccode\u003es\u003c/code\u003e, \u003ccode\u003et\u003c/code\u003e, and \u003ccode\u003ev\u003c/code\u003e 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, \u003ccode\u003e\\dti\u003c/code\u003e lists tables and indexes. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e 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 \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only objects whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the \u003ccode\u003eS\u003c/code\u003e modifier to include system objects.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DES\"\u003e\u003cspan\u003e\u003ccode\u003e\\des[x+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists foreign servers (mnemonic: \u003cspan\u003e“\u003cspan\u003eexternal servers\u003c/span\u003e”\u003c/span\u003e). If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those servers whose name matches the pattern are listed. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, a full description of each server is shown, including the server\u0026#39;s access privileges, type, version, options, and description.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DET\"\u003e\u003cspan\u003e\u003ccode\u003e\\det[x+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists foreign tables (mnemonic: \u003cspan\u003e“\u003cspan\u003eexternal tables\u003c/span\u003e”\u003c/span\u003e). If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only entries whose table name or schema name matches the pattern are listed. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, generic options and the foreign table description are also displayed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DEU\"\u003e\u003cspan\u003e\u003ccode\u003e\\deu[x+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists user mappings (mnemonic: \u003cspan\u003e“\u003cspan\u003eexternal users\u003c/span\u003e”\u003c/span\u003e). If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those mappings whose user names match the pattern are listed. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, additional information about each mapping is shown.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eCaution\u003c/h3\u003e\n\u003cp\u003e\u003ccode\u003e\\deu+\u003c/code\u003e might also display the user name and password of the remote user, so care should be taken not to disclose them.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DEW\"\u003e\u003cspan\u003e\u003ccode\u003e\\dew[x+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists foreign-data wrappers (mnemonic: \u003cspan\u003e“\u003cspan\u003eexternal wrappers\u003c/span\u003e”\u003c/span\u003e). If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those foreign-data wrappers whose name matches the pattern are listed. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, the access privileges, options, and description of the foreign-data wrapper are also shown.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DF-LC\"\u003e\u003cspan\u003e\u003ccode\u003e\\df[anptwSx+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [ \u003cem\u003e\u003ccode\u003earg_pattern\u003c/code\u003e\u003c/em\u003e ... ] ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists functions, together with their result data types, argument data types, and function types, which are classified as \u003cspan\u003e“\u003cspan\u003eagg\u003c/span\u003e”\u003c/span\u003e (aggregate), \u003cspan\u003e“\u003cspan\u003enormal\u003c/span\u003e”\u003c/span\u003e, \u003cspan\u003e“\u003cspan\u003eprocedure\u003c/span\u003e”\u003c/span\u003e, \u003cspan\u003e“\u003cspan\u003etrigger\u003c/span\u003e”\u003c/span\u003e, or \u003cspan\u003e“\u003cspan\u003ewindow\u003c/span\u003e”\u003c/span\u003e. To display only functions of specific type(s), add the corresponding letters \u003ccode\u003ea\u003c/code\u003e, \u003ccode\u003en\u003c/code\u003e, \u003ccode\u003ep\u003c/code\u003e, \u003ccode\u003et\u003c/code\u003e, or \u003ccode\u003ew\u003c/code\u003e to the command. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e 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 \u003ccode\u003e-\u003c/code\u003e as the last \u003cem\u003e\u003ccode\u003earg_pattern\u003c/code\u003e\u003c/em\u003e.) By default, only user-created objects are shown; supply a pattern or the \u003ccode\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e 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 \u003ccode\u003e\\sf\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DF-UC\"\u003e\u003cspan\u003e\u003ccode\u003e\\dF[x+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists text search configurations. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only configurations whose names match the pattern are shown. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DFD\"\u003e\u003cspan\u003e\u003ccode\u003e\\dFd[x+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists text search dictionaries. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only dictionaries whose names match the pattern are shown. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, additional information is shown about each selected dictionary, including the underlying text search template and the option values.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DFP\"\u003e\u003cspan\u003e\u003ccode\u003e\\dFp[x+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists text search parsers. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only parsers whose names match the pattern are shown. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DFT\"\u003e\u003cspan\u003e\u003ccode\u003e\\dFt[x+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists text search templates. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only templates whose names match the pattern are shown. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, additional information is shown about each template, including the underlying function names.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DG\"\u003e\u003cspan\u003e\u003ccode\u003e\\dg[Sx+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists database roles. (Since the concepts of \u003cspan\u003e“\u003cspan\u003eusers\u003c/span\u003e”\u003c/span\u003e and \u003cspan\u003e“\u003cspan\u003egroups\u003c/span\u003e”\u003c/span\u003e have been unified into \u003cspan\u003e“\u003cspan\u003eroles\u003c/span\u003e”\u003c/span\u003e, this command is now equivalent to \u003ccode\u003e\\du\u003c/code\u003e.) By default, only user-created roles are shown; supply the \u003ccode\u003eS\u003c/code\u003e modifier to include system roles. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those roles whose names match the pattern are listed. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, additional information is shown about each role; currently this adds the comment for each role.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DL-LC\"\u003e\u003cspan\u003e\u003ccode\u003e\\dl[x+]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis is an alias for \u003ccode\u003e\\lo_list\u003c/code\u003e, which shows a list of large objects. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, each large object is listed with its associated permissions, if any.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DL-UC\"\u003e\u003cspan\u003e\u003ccode\u003e\\dL[Sx+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists procedural languages. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only languages whose names match the pattern are listed. By default, only user-created languages are shown; supply the \u003ccode\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, each language is listed with its call handler, validator, access privileges, and whether it is a system object.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DN\"\u003e\u003cspan\u003e\u003ccode\u003e\\dn[Sx+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists schemas (namespaces). If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only schemas whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the \u003ccode\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, each object is listed with its associated permissions and description, if any.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DO-LC\"\u003e\u003cspan\u003e\u003ccode\u003e\\do[Sx+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [ \u003cem\u003e\u003ccode\u003earg_pattern\u003c/code\u003e\u003c/em\u003e [ \u003cem\u003e\u003ccode\u003earg_pattern\u003c/code\u003e\u003c/em\u003e ] ] ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists operators with their operand and result types. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only operators whose names match the pattern are listed. If one \u003cem\u003e\u003ccode\u003earg_pattern\u003c/code\u003e\u003c/em\u003e is specified, only prefix operators whose right argument\u0026#39;s type name matches that pattern are listed. If two \u003cem\u003e\u003ccode\u003earg_pattern\u003c/code\u003e\u003c/em\u003es are specified, only binary operators whose argument type names match those patterns are listed. (Alternatively, write \u003ccode\u003e-\u003c/code\u003e for the unused argument of a unary operator.) By default, only user-created objects are shown; supply a pattern or the \u003ccode\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DO-UC\"\u003e\u003cspan\u003e\u003ccode\u003e\\dO[Sx+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists collations. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only collations whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the \u003ccode\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e 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\u0026#39;s encoding are shown, so the results may vary in different databases of the same installation.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DP-LC\"\u003e\u003cspan\u003e\u003ccode\u003e\\dp[Sx] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists tables, views and sequences with their associated access privileges. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e 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 \u003ccode\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003cp\u003eThe \u003ca href=\"/docs/18/sql-grant.html\" title=\"GRANT\" rel=\"nofollow\"\u003e\u003ccode\u003eGRANT\u003c/code\u003e\u003c/a\u003e and \u003ca href=\"/docs/18/sql-revoke.html\" title=\"REVOKE\" rel=\"nofollow\"\u003e\u003ccode\u003eREVOKE\u003c/code\u003e\u003c/a\u003e commands are used to set access privileges. The meaning of the privilege display is explained in \u003ca href=\"/docs/18/ddl-priv.html\" rel=\"nofollow\"\u003eSection 5.8\u003c/a\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DP-UC\"\u003e\u003cspan\u003e\u003ccode\u003e\\dP[itnx+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists partitioned relations. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only entries whose name matches the pattern are listed. The modifiers \u003ccode\u003et\u003c/code\u003e (tables) and \u003ccode\u003ei\u003c/code\u003e (indexes) can be appended to the command, filtering the kind of relations to list. By default, partitioned tables and indexes are listed.\u003c/p\u003e\n\u003cp\u003eIf the modifier \u003ccode\u003en\u003c/code\u003e (\u003cspan\u003e“\u003cspan\u003enested\u003c/span\u003e”\u003c/span\u003e) is used, or a pattern is specified, then non-root partitioned relations are included, and a column is shown displaying the parent of each partitioned relation.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, the sum of the sizes of each relation\u0026#39;s partitions is also displayed, along with the relation\u0026#39;s description. If \u003ccode\u003en\u003c/code\u003e is combined with \u003ccode\u003e+\u003c/code\u003e, two sizes are shown: one including the total size of directly-attached leaf partitions, and another showing the total size of all partitions, including indirectly attached sub-partitions.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DRDS\"\u003e\u003cspan\u003e\u003ccode\u003e\\drds[x] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003erole-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003edatabase-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ] ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists defined configuration settings. These settings can be role-specific, database-specific, or both. \u003cem\u003e\u003ccode\u003erole-pattern\u003c/code\u003e\u003c/em\u003e and \u003cem\u003e\u003ccode\u003edatabase-pattern\u003c/code\u003e\u003c/em\u003e are used to select specific roles and databases to list, respectively. If omitted, or if \u003ccode\u003e*\u003c/code\u003e is specified, all settings are listed, including those not role-specific or database-specific, respectively. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003cp\u003eThe \u003ca href=\"/docs/18/sql-alterrole.html\" title=\"ALTER ROLE\" rel=\"nofollow\"\u003e\u003ccode\u003eALTER ROLE\u003c/code\u003e\u003c/a\u003e and \u003ca href=\"/docs/18/sql-alterdatabase.html\" title=\"ALTER DATABASE\" rel=\"nofollow\"\u003e\u003ccode\u003eALTER DATABASE\u003c/code\u003e\u003c/a\u003e commands are used to define per-role and per-database configuration settings.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DRG\"\u003e\u003cspan\u003e\u003ccode\u003e\\drg[Sx] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists information about each granted role membership, including assigned options (\u003ccode\u003eADMIN\u003c/code\u003e, \u003ccode\u003eINHERIT\u003c/code\u003e and/or \u003ccode\u003eSET\u003c/code\u003e) and grantor. See the \u003ca href=\"/docs/18/sql-grant.html\" title=\"GRANT\" rel=\"nofollow\"\u003e\u003ccode\u003eGRANT\u003c/code\u003e\u003c/a\u003e command for information about role memberships.\u003c/p\u003e\n\u003cp\u003eBy default, only grants to user-created roles are shown; supply the \u003ccode\u003eS\u003c/code\u003e modifier to include system roles. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only grants to those roles whose names match the pattern are listed. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DRP\"\u003e\u003cspan\u003e\u003ccode\u003e\\dRp[x+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists replication publications. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those publications whose names match the pattern are listed. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, the tables and schemas associated with each publication are shown as well.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DRS\"\u003e\u003cspan\u003e\u003ccode\u003e\\dRs[x+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists replication subscriptions. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those subscriptions whose names match the pattern are listed. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, additional properties of the subscriptions are shown.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DT\"\u003e\u003cspan\u003e\u003ccode\u003e\\dT[Sx+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists data types. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only types whose names match the pattern are listed. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, each type is listed with its internal name and size, its allowed values if it is an \u003ccode\u003eenum\u003c/code\u003e type, and its associated permissions. By default, only user-created objects are shown; supply a pattern or the \u003ccode\u003eS\u003c/code\u003e modifier to include system objects.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DU\"\u003e\u003cspan\u003e\u003ccode\u003e\\du[Sx+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists database roles. (Since the concepts of \u003cspan\u003e“\u003cspan\u003eusers\u003c/span\u003e”\u003c/span\u003e and \u003cspan\u003e“\u003cspan\u003egroups\u003c/span\u003e”\u003c/span\u003e have been unified into \u003cspan\u003e“\u003cspan\u003eroles\u003c/span\u003e”\u003c/span\u003e, this command is now equivalent to \u003ccode\u003e\\dg\u003c/code\u003e.) By default, only user-created roles are shown; supply the \u003ccode\u003eS\u003c/code\u003e modifier to include system roles. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those roles whose names match the pattern are listed. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, additional information is shown about each role; currently this adds the comment for each role.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DX-LC\"\u003e\u003cspan\u003e\u003ccode\u003e\\dx[x+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists installed extensions. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those extensions whose names match the pattern are listed. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, all the objects belonging to each matching extension are listed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DX-UC\"\u003e\u003cspan\u003e\u003ccode\u003e\\dX[x] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists extended statistics. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those extended statistics whose names match the pattern are listed. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003cp\u003eThe status of each kind of extended statistics is shown in a column named after its statistic kind (e.g. Ndistinct). \u003ccode\u003edefined\u003c/code\u003e means that it was requested when creating the statistics, and NULL means it wasn\u0026#39;t requested. You can use \u003ccode\u003epg_stats_ext\u003c/code\u003e if you\u0026#39;d like to know whether \u003ca href=\"/docs/18/sql-analyze.html\" title=\"ANALYZE\" rel=\"nofollow\"\u003e\u003ccode\u003eANALYZE\u003c/code\u003e\u003c/a\u003e was run and statistics are available to the planner.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DY\"\u003e\u003cspan\u003e\u003ccode\u003e\\dy[x+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists event triggers. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those event triggers whose names match the pattern are listed. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, each object is listed with its associated description.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-EDIT\"\u003e\u003cspan\u003e\u003ccode\u003e\\e\u003c/code\u003e or \u003ccode\u003e\\edit\u003c/code\u003e \u003ccode\u003e[ \u003cspan\u003e\u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ] [ \u003cspan\u003e\u003cem\u003e\u003ccode\u003eline_number\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e is specified, the file is edited; after the editor exits, the file\u0026#39;s content is copied into the current query buffer. If no \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e 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.\u003c/p\u003e\n\u003cp\u003eIf you edit a file or the previous query, and you quit the editor without modifying the file, the query buffer is cleared. Otherwise, the new contents of the query buffer are re-parsed according to the normal rules of \u003cspan\u003epsql\u003c/span\u003e, treating the whole buffer as a single line. Any complete queries are immediately executed; that is, if the query buffer contains or ends with a semicolon, everything up to that point is executed and removed from the query buffer. Whatever remains in the query buffer is redisplayed. Type semicolon or \u003ccode\u003e\\g\u003c/code\u003e to send it, or \u003ccode\u003e\\r\u003c/code\u003e to cancel it by clearing the query buffer.\u003c/p\u003e\n\u003cp\u003eTreating the buffer as a single line primarily affects meta-commands: whatever is in the buffer after a meta-command will be taken as argument(s) to the meta-command, even if it spans multiple lines. (Thus you cannot make meta-command-using scripts this way. Use \u003ccode\u003e\\i\u003c/code\u003e for that.)\u003c/p\u003e\n\u003cp\u003eIf a line number is specified, \u003cspan\u003epsql\u003c/span\u003e will position the cursor on the specified line of the file or query buffer. Note that if a single all-digits argument is given, \u003cspan\u003epsql\u003c/span\u003e assumes it is a line number, not a file name.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eTip\u003c/h3\u003e\n\u003cp\u003eSee \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-ENVIRONMENT\" title=\"Environment\" rel=\"nofollow\"\u003eEnvironment\u003c/a\u003e, below, for how to configure and customize your editor.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-ECHO\"\u003e\u003cspan\u003e\u003ccode\u003e\\echo \u003cem\u003e\u003ccode\u003etext\u003c/code\u003e\u003c/em\u003e [ ... ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrints 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:\u003c/p\u003e\n\u003cpre\u003e=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\echo `date`\u003c/code\u003e\u003c/strong\u003e\nTue Oct 26 21:40:57 CEST 1999\n\u003c/pre\u003e\n\u003cp\u003eIf the first argument is an unquoted \u003ccode\u003e-n\u003c/code\u003e the trailing newline is not written (nor is the first argument).\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eTip\u003c/h3\u003e\n\u003cp\u003eIf you use the \u003ccode\u003e\\o\u003c/code\u003e command to redirect your query output you might wish to use \u003ccode\u003e\\qecho\u003c/code\u003e instead of this command. See also \u003ccode\u003e\\warn\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-EF\"\u003e\u003cspan\u003e\u003ccode\u003e\\ef [ \u003cspan\u003e\u003cem\u003e\u003ccode\u003efunction_description\u003c/code\u003e\u003c/em\u003e [ \u003cspan\u003e\u003cem\u003e\u003ccode\u003eline_number\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ]\u003c/span\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command fetches and edits the definition of the named function or procedure, in the form of a \u003ccode\u003eCREATE OR REPLACE FUNCTION\u003c/code\u003e or \u003ccode\u003eCREATE OR REPLACE PROCEDURE\u003c/code\u003e command. Editing is done in the same way as for \u003ccode\u003e\\edit\u003c/code\u003e. 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 \u003ccode\u003e\\g\u003c/code\u003e to send it, or \u003ccode\u003e\\r\u003c/code\u003e to cancel.\u003c/p\u003e\n\u003cp\u003eThe target function can be specified by name alone, or by name and arguments, for example \u003ccode\u003efoo(integer, text)\u003c/code\u003e. The argument types must be given if there is more than one function of the same name.\u003c/p\u003e\n\u003cp\u003eIf no function is specified, a blank \u003ccode\u003eCREATE FUNCTION\u003c/code\u003e template is presented for editing.\u003c/p\u003e\n\u003cp\u003eIf a line number is specified, \u003cspan\u003epsql\u003c/span\u003e will position the cursor on the specified line of the function body. (Note that the function body typically does not begin on the first line of the file.)\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument(s) of \u003ccode\u003e\\ef\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eTip\u003c/h3\u003e\n\u003cp\u003eSee \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-ENVIRONMENT\" title=\"Environment\" rel=\"nofollow\"\u003eEnvironment\u003c/a\u003e, below, for how to configure and customize your editor.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-ENCODING\"\u003e\u003cspan\u003e\u003ccode\u003e\\encoding [ \u003cem\u003e\u003ccode\u003eencoding\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the client character set encoding. Without an argument, this command shows the current encoding.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-ERRVERBOSE\"\u003e\u003cspan\u003e\u003ccode\u003e\\errverbose\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRepeats the most recent server error message at maximum verbosity, as though \u003ccode\u003eVERBOSITY\u003c/code\u003e were set to \u003ccode\u003everbose\u003c/code\u003e and \u003ccode\u003eSHOW_CONTEXT\u003c/code\u003e were set to \u003ccode\u003ealways\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-EV\"\u003e\u003cspan\u003e\u003ccode\u003e\\ev [ \u003cspan\u003e\u003cem\u003e\u003ccode\u003eview_name\u003c/code\u003e\u003c/em\u003e [ \u003cspan\u003e\u003cem\u003e\u003ccode\u003eline_number\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ]\u003c/span\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command fetches and edits the definition of the named view, in the form of a \u003ccode\u003eCREATE OR REPLACE VIEW\u003c/code\u003e command. Editing is done in the same way as for \u003ccode\u003e\\edit\u003c/code\u003e. 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 \u003ccode\u003e\\g\u003c/code\u003e to send it, or \u003ccode\u003e\\r\u003c/code\u003e to cancel.\u003c/p\u003e\n\u003cp\u003eIf no view is specified, a blank \u003ccode\u003eCREATE VIEW\u003c/code\u003e template is presented for editing.\u003c/p\u003e\n\u003cp\u003eIf a line number is specified, \u003cspan\u003epsql\u003c/span\u003e will position the cursor on the specified line of the view definition.\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument(s) of \u003ccode\u003e\\ev\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-F\"\u003e\u003cspan\u003e\u003ccode\u003e\\f [ \u003cem\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the field separator for unaligned query output. The default is the vertical bar (\u003ccode\u003e|\u003c/code\u003e). It is equivalent to \u003ccode\u003e\\pset fieldsep\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-G\"\u003e\u003cspan\u003e\u003ccode\u003e\\g [ (\u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e=\u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [...]) ] [ \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\g [ (\u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e=\u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [...]) ] [ |\u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSends the current query buffer to the server for execution.\u003c/p\u003e\n\u003cp\u003eIf parentheses appear after \u003ccode\u003e\\g\u003c/code\u003e, they surround a space-separated list of \u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e\u003ccode\u003e=\u003c/code\u003e\u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e formatting-option clauses, which are interpreted in the same way as \u003ccode\u003e\\pset\u003c/code\u003e \u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e commands, but take effect only for the duration of this query. In this list, spaces are not allowed around \u003ccode\u003e=\u003c/code\u003e signs, but are required between option clauses. If \u003ccode\u003e=\u003c/code\u003e\u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is omitted, the named \u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e is changed in the same way as for \u003ccode\u003e\\pset\u003c/code\u003e \u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e with no explicit \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eIf a \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e or \u003ccode\u003e|\u003c/code\u003e\u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e argument is given, the query\u0026#39;s output is written to the named file or piped to the given shell command, instead of displaying it as usual. The file or command is written to only if the query successfully returns zero or more tuples, not if the query fails or is a non-data-returning SQL command.\u003c/p\u003e\n\u003cp\u003eIf the current query buffer is empty, the most recently sent query is re-executed instead. Except for that behavior, \u003ccode\u003e\\g\u003c/code\u003e without any arguments is essentially equivalent to a semicolon. With arguments, \u003ccode\u003e\\g\u003c/code\u003e provides a \u003cspan\u003e“\u003cspan\u003eone-shot\u003c/span\u003e”\u003c/span\u003e alternative to the \u003ccode\u003e\\o\u003c/code\u003e command, and additionally allows one-shot adjustments of the output formatting options normally set by \u003ccode\u003e\\pset\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eWhen the last argument begins with \u003ccode\u003e|\u003c/code\u003e, the entire remainder of the line is taken to be the \u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e to execute, and neither variable interpolation nor backquote expansion are performed in it. The rest of the line is simply passed literally to the shell.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-GDESC\"\u003e\u003cspan\u003e\u003ccode\u003e\\gdesc\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShows 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.\u003c/p\u003e\n\u003cp\u003eIf the current query buffer is empty, the most recently sent query is described instead.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-GETENV\"\u003e\u003cspan\u003e\u003ccode\u003e\\getenv \u003cem\u003e\u003ccode\u003epsql_var\u003c/code\u003e\u003c/em\u003e \u003cem\u003e\u003ccode\u003eenv_var\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eGets the value of the environment variable \u003cem\u003e\u003ccode\u003eenv_var\u003c/code\u003e\u003c/em\u003e and assigns it to the \u003cspan\u003epsql\u003c/span\u003e variable \u003cem\u003e\u003ccode\u003epsql_var\u003c/code\u003e\u003c/em\u003e. If \u003cem\u003e\u003ccode\u003eenv_var\u003c/code\u003e\u003c/em\u003e is not defined in the \u003cspan\u003epsql\u003c/span\u003e process\u0026#39;s environment, \u003cem\u003e\u003ccode\u003epsql_var\u003c/code\u003e\u003c/em\u003e is not changed. Example:\u003c/p\u003e\n\u003cpre\u003e=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\getenv home HOME\u003c/code\u003e\u003c/strong\u003e\n=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\echo :home\u003c/code\u003e\u003c/strong\u003e\n/home/postgres\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-GEXEC\"\u003e\u003cspan\u003e\u003ccode\u003e\\gexec\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSends the current query buffer to the server, then treats each column of each row of the query\u0026#39;s output (if any) as an SQL statement to be executed. For example, to create an index on each column of \u003ccode\u003emy_table\u003c/code\u003e:\u003c/p\u003e\n\u003cpre\u003e=\u0026gt; \u003cstrong\u003e\u003ccode\u003eSELECT format(\u0026#39;create index on my_table(%I)\u0026#39;, attname)\u003c/code\u003e\u003c/strong\u003e\n-\u0026gt; \u003cstrong\u003e\u003ccode\u003eFROM pg_attribute\u003c/code\u003e\u003c/strong\u003e\n-\u0026gt; \u003cstrong\u003e\u003ccode\u003eWHERE attrelid = \u0026#39;my_table\u0026#39;::regclass AND attnum \u0026gt; 0\u003c/code\u003e\u003c/strong\u003e\n-\u0026gt; \u003cstrong\u003e\u003ccode\u003eORDER BY attnum\u003c/code\u003e\u003c/strong\u003e\n-\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\gexec\u003c/code\u003e\u003c/strong\u003e\nCREATE INDEX\nCREATE INDEX\nCREATE INDEX\nCREATE INDEX\n\u003c/pre\u003e\n\u003cp\u003eThe generated queries are executed in the order in which the rows are returned, and left-to-right within each row if there is more than one column. NULL fields are ignored. The generated queries are sent literally to the server for processing, so they cannot be \u003cspan\u003epsql\u003c/span\u003e meta-commands nor contain \u003cspan\u003epsql\u003c/span\u003e variable references. If any individual query fails, execution of the remaining queries continues unless \u003ccode\u003eON_ERROR_STOP\u003c/code\u003e is set. Execution of each query is subject to \u003ccode\u003eECHO\u003c/code\u003e processing. (Setting \u003ccode\u003eECHO\u003c/code\u003e to \u003ccode\u003eall\u003c/code\u003e or \u003ccode\u003equeries\u003c/code\u003e is often advisable when using \u003ccode\u003e\\gexec\u003c/code\u003e.) Query logging, single-step mode, timing, and other query execution features apply to each generated query as well.\u003c/p\u003e\n\u003cp\u003eIf the current query buffer is empty, the most recently sent query is re-executed instead.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-GSET\"\u003e\u003cspan\u003e\u003ccode\u003e\\gset [ \u003cem\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSends the current query buffer to the server and stores the query\u0026#39;s output into \u003cspan\u003epsql\u003c/span\u003e variables (see \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-VARIABLES\" title=\"Variables\" rel=\"nofollow\"\u003eVariables\u003c/a\u003e 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:\u003c/p\u003e\n\u003cpre\u003e=\u0026gt; \u003cstrong\u003e\u003ccode\u003eSELECT \u0026#39;hello\u0026#39; AS var1, 10 AS var2\u003c/code\u003e\u003c/strong\u003e\n-\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\gset\u003c/code\u003e\u003c/strong\u003e\n=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\echo :var1 :var2\u003c/code\u003e\u003c/strong\u003e\nhello 10\n\u003c/pre\u003e\n\u003cp\u003eIf you specify a \u003cem\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e, that string is prepended to the query\u0026#39;s column names to create the variable names to use:\u003c/p\u003e\n\u003cpre\u003e=\u0026gt; \u003cstrong\u003e\u003ccode\u003eSELECT \u0026#39;hello\u0026#39; AS var1, 10 AS var2\u003c/code\u003e\u003c/strong\u003e\n-\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\gset result_\u003c/code\u003e\u003c/strong\u003e\n=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\echo :result_var1 :result_var2\u003c/code\u003e\u003c/strong\u003e\nhello 10\n\u003c/pre\u003e\n\u003cp\u003eIf a column result is NULL, the corresponding variable is unset rather than being set.\u003c/p\u003e\n\u003cp\u003eIf the query fails or does not return one row, no variables are changed.\u003c/p\u003e\n\u003cp\u003eIf the current query buffer is empty, the most recently sent query is re-executed instead.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-GX\"\u003e\u003cspan\u003e\u003ccode\u003e\\gx [ (\u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e=\u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [...]) ] [ \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\gx [ (\u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e=\u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [...]) ] [ |\u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003e\u003ccode\u003e\\gx\u003c/code\u003e is equivalent to \u003ccode\u003e\\g\u003c/code\u003e, except that it forces expanded output mode for this query, as if \u003ccode\u003eexpanded=on\u003c/code\u003e were included in the list of \u003ccode\u003e\\pset\u003c/code\u003e options. See also \u003ccode\u003e\\x\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-HELP\"\u003e\u003cspan\u003e\u003ccode\u003e\\h\u003c/code\u003e or \u003ccode\u003e\\help\u003c/code\u003e \u003ccode\u003e[ \u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eGives syntax help on the specified SQL command. If \u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e is not specified, then \u003cspan\u003epsql\u003c/span\u003e will list all the commands for which syntax help is available. If \u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e is an asterisk (\u003ccode\u003e*\u003c/code\u003e), then syntax help on all SQL commands is shown.\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument(s) of \u003ccode\u003e\\help\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003eTo simplify typing, commands that consists of several words do not have to be quoted. Thus it is fine to type \u003cstrong\u003e\u003ccode\u003e\\help alter table\u003c/code\u003e\u003c/strong\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-HTML\"\u003e\u003cspan\u003e\u003ccode\u003e\\H\u003c/code\u003e or \u003ccode\u003e\\html\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eTurns 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 \u003ccode\u003e\\pset\u003c/code\u003e about setting other output options.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-INCLUDE\"\u003e\u003cspan\u003e\u003ccode\u003e\\i\u003c/code\u003e or \u003ccode\u003e\\include\u003c/code\u003e \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eReads input from the file \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e and executes it as though it had been typed on the keyboard.\u003c/p\u003e\n\u003cp\u003eIf \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e is \u003ccode\u003e-\u003c/code\u003e (hyphen), then standard input is read until an EOF indication or \u003ccode\u003e\\q\u003c/code\u003e meta-command. This can be used to intersperse interactive input with input from files. Note that Readline behavior will be used only if it is active at the outermost level.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003eIf you want to see the lines on the screen as they are read you must set the variable \u003ccode\u003eECHO\u003c/code\u003e to \u003ccode\u003eall\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PSQL-METACOMMAND-IF\"\u003e\u003cspan\u003e\u003ccode\u003e\\if\u003c/code\u003e \u003cem\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\elif\u003c/code\u003e \u003cem\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\else\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\endif\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis group of commands implements nestable conditional blocks. A conditional block must begin with an \u003ccode\u003e\\if\u003c/code\u003e and end with an \u003ccode\u003e\\endif\u003c/code\u003e. In between there may be any number of \u003ccode\u003e\\elif\u003c/code\u003e clauses, which may optionally be followed by a single \u003ccode\u003e\\else\u003c/code\u003e clause. Ordinary queries and other types of backslash commands may (and usually do) appear between the commands forming a conditional block.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode\u003e\\if\u003c/code\u003e and \u003ccode\u003e\\elif\u003c/code\u003e commands read their argument(s) and evaluate them as a Boolean expression. If the expression yields \u003ccode\u003etrue\u003c/code\u003e then processing continues normally; otherwise, lines are skipped until a matching \u003ccode\u003e\\elif\u003c/code\u003e, \u003ccode\u003e\\else\u003c/code\u003e, or \u003ccode\u003e\\endif\u003c/code\u003e is reached. Once an \u003ccode\u003e\\if\u003c/code\u003e or \u003ccode\u003e\\elif\u003c/code\u003e test has succeeded, the arguments of later \u003ccode\u003e\\elif\u003c/code\u003e commands in the same block are not evaluated but are treated as false. Lines following an \u003ccode\u003e\\else\u003c/code\u003e are processed only if no earlier matching \u003ccode\u003e\\if\u003c/code\u003e or \u003ccode\u003e\\elif\u003c/code\u003e succeeded.\u003c/p\u003e\n\u003cp\u003eThe \u003cem\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e argument of an \u003ccode\u003e\\if\u003c/code\u003e or \u003ccode\u003e\\elif\u003c/code\u003e command is subject to variable interpolation and backquote expansion, just like any other backslash command argument. After that it is evaluated like the value of an on/off option variable. So a valid value is any unambiguous case-insensitive match for one of: \u003ccode\u003etrue\u003c/code\u003e, \u003ccode\u003efalse\u003c/code\u003e, \u003ccode\u003e1\u003c/code\u003e, \u003ccode\u003e0\u003c/code\u003e, \u003ccode\u003eon\u003c/code\u003e, \u003ccode\u003eoff\u003c/code\u003e, \u003ccode\u003eyes\u003c/code\u003e, \u003ccode\u003eno\u003c/code\u003e. For example, \u003ccode\u003et\u003c/code\u003e, \u003ccode\u003eT\u003c/code\u003e, and \u003ccode\u003etR\u003c/code\u003e will all be considered to be \u003ccode\u003etrue\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eExpressions that do not properly evaluate to true or false will generate a warning and be treated as false.\u003c/p\u003e\n\u003cp\u003eLines being skipped are parsed normally to identify queries and backslash commands, but queries are not sent to the server, and backslash commands other than conditionals (\u003ccode\u003e\\if\u003c/code\u003e, \u003ccode\u003e\\elif\u003c/code\u003e, \u003ccode\u003e\\else\u003c/code\u003e, \u003ccode\u003e\\endif\u003c/code\u003e) are ignored. Conditional commands are checked only for valid nesting. Variable references in skipped lines are not expanded, and backquote expansion is not performed either.\u003c/p\u003e\n\u003cp\u003eAll the backslash commands of a given conditional block must appear in the same source file. If EOF is reached on the main input file or an \u003ccode\u003e\\include\u003c/code\u003e-ed file before all local \u003ccode\u003e\\if\u003c/code\u003e-blocks have been closed, then \u003cspan\u003epsql\u003c/span\u003e will raise an error.\u003c/p\u003e\n\u003cp\u003eHere is an example:\u003c/p\u003e\n\u003cpre\u003e-- check for the existence of two separate records in the database and store\n-- the results in separate psql variables\nSELECT\n    EXISTS(SELECT 1 FROM customer WHERE customer_id = 123) as is_customer,\n    EXISTS(SELECT 1 FROM employee WHERE employee_id = 456) as is_employee\n\\gset\n\\if :is_customer\n    SELECT * FROM customer WHERE customer_id = 123;\n\\elif :is_employee\n    \\echo \u0026#39;is not a customer but is an employee\u0026#39;\n    SELECT * FROM employee WHERE employee_id = 456;\n\\else\n    \\if yes\n        \\echo \u0026#39;not a customer or employee\u0026#39;\n    \\else\n        \\echo \u0026#39;this will never print\u0026#39;\n    \\endif\n\\endif\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-INCLUDE-RELATIVE\"\u003e\u003cspan\u003e\u003ccode\u003e\\ir\u003c/code\u003e or \u003ccode\u003e\\include_relative\u003c/code\u003e \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe \u003ccode\u003e\\ir\u003c/code\u003e command is similar to \u003ccode\u003e\\i\u003c/code\u003e, but resolves relative file names differently. When executing in interactive mode, the two commands behave identically. However, when invoked from a script, \u003ccode\u003e\\ir\u003c/code\u003e interprets file names relative to the directory in which the script is located, rather than the current working directory.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-LIST\"\u003e\u003cspan\u003e\u003ccode\u003e\\l[x+]\u003c/code\u003e or \u003ccode\u003e\\list[x+] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eList the databases in the server and show their names, owners, character set encodings, and access privileges. If \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only databases whose names match the pattern are listed. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e 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 \u003ccode\u003eCONNECT\u003c/code\u003e privilege, or if the current user is a superuser or has privileges of the \u003ccode\u003epg_read_all_stats\u003c/code\u003e role.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-LO-EXPORT\"\u003e\u003cspan\u003e\u003ccode\u003e\\lo_export \u003cem\u003e\u003ccode\u003eloid\u003c/code\u003e\u003c/em\u003e \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eReads the large object with OID \u003cem\u003e\u003ccode\u003eloid\u003c/code\u003e\u003c/em\u003e from the database and writes it to \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e. Note that this is subtly different from the server function \u003ccode\u003elo_export\u003c/code\u003e, which acts with the permissions of the user that the database server runs as and on the server\u0026#39;s file system.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eTip\u003c/h3\u003e\n\u003cp\u003eUse \u003ccode\u003e\\lo_list\u003c/code\u003e to find out the large object\u0026#39;s OID.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-LO-IMPORT\"\u003e\u003cspan\u003e\u003ccode\u003e\\lo_import \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e [ \u003cem\u003e\u003ccode\u003ecomment\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eStores the file into a \u003cspan\u003ePostgreSQL\u003c/span\u003e large object. Optionally, it associates the given comment with the object. Example:\u003c/p\u003e\n\u003cpre\u003efoo=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\lo_import \u0026#39;/home/peter/pictures/photo.xcf\u0026#39; \u0026#39;a picture of me\u0026#39;\u003c/code\u003e\u003c/strong\u003e\nlo_import 152801\n\u003c/pre\u003e\n\u003cp\u003eThe response indicates that the large object received object ID 152801, which can be used to access the newly-created large object in the future. For the sake of readability, it is recommended to always associate a human-readable comment with every object. Both OIDs and comments can be viewed with the \u003ccode\u003e\\lo_list\u003c/code\u003e command.\u003c/p\u003e\n\u003cp\u003eNote that this command is subtly different from the server-side \u003ccode\u003elo_import\u003c/code\u003e because it acts as the local user on the local file system, rather than the server\u0026#39;s user and file system.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-LO-LIST\"\u003e\u003cspan\u003e\u003ccode\u003e\\lo_list[x+]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShows a list of all \u003cspan\u003ePostgreSQL\u003c/span\u003e large objects currently stored in the database, along with any comments provided for them. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode\u003e+\u003c/code\u003e is appended to the command name, each large object is listed with its associated permissions, if any.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-LO-UNLINK\"\u003e\u003cspan\u003e\u003ccode\u003e\\lo_unlink \u003cem\u003e\u003ccode\u003eloid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDeletes the large object with OID \u003cem\u003e\u003ccode\u003eloid\u003c/code\u003e\u003c/em\u003e from the database.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eTip\u003c/h3\u003e\n\u003cp\u003eUse \u003ccode\u003e\\lo_list\u003c/code\u003e to find out the large object\u0026#39;s OID.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-OUT\"\u003e\u003cspan\u003e\u003ccode\u003e\\o\u003c/code\u003e or \u003ccode\u003e\\out [ \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\o\u003c/code\u003e or \u003ccode\u003e\\out [ |\u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eArranges to save future query results to the file \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e or pipe future results to the shell command \u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e. If no argument is specified, the query output is reset to the standard output.\u003c/p\u003e\n\u003cp\u003eIf the argument begins with \u003ccode\u003e|\u003c/code\u003e, then the entire remainder of the line is taken to be the \u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e to execute, and neither variable interpolation nor backquote expansion are performed in it. The rest of the line is simply passed literally to the shell.\u003c/p\u003e\n\u003cp\u003e\u003cspan\u003e“\u003cspan\u003eQuery results\u003c/span\u003e”\u003c/span\u003e includes all tables, command responses, and notices obtained from the database server, as well as output of various backslash commands that query the database (such as \u003ccode\u003e\\d\u003c/code\u003e); but not error messages.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eTip\u003c/h3\u003e\n\u003cp\u003eTo intersperse text output in between query results, use \u003ccode\u003e\\qecho\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PRINT\"\u003e\u003cspan\u003e\u003ccode\u003e\\p\u003c/code\u003e or \u003ccode\u003e\\print\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint the current query buffer to the standard output. If the current query buffer is empty, the most recently executed query is printed instead.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PARSE\"\u003e\u003cspan\u003e\u003ccode\u003e\\parse \u003cem\u003e\u003ccode\u003estatement_name\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreates 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.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre\u003eSELECT $1 \\parse stmt1\n\u003c/pre\u003e\n\u003cp\u003eThis command causes the extended query protocol to be used, unlike normal \u003cspan\u003epsql\u003c/span\u003e operation, which uses the simple query protocol. A \u003ca href=\"/docs/18/protocol-message-formats.html#PROTOCOL-MESSAGE-FORMATS-PARSE\" rel=\"nofollow\"\u003eParse (F)\u003c/a\u003e message will be issued by this command so it can be useful to test the extended query protocol from \u003cspan\u003epsql\u003c/span\u003e. This command affects only the next query executed; all subsequent queries will use the simple query protocol by default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PASSWORD\"\u003e\u003cspan\u003e\u003ccode\u003e\\password [ \u003cem\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eChanges 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 \u003ccode\u003eALTER ROLE\u003c/code\u003e command. This makes sure that the new password does not appear in cleartext in the command history, the server log, or elsewhere.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PROMPT\"\u003e\u003cspan\u003e\u003ccode\u003e\\prompt [ \u003cem\u003e\u003ccode\u003etext\u003c/code\u003e\u003c/em\u003e ] \u003cem\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrompts the user to supply text, which is assigned to the variable \u003cem\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e. An optional prompt string, \u003cem\u003e\u003ccode\u003etext\u003c/code\u003e\u003c/em\u003e, can be specified. (For multiword prompts, surround the text with single quotes.)\u003c/p\u003e\n\u003cp\u003eBy default, \u003ccode\u003e\\prompt\u003c/code\u003e uses the terminal for input and output. However, if the \u003ccode\u003e-f\u003c/code\u003e command line switch was used, \u003ccode\u003e\\prompt\u003c/code\u003e uses standard input and standard output.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET\"\u003e\u003cspan\u003e\u003ccode\u003e\\pset [ \u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e [ \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e ] ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command sets options affecting the output of query result tables. \u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e indicates which option is to be set. The semantics of \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e vary depending on the selected option. For some options, omitting \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e causes the option to be toggled or unset, as described under the particular option. If no such behavior is mentioned, then omitting \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e just results in the current setting being displayed.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e\\pset\u003c/code\u003e without any arguments displays the current status of all printing options.\u003c/p\u003e\n\u003cp\u003eAdjustable printing options are:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-BORDER\"\u003e\u003cspan\u003e\u003ccode\u003eborder\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e must be a number. In general, the higher the number the more borders and lines the tables will have, but details depend on the particular format. In HTML format, this will translate directly into the \u003ccode\u003eborder=...\u003c/code\u003e attribute. In most other formats only values 0 (no border), 1 (internal dividing lines), and 2 (table frame) make sense, and values above 2 will be treated the same as \u003ccode\u003eborder = 2\u003c/code\u003e. The \u003ccode\u003elatex\u003c/code\u003e and \u003ccode\u003elatex-longtable\u003c/code\u003e formats additionally allow a value of 3 to add dividing lines between data rows.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-COLUMNS\"\u003e\u003cspan\u003e\u003ccode\u003ecolumns\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the target width for the \u003ccode\u003ewrapped\u003c/code\u003e format, and also the width limit for determining whether output is wide enough to require the pager or switch to the vertical display in expanded auto mode. Zero (the default) causes the target width to be controlled by the environment variable \u003ccode\u003eCOLUMNS\u003c/code\u003e, or the detected screen width if \u003ccode\u003eCOLUMNS\u003c/code\u003e is not set. In addition, if \u003ccode\u003ecolumns\u003c/code\u003e is zero then the \u003ccode\u003ewrapped\u003c/code\u003e format only affects screen output. If \u003ccode\u003ecolumns\u003c/code\u003e is nonzero then file and pipe output is wrapped to that width as well.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-CSV-FIELDSEP\"\u003e\u003cspan\u003e\u003ccode\u003ecsv_fieldsep\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the field separator to be used in CSV output format. If the separator character appears in a field\u0026#39;s value, that field is output within double quotes, following standard CSV rules. The default is a comma.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-EXPANDED\"\u003e\u003cspan\u003e\u003ccode\u003eexpanded\u003c/code\u003e (or \u003ccode\u003ex\u003c/code\u003e)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is specified it must be either \u003ccode\u003eon\u003c/code\u003e or \u003ccode\u003eoff\u003c/code\u003e, which will enable or disable expanded mode, or \u003ccode\u003eauto\u003c/code\u003e. If \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is omitted the command toggles between the on and off settings. When expanded mode 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\u0026#39;t fit on the screen in the normal \u003cspan\u003e“\u003cspan\u003ehorizontal\u003c/span\u003e”\u003c/span\u003e mode. In the auto setting, the expanded mode is used whenever the query output has more than one column and is wider than the screen; otherwise, the regular mode is used. The auto setting is only effective in the aligned and wrapped formats. In other formats, it always behaves as if the expanded mode is off.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-FIELDSEP\"\u003e\u003cspan\u003e\u003ccode\u003efieldsep\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the field separator to be used in unaligned output format. That way one can create, for example, tab-separated output, which other programs might prefer. To set a tab as field separator, type \u003ccode\u003e\\pset fieldsep \u0026#39;\\t\u0026#39;\u003c/code\u003e. The default field separator is \u003ccode\u003e\u0026#39;|\u0026#39;\u003c/code\u003e (a vertical bar).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-FIELDSEP-ZERO\"\u003e\u003cspan\u003e\u003ccode\u003efieldsep_zero\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the field separator to use in unaligned output format to a zero byte.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-FOOTER\"\u003e\u003cspan\u003e\u003ccode\u003efooter\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is specified it must be either \u003ccode\u003eon\u003c/code\u003e or \u003ccode\u003eoff\u003c/code\u003e which will enable or disable display of the table footer (the \u003ccode\u003e(\u003cem\u003e\u003ccode\u003en\u003c/code\u003e\u003c/em\u003e rows)\u003c/code\u003e count). If \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is omitted the command toggles footer display on or off.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-FORMAT\"\u003e\u003cspan\u003e\u003ccode\u003eformat\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the output format to one of \u003ccode\u003ealigned\u003c/code\u003e, \u003ccode\u003easciidoc\u003c/code\u003e, \u003ccode\u003ecsv\u003c/code\u003e, \u003ccode\u003ehtml\u003c/code\u003e, \u003ccode\u003elatex\u003c/code\u003e, \u003ccode\u003elatex-longtable\u003c/code\u003e, \u003ccode\u003etroff-ms\u003c/code\u003e, \u003ccode\u003eunaligned\u003c/code\u003e, or \u003ccode\u003ewrapped\u003c/code\u003e. Unique abbreviations are allowed.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003ealigned\u003c/code\u003e format is the standard, human-readable, nicely formatted text output; this is the default.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003eunaligned\u003c/code\u003e format writes all columns of a row on one line, separated by the currently active field separator. This is useful for creating output that might be intended to be read in by other programs, for example, tab-separated or comma-separated format. However, the field separator character is not treated specially if it appears in a column\u0026#39;s value; so CSV format may be better suited for such purposes.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003ecsv\u003c/code\u003e format  writes column values separated by commas, applying the quoting rules described in \u003ca href=\"https://datatracker.ietf.org/doc/html/rfc4180\" rel=\"nofollow\"\u003eRFC 4180\u003c/a\u003e. This output is compatible with the CSV format of the server\u0026#39;s \u003ccode\u003eCOPY\u003c/code\u003e command. A header line with column names is generated unless the \u003ccode\u003etuples_only\u003c/code\u003e parameter is \u003ccode\u003eon\u003c/code\u003e. Titles and footers are not printed. Each row is terminated by the system-dependent end-of-line character, which is typically a single newline (\u003ccode\u003e\\n\u003c/code\u003e) for Unix-like systems or a carriage return and newline sequence (\u003ccode\u003e\\r\\n\u003c/code\u003e) for Microsoft Windows. Field separator characters other than comma can be selected with \u003ccode\u003e\\pset csv_fieldsep\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003ewrapped\u003c/code\u003e format is like \u003ccode\u003ealigned\u003c/code\u003e but wraps wide data values across lines to make the output fit in the target column width. The target width is determined as described under the \u003ccode\u003ecolumns\u003c/code\u003e option. Note that \u003cspan\u003epsql\u003c/span\u003e will not attempt to wrap column header titles; therefore, \u003ccode\u003ewrapped\u003c/code\u003e format behaves the same as \u003ccode\u003ealigned\u003c/code\u003e if the total width needed for column headers exceeds the target.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode\u003easciidoc\u003c/code\u003e, \u003ccode\u003ehtml\u003c/code\u003e, \u003ccode\u003elatex\u003c/code\u003e, \u003ccode\u003elatex-longtable\u003c/code\u003e, and \u003ccode\u003etroff-ms\u003c/code\u003e formats 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 necessary in HTML, but in \u003cspan\u003eLaTeX\u003c/span\u003e you must have a complete document wrapper. The \u003ccode\u003elatex\u003c/code\u003e format uses \u003cspan\u003eLaTeX\u003c/span\u003e\u0026#39;s \u003ccode\u003etabular\u003c/code\u003e environment. The \u003ccode\u003elatex-longtable\u003c/code\u003e format requires the \u003cspan\u003eLaTeX\u003c/span\u003e \u003ccode\u003elongtable\u003c/code\u003e and \u003ccode\u003ebooktabs\u003c/code\u003e packages.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-LINESTYLE\"\u003e\u003cspan\u003e\u003ccode\u003elinestyle\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the border line drawing style to one of \u003ccode\u003eascii\u003c/code\u003e, \u003ccode\u003eold-ascii\u003c/code\u003e, or \u003ccode\u003eunicode\u003c/code\u003e. Unique abbreviations are allowed. (That would mean one letter is enough.) The default setting is \u003ccode\u003eascii\u003c/code\u003e. This option only affects the \u003ccode\u003ealigned\u003c/code\u003e and \u003ccode\u003ewrapped\u003c/code\u003e output formats.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003eascii\u003c/code\u003e style uses plain ASCII characters. Newlines in data are shown using a \u003ccode\u003e+\u003c/code\u003e symbol in the right-hand margin. When the \u003ccode\u003ewrapped\u003c/code\u003e format wraps data from one line to the next without a newline character, a dot (\u003ccode\u003e.\u003c/code\u003e) is shown in the right-hand margin of the first line, and again in the left-hand margin of the following line.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003eold-ascii\u003c/code\u003e style uses plain ASCII characters, using the formatting style used in \u003cspan\u003ePostgreSQL\u003c/span\u003e 8.4 and earlier. Newlines in data are shown using a \u003ccode\u003e:\u003c/code\u003e symbol in place of the left-hand column separator. When the data is wrapped from one line to the next without a newline character, a \u003ccode\u003e;\u003c/code\u003e symbol is used in place of the left-hand column separator.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003eunicode\u003c/code\u003e style uses Unicode box-drawing characters. Newlines in data are shown using a carriage return symbol in the right-hand margin. When the data is wrapped from one line to the next without a newline character, an ellipsis symbol is shown in the right-hand margin of the first line, and again in the left-hand margin of the following line.\u003c/p\u003e\n\u003cp\u003eWhen the \u003ccode\u003eborder\u003c/code\u003e setting is greater than zero, the \u003ccode\u003elinestyle\u003c/code\u003e option also determines the characters with which the border lines are drawn. Plain ASCII characters work everywhere, but Unicode characters look nicer on displays that recognize them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-NULL\"\u003e\u003cspan\u003e\u003ccode\u003enull\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the string to be printed in place of a null value. The default is to print nothing, which can easily be mistaken for an empty string. For example, one might prefer \u003ccode\u003e\\pset null \u0026#39;(null)\u0026#39;\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-NUMERICLOCALE\"\u003e\u003cspan\u003e\u003ccode\u003enumericlocale\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is specified it must be either \u003ccode\u003eon\u003c/code\u003e or \u003ccode\u003eoff\u003c/code\u003e which will enable or disable display of a locale-specific character to separate groups of digits to the left of the decimal marker. If \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is omitted the command toggles between regular and locale-specific numeric output.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-PAGER\"\u003e\u003cspan\u003e\u003ccode\u003epager\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eControls use of a pager program for query and \u003cspan\u003epsql\u003c/span\u003e help output. When the \u003ccode\u003epager\u003c/code\u003e option is \u003ccode\u003eoff\u003c/code\u003e, the pager program is not used. When the \u003ccode\u003epager\u003c/code\u003e option is \u003ccode\u003eon\u003c/code\u003e, the pager is used when appropriate, i.e., when the output is to a terminal and will not fit on the screen. The \u003ccode\u003epager\u003c/code\u003e option can also be set to \u003ccode\u003ealways\u003c/code\u003e, which causes the pager to be used for all terminal output regardless of whether it fits on the screen. \u003ccode\u003e\\pset pager\u003c/code\u003e without a \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e toggles pager use on and off.\u003c/p\u003e\n\u003cp\u003eIf the environment variable \u003ccode\u003ePSQL_PAGER\u003c/code\u003e or \u003ccode\u003ePAGER\u003c/code\u003e is set, output to be paged is piped to the specified program. Otherwise a platform-dependent default program (such as \u003ccode\u003emore\u003c/code\u003e) is used.\u003c/p\u003e\n\u003cp\u003eWhen using the \u003ccode\u003e\\watch\u003c/code\u003e command to execute a query repeatedly, the environment variable \u003ccode\u003ePSQL_WATCH_PAGER\u003c/code\u003e is used to find the pager program instead, on Unix systems. This is configured separately because it may confuse traditional pagers, but can be used to send output to tools that understand \u003cspan\u003epsql\u003c/span\u003e\u0026#39;s output format (such as \u003ccode\u003epspg --stream\u003c/code\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-PAGER-MIN-LINES\"\u003e\u003cspan\u003e\u003ccode\u003epager_min_lines\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003ccode\u003epager_min_lines\u003c/code\u003e is set to a number greater than the page height, the pager program will not be called unless there are at least this many lines of output to show. The default setting is 0.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-RECORDSEP\"\u003e\u003cspan\u003e\u003ccode\u003erecordsep\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the record (line) separator to use in unaligned output format. The default is a newline character.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-RECORDSEP-ZERO\"\u003e\u003cspan\u003e\u003ccode\u003erecordsep_zero\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the record separator to use in unaligned output format to a zero byte.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-TABLEATTR\"\u003e\u003cspan\u003e\u003ccode\u003etableattr\u003c/code\u003e (or \u003ccode\u003eT\u003c/code\u003e)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIn HTML format, this specifies attributes to be placed inside the \u003ccode\u003etable\u003c/code\u003e tag. This could for example be \u003ccode\u003ecellpadding\u003c/code\u003e or \u003ccode\u003ebgcolor\u003c/code\u003e. Note that you probably don\u0026#39;t want to specify \u003ccode\u003eborder\u003c/code\u003e here, as that is already taken care of by \u003ccode\u003e\\pset border\u003c/code\u003e. If no \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is given, the table attributes are unset.\u003c/p\u003e\n\u003cp\u003eIn \u003ccode\u003elatex-longtable\u003c/code\u003e format, this controls the proportional width of each column containing a left-aligned data type. It is specified as a whitespace-separated list of values, e.g., \u003ccode\u003e\u0026#39;0.2 0.2 0.6\u0026#39;\u003c/code\u003e. Unspecified output columns use the last specified value.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-TITLE\"\u003e\u003cspan\u003e\u003ccode\u003etitle\u003c/code\u003e (or \u003ccode\u003eC\u003c/code\u003e)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the table title for any subsequently printed tables. This can be used to give your output descriptive tags. If no \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is given, the title is unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-TUPLES-ONLY\"\u003e\u003cspan\u003e\u003ccode\u003etuples_only\u003c/code\u003e (or \u003ccode\u003et\u003c/code\u003e)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is specified it must be either \u003ccode\u003eon\u003c/code\u003e or \u003ccode\u003eoff\u003c/code\u003e which will enable or disable tuples-only mode. If \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is omitted the command toggles between regular and tuples-only output. Regular output includes extra information such as column headers, titles, and various footers. In tuples-only mode, only actual table data is shown.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-UNICODE-BORDER-LINESTYLE\"\u003e\u003cspan\u003e\u003ccode\u003eunicode_border_linestyle\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the border drawing style for the \u003ccode\u003eunicode\u003c/code\u003e line style to one of \u003ccode\u003esingle\u003c/code\u003e or \u003ccode\u003edouble\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-UNICODE-COLUMN-LINESTYLE\"\u003e\u003cspan\u003e\u003ccode\u003eunicode_column_linestyle\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the column drawing style for the \u003ccode\u003eunicode\u003c/code\u003e line style to one of \u003ccode\u003esingle\u003c/code\u003e or \u003ccode\u003edouble\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-UNICODE-HEADER-LINESTYLE\"\u003e\u003cspan\u003e\u003ccode\u003eunicode_header_linestyle\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the header drawing style for the \u003ccode\u003eunicode\u003c/code\u003e line style to one of \u003ccode\u003esingle\u003c/code\u003e or \u003ccode\u003edouble\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-XHEADER-WIDTH\"\u003e\u003cspan\u003e\u003ccode\u003exheader_width\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the maximum width of the header for expanded output to one of \u003ccode\u003efull\u003c/code\u003e (the default value), \u003ccode\u003ecolumn\u003c/code\u003e, \u003ccode\u003epage\u003c/code\u003e, or an \u003cem\u003e\u003ccode\u003einteger value\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003efull\u003c/code\u003e: the expanded header is not truncated, and will be as wide as the widest output line.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003ecolumn\u003c/code\u003e: truncate the header line to the width of the first column.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003epage\u003c/code\u003e: truncate the header line to the terminal width.\u003c/p\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003einteger value\u003c/code\u003e\u003c/em\u003e: specify the exact maximum width of the header line.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eIllustrations of how these different formats look can be seen in \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-EXAMPLES\" title=\"Examples\" rel=\"nofollow\"\u003eExamples\u003c/a\u003e, below.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eTip\u003c/h3\u003e\n\u003cp\u003eThere are various shortcut commands for \u003ccode\u003e\\pset\u003c/code\u003e. See \u003ccode\u003e\\a\u003c/code\u003e, \u003ccode\u003e\\C\u003c/code\u003e, \u003ccode\u003e\\f\u003c/code\u003e, \u003ccode\u003e\\H\u003c/code\u003e, \u003ccode\u003e\\t\u003c/code\u003e, \u003ccode\u003e\\T\u003c/code\u003e, and \u003ccode\u003e\\x\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-QUIT\"\u003e\u003cspan\u003e\u003ccode\u003e\\q\u003c/code\u003e or \u003ccode\u003e\\quit\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eQuits the \u003cspan\u003epsql\u003c/span\u003e program. In a script file, only execution of that script is terminated.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-QECHO\"\u003e\u003cspan\u003e\u003ccode\u003e\\qecho \u003cem\u003e\u003ccode\u003etext\u003c/code\u003e\u003c/em\u003e [ ... ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command is identical to \u003ccode\u003e\\echo\u003c/code\u003e except that the output will be written to the query output channel, as set by \u003ccode\u003e\\o\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-RESET\"\u003e\u003cspan\u003e\u003ccode\u003e\\r\u003c/code\u003e or \u003ccode\u003e\\reset\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eResets (clears) the query buffer.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-RESTRICT\"\u003e\u003cspan\u003e\u003ccode\u003e\\restrict \u003cem\u003e\u003ccode\u003erestrict_key\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnter \u0026#34;restricted\u0026#34; mode with the provided key. In this mode, the only allowed meta-command is \u003ccode\u003e\\unrestrict\u003c/code\u003e, to exit restricted mode. The key may contain only alphanumeric characters.\u003c/p\u003e\n\u003cp\u003eThis command is primarily intended for use in plain-text dumps generated by \u003cspan\u003epg_dump\u003c/span\u003e, \u003cspan\u003epg_dumpall\u003c/span\u003e, and \u003cspan\u003epg_restore\u003c/span\u003e, but it may be useful elsewhere.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-S\"\u003e\u003cspan\u003e\u003ccode\u003e\\s [ \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint \u003cspan\u003epsql\u003c/span\u003e\u0026#39;s command line history to \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e. If \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e is omitted, the history is written to the standard output (using the pager if appropriate). This command is not available if \u003cspan\u003epsql\u003c/span\u003e was built without \u003cspan\u003eReadline\u003c/span\u003e support.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-SET\"\u003e\u003cspan\u003e\u003ccode\u003e\\set [ \u003cem\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e [ \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [ ... ] ] ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the \u003cspan\u003epsql\u003c/span\u003e variable \u003cem\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e to \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e, 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 \u003ccode\u003e\\unset\u003c/code\u003e command.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e\\set\u003c/code\u003e without any arguments displays the names and values of all currently-set \u003cspan\u003epsql\u003c/span\u003e variables.\u003c/p\u003e\n\u003cp\u003eValid variable names can contain letters, digits, and underscores. See \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-VARIABLES\" title=\"Variables\" rel=\"nofollow\"\u003eVariables\u003c/a\u003e below for details. Variable names are case-sensitive.\u003c/p\u003e\n\u003cp\u003eCertain variables are special, in that they control \u003cspan\u003epsql\u003c/span\u003e\u0026#39;s behavior or are automatically set to reflect connection state. These variables are documented in \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-VARIABLES\" title=\"Variables\" rel=\"nofollow\"\u003eVariables\u003c/a\u003e, below.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis command is unrelated to the SQL command \u003ca href=\"/docs/18/sql-set.html\" title=\"SET\" rel=\"nofollow\"\u003e\u003ccode\u003eSET\u003c/code\u003e\u003c/a\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-SETENV\"\u003e\u003cspan\u003e\u003ccode\u003e\\setenv \u003cem\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e [ \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the environment variable \u003cem\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e to \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e, or if the \u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is not supplied, unsets the environment variable. Example:\u003c/p\u003e\n\u003cpre\u003etestdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\setenv PAGER less\u003c/code\u003e\u003c/strong\u003e\ntestdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\setenv LESS -imx4F\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-SF\"\u003e\u003cspan\u003e\u003ccode\u003e\\sf[+] \u003cem\u003e\u003ccode\u003efunction_description\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command fetches and shows the definition of the named function or procedure, in the form of a \u003ccode\u003eCREATE OR REPLACE FUNCTION\u003c/code\u003e or \u003ccode\u003eCREATE OR REPLACE PROCEDURE\u003c/code\u003e command. The definition is printed to the current query output channel, as set by \u003ccode\u003e\\o\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe target function can be specified by name alone, or by name and arguments, for example \u003ccode\u003efoo(integer, text)\u003c/code\u003e. The argument types must be given if there is more than one function of the same name.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode\u003e+\u003c/code\u003e is appended to the command name, then the output lines are numbered, with the first line of the function body being line 1.\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument(s) of \u003ccode\u003e\\sf\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-SV\"\u003e\u003cspan\u003e\u003ccode\u003e\\sv[+] \u003cem\u003e\u003ccode\u003eview_name\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command fetches and shows the definition of the named view, in the form of a \u003ccode\u003eCREATE OR REPLACE VIEW\u003c/code\u003e command. The definition is printed to the current query output channel, as set by \u003ccode\u003e\\o\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode\u003e+\u003c/code\u003e is appended to the command name, then the output lines are numbered from 1.\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument(s) of \u003ccode\u003e\\sv\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PIPELINE\"\u003e\u003cspan\u003e\u003ccode\u003e\\startpipeline\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\sendpipeline\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\syncpipeline\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\endpipeline\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\flushrequest\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\flush\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\getresults [ \u003cem\u003e\u003ccode\u003enumber_results\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis group of commands implements pipelining of SQL statements. A pipeline must begin with a \u003ccode\u003e\\startpipeline\u003c/code\u003e and end with an \u003ccode\u003e\\endpipeline\u003c/code\u003e. In between there may be any number of \u003ccode\u003e\\syncpipeline\u003c/code\u003e commands, which sends a \u003ca href=\"/docs/18/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY\" rel=\"nofollow\"\u003esync message\u003c/a\u003e 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 \u003ca href=\"/docs/18/libpq-pipeline-mode.html\" rel=\"nofollow\"\u003eSection 32.5\u003c/a\u003e for more details.\u003c/p\u003e\n\u003cp\u003eAll queries executed while a pipeline is ongoing use the extended query protocol. Queries are appended to the pipeline when ending with a semicolon. The meta-commands \u003ccode\u003e\\bind\u003c/code\u003e, \u003ccode\u003e\\bind_named\u003c/code\u003e, \u003ccode\u003e\\close_prepared\u003c/code\u003e or \u003ccode\u003e\\parse\u003c/code\u003e can be used in an ongoing pipeline. While a pipeline is ongoing, \u003ccode\u003e\\sendpipeline\u003c/code\u003e will append the current query buffer to the pipeline. Other meta-commands like \u003ccode\u003e\\g\u003c/code\u003e, \u003ccode\u003e\\gx\u003c/code\u003e or \u003ccode\u003e\\gdesc\u003c/code\u003e are not allowed in pipeline mode.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e\\flushrequest\u003c/code\u003e appends a flush command to the pipeline, allowing to read results with \u003ccode\u003e\\getresults\u003c/code\u003e without issuing a sync or ending the pipeline. \u003ccode\u003e\\getresults\u003c/code\u003e will automatically push unsent data to the server. \u003ccode\u003e\\flush\u003c/code\u003e can be used to manually push unsent data.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e\\getresults\u003c/code\u003e accepts an optional \u003cem\u003e\u003ccode\u003enumber_results\u003c/code\u003e\u003c/em\u003e parameter. If provided, only the first \u003cem\u003e\u003ccode\u003enumber_results\u003c/code\u003e\u003c/em\u003e pending results will be read. If not provided or \u003ccode\u003e0\u003c/code\u003e, all pending results are read.\u003c/p\u003e\n\u003cp\u003eWhen pipeline mode is active, a dedicated prompt variable is available to report the pipeline status. See \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PROMPTING-P-UC\" rel=\"nofollow\"\u003e\u003ccode\u003e%P\u003c/code\u003e\u003c/a\u003e for more details\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003eCOPY\u003c/code\u003e is not supported while in pipeline mode.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre\u003e\\startpipeline\nSELECT * FROM pg_class;\nSELECT 1 \\bind \\sendpipeline\n\\flushrequest\n\\getresults\n\\endpipeline\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-T-LC\"\u003e\u003cspan\u003e\u003ccode\u003e\\t\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eToggles the display of output column name headings and row count footer. This command is equivalent to \u003ccode\u003e\\pset tuples_only\u003c/code\u003e and is provided for convenience.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-T-UC\"\u003e\u003cspan\u003e\u003ccode\u003e\\T \u003cem\u003e\u003ccode\u003etable_options\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies attributes to be placed within the \u003ccode\u003etable\u003c/code\u003e tag in HTML output format. This command is equivalent to \u003ccode\u003e\\pset tableattr \u003cem\u003e\u003ccode\u003etable_options\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-TIMING\"\u003e\u003cspan\u003e\u003ccode\u003e\\timing [ \u003cem\u003e\u003ccode\u003eon\u003c/code\u003e\u003c/em\u003e | \u003cem\u003e\u003ccode\u003eoff\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWith 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-UNRESTRICT\"\u003e\u003cspan\u003e\u003ccode\u003e\\unrestrict \u003cem\u003e\u003ccode\u003erestrict_key\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eExit \u0026#34;restricted\u0026#34; mode (i.e., where all other meta-commands are blocked), provided the specified key matches the one given to \u003ccode\u003e\\restrict\u003c/code\u003e when restricted mode was entered.\u003c/p\u003e\n\u003cp\u003eThis command is primarily intended for use in plain-text dumps generated by \u003cspan\u003epg_dump\u003c/span\u003e, \u003cspan\u003epg_dumpall\u003c/span\u003e, and \u003cspan\u003epg_restore\u003c/span\u003e, but it may be useful elsewhere.\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument of \u003ccode\u003e\\unrestrict\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-UNSET\"\u003e\u003cspan\u003e\u003ccode\u003e\\unset \u003cem\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUnsets (deletes) the \u003cspan\u003epsql\u003c/span\u003e variable \u003cem\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eMost variables that control \u003cspan\u003epsql\u003c/span\u003e\u0026#39;s behavior cannot be unset; instead, an \u003ccode\u003e\\unset\u003c/code\u003e command is interpreted as setting them to their default values. See \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-VARIABLES\" title=\"Variables\" rel=\"nofollow\"\u003eVariables\u003c/a\u003e below.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-WRITE\"\u003e\u003cspan\u003e\u003ccode\u003e\\w\u003c/code\u003e or \u003ccode\u003e\\write\u003c/code\u003e \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e\\w\u003c/code\u003e or \u003ccode\u003e\\write\u003c/code\u003e \u003ccode\u003e|\u003c/code\u003e\u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWrites the current query buffer to the file \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e or pipes it to the shell command \u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e. If the current query buffer is empty, the most recently executed query is written instead.\u003c/p\u003e\n\u003cp\u003eIf the argument begins with \u003ccode\u003e|\u003c/code\u003e, then the entire remainder of the line is taken to be the \u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e to execute, and neither variable interpolation nor backquote expansion are performed in it. The rest of the line is simply passed literally to the shell.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-WARN\"\u003e\u003cspan\u003e\u003ccode\u003e\\warn \u003cem\u003e\u003ccode\u003etext\u003c/code\u003e\u003c/em\u003e [ ... ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command is identical to \u003ccode\u003e\\echo\u003c/code\u003e except that the output will be written to \u003cspan\u003epsql\u003c/span\u003e\u0026#39;s standard error channel, rather than standard output.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-WATCH\"\u003e\u003cspan\u003e\u003ccode\u003e\\watch [ i[nterval]=\u003cem\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e ] [ c[ount]=\u003cem\u003e\u003ccode\u003etimes\u003c/code\u003e\u003c/em\u003e ] [ m[in_rows]=\u003cem\u003e\u003ccode\u003erows\u003c/code\u003e\u003c/em\u003e ] [ \u003cem\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRepeatedly execute the current query buffer (as \u003ccode\u003e\\g\u003c/code\u003e 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 \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-VARIABLES-WATCH-INTERVAL\" rel=\"nofollow\"\u003e\u003ccode\u003eWATCH_INTERVAL\u003c/code\u003e\u003c/a\u003e. For backwards compatibility, \u003cem\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e can be specified with or without an \u003ccode\u003einterval=\u003c/code\u003e prefix. Each query result is displayed with a header that includes the \u003ccode\u003e\\pset title\u003c/code\u003e string (if any), the time as of query start, and the delay interval.\u003c/p\u003e\n\u003cp\u003eIf the current query buffer is empty, the most recently sent query is re-executed instead.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-X\"\u003e\u003cspan\u003e\u003ccode\u003e\\x [ \u003cem\u003e\u003ccode\u003eon\u003c/code\u003e\u003c/em\u003e | \u003cem\u003e\u003ccode\u003eoff\u003c/code\u003e\u003c/em\u003e | \u003cem\u003e\u003ccode\u003eauto\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets or toggles expanded table formatting mode. As such it is equivalent to \u003ccode\u003e\\pset expanded\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-Z\"\u003e\u003cspan\u003e\u003ccode\u003e\\z[Sx] [ \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003e\u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists tables, views and sequences with their associated access privileges. If a \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e 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 \u003ccode\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003cp\u003eThis is an alias for \u003ccode\u003e\\dp\u003c/code\u003e (\u003cspan\u003e“\u003cspan\u003edisplay privileges\u003c/span\u003e”\u003c/span\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-EXCLAMATION-MARK\"\u003e\u003cspan\u003e\u003ccode\u003e\\! [ \u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWith no argument, escapes to a sub-shell; \u003cspan\u003epsql\u003c/span\u003e resumes when the sub-shell exits. With an argument, executes the shell command \u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument(s) of \u003ccode\u003e\\!\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments. The rest of the line is simply passed literally to the shell.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-QUESTION-MARK\"\u003e\u003cspan\u003e\u003ccode\u003e\\? [ \u003cem\u003e\u003ccode\u003etopic\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShows help information. The optional \u003cem\u003e\u003ccode\u003etopic\u003c/code\u003e\u003c/em\u003e parameter (defaulting to \u003ccode\u003ecommands\u003c/code\u003e) selects which part of \u003cspan\u003epsql\u003c/span\u003e is explained: \u003ccode\u003ecommands\u003c/code\u003e describes \u003cspan\u003epsql\u003c/span\u003e\u0026#39;s backslash commands; \u003ccode\u003eoptions\u003c/code\u003e describes the command-line options that can be passed to \u003cspan\u003epsql\u003c/span\u003e; and \u003ccode\u003evariables\u003c/code\u003e shows help about \u003cspan\u003epsql\u003c/span\u003e configuration variables.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-SEMICOLON\"\u003e\u003cspan\u003e\u003ccode\u003e\\;\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBackslash-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.\u003c/p\u003e\n\u003cp\u003eNormally, \u003cspan\u003epsql\u003c/span\u003e will dispatch an SQL command to the server as soon as it reaches the command-ending semicolon, even if more input remains on the current line. Thus for example entering\u003c/p\u003e\n\u003cpre\u003eselect 1; select 2; select 3;\n\u003c/pre\u003e\n\u003cp\u003ewill result in the three SQL commands being individually sent to the server, with each one\u0026#39;s results being displayed before continuing to the next command. However, a semicolon entered as \u003ccode\u003e\\;\u003c/code\u003e will not trigger command processing, so that the command before it and the one after are effectively combined and sent to the server in one request. So for example\u003c/p\u003e\n\u003cpre\u003eselect 1\\; select 2\\; select 3;\n\u003c/pre\u003e\n\u003cp\u003eresults in sending the three SQL commands to the server in a single request, when the non-backslashed semicolon is reached. The server executes such a request as a single transaction, unless there are explicit \u003ccode\u003eBEGIN\u003c/code\u003e/\u003ccode\u003eCOMMIT\u003c/code\u003e commands included in the string to divide it into multiple transactions. (See \u003ca href=\"/docs/18/protocol-flow.html#PROTOCOL-FLOW-MULTI-STATEMENT\" rel=\"nofollow\"\u003eSection 54.2.2.1\u003c/a\u003e for more details about how the server handles multi-query strings.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cdiv id=\"APP-PSQL-PATTERNS\"\u003e\n\u003ch4\u003ePatterns\u003c/h4\u003e\n\u003cp\u003eThe various \u003ccode\u003e\\d\u003c/code\u003e commands accept a \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e parameter to specify the object name(s) to be displayed. In the simplest case, a pattern is just the exact name of the object. The characters within a pattern are normally folded to lower case, just as in SQL names; for example, \u003ccode\u003e\\dt FOO\u003c/code\u003e will display the table named \u003ccode\u003efoo\u003c/code\u003e. As in SQL names, placing double quotes around a pattern stops folding to lower case. Should you need to include an actual double quote character in a pattern, write it as a pair of double quotes within a double-quote sequence; again this is in accord with the rules for SQL quoted identifiers. For example, \u003ccode\u003e\\dt \u0026#34;FOO\u0026#34;\u0026#34;BAR\u0026#34;\u003c/code\u003e will display the table named \u003ccode\u003eFOO\u0026#34;BAR\u003c/code\u003e (not \u003ccode\u003efoo\u0026#34;bar\u003c/code\u003e). Unlike the normal rules for SQL names, you can put double quotes around just part of a pattern, for instance \u003ccode\u003e\\dt FOO\u0026#34;FOO\u0026#34;BAR\u003c/code\u003e will display the table named \u003ccode\u003efooFOObar\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eWhenever the \u003cem\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e parameter is omitted completely, the \u003ccode\u003e\\d\u003c/code\u003e commands display all objects that are visible in the current schema search path — this is equivalent to using \u003ccode\u003e*\u003c/code\u003e as the pattern. (An object is said to be \u003cem\u003evisible\u003c/em\u003e if its containing schema is in the search path and no object of the same kind and name appears earlier in the search path. This is equivalent to the statement that the object can be referenced by name without explicit schema qualification.) To see all objects in the database regardless of visibility, use \u003ccode\u003e*.*\u003c/code\u003e as the pattern.\u003c/p\u003e\n\u003cp\u003eWithin a pattern, \u003ccode\u003e*\u003c/code\u003e matches any sequence of characters (including no characters) and \u003ccode\u003e?\u003c/code\u003e matches any single character. (This notation is comparable to Unix shell file name patterns.) For example, \u003ccode\u003e\\dt int*\u003c/code\u003e displays tables whose names begin with \u003ccode\u003eint\u003c/code\u003e. But within double quotes, \u003ccode\u003e*\u003c/code\u003e and \u003ccode\u003e?\u003c/code\u003e lose these special meanings and are just matched literally.\u003c/p\u003e\n\u003cp\u003eA relation pattern that contains a dot (\u003ccode\u003e.\u003c/code\u003e) is interpreted as a schema name pattern followed by an object name pattern. For example, \u003ccode\u003e\\dt foo*.*bar*\u003c/code\u003e displays all tables whose table name includes \u003ccode\u003ebar\u003c/code\u003e that are in schemas whose schema name starts with \u003ccode\u003efoo\u003c/code\u003e. When no dot appears, then the pattern matches only objects that are visible in the current schema search path. Again, a dot within double quotes loses its special meaning and is matched literally. A relation pattern that contains two dots (\u003ccode\u003e.\u003c/code\u003e) is interpreted as a database name followed by a schema name pattern followed by an object name pattern. The database name portion will not be treated as a pattern and must match the name of the currently connected database, else an error will be raised.\u003c/p\u003e\n\u003cp\u003eA schema pattern that contains a dot (\u003ccode\u003e.\u003c/code\u003e) is interpreted as a database name followed by a schema name pattern. For example, \u003ccode\u003e\\dn mydb.*foo*\u003c/code\u003e displays all schemas whose schema name includes \u003ccode\u003efoo\u003c/code\u003e. The database name portion will not be treated as a pattern and must match the name of the currently connected database, else an error will be raised.\u003c/p\u003e\n\u003cp\u003eAdvanced users can use regular-expression notations such as character classes, for example \u003ccode\u003e[0-9]\u003c/code\u003e to match any digit. All regular expression special characters work as specified in \u003ca href=\"/docs/18/functions-matching.html#FUNCTIONS-POSIX-REGEXP\" rel=\"nofollow\"\u003eSection 9.7.3\u003c/a\u003e, except for \u003ccode\u003e.\u003c/code\u003e which is taken as a separator as mentioned above, \u003ccode\u003e*\u003c/code\u003e which is translated to the regular-expression notation \u003ccode\u003e.*\u003c/code\u003e, \u003ccode\u003e?\u003c/code\u003e which is translated to \u003ccode\u003e.\u003c/code\u003e, and \u003ccode\u003e$\u003c/code\u003e which is matched literally. You can emulate these pattern characters at need by writing \u003ccode\u003e?\u003c/code\u003e for \u003ccode\u003e.\u003c/code\u003e, \u003ccode\u003e(\u003cem\u003e\u003ccode\u003eR\u003c/code\u003e\u003c/em\u003e+|)\u003c/code\u003e for \u003ccode\u003e\u003cem\u003e\u003ccode\u003eR\u003c/code\u003e\u003c/em\u003e*\u003c/code\u003e, or \u003ccode\u003e(\u003cem\u003e\u003ccode\u003eR\u003c/code\u003e\u003c/em\u003e|)\u003c/code\u003e for \u003ccode\u003e\u003cem\u003e\u003ccode\u003eR\u003c/code\u003e\u003c/em\u003e?\u003c/code\u003e. \u003ccode\u003e$\u003c/code\u003e is not needed as a regular-expression character since the pattern must match the whole name, unlike the usual interpretation of regular expressions (in other words, \u003ccode\u003e$\u003c/code\u003e is automatically appended to your pattern). Write \u003ccode\u003e*\u003c/code\u003e at the beginning and/or end if you don\u0026#39;t wish the pattern to be anchored. Note that within double quotes, all regular expression special characters lose their special meanings and are matched literally. Also, the regular expression special characters are matched literally in operator name patterns (i.e., the argument of \u003ccode\u003e\\do\u003c/code\u003e).\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.21.8.5\"\u003e\n\u003ch3\u003eAdvanced Features\u003c/h3\u003e\n\u003cdiv id=\"APP-PSQL-VARIABLES\"\u003e\n\u003ch4\u003eVariables\u003c/h4\u003e\n\u003cp\u003e\u003cspan\u003epsql\u003c/span\u003e provides variable substitution features similar to common Unix command shells. Variables are simply name/value pairs, where the value can be any string of any length. The name must consist of letters (including non-Latin letters), digits, and underscores.\u003c/p\u003e\n\u003cp\u003eTo set a variable, use the \u003cspan\u003epsql\u003c/span\u003e meta-command \u003ccode\u003e\\set\u003c/code\u003e. For example,\u003c/p\u003e\n\u003cpre\u003etestdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\set foo bar\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003esets the variable \u003ccode\u003efoo\u003c/code\u003e to the value \u003ccode\u003ebar\u003c/code\u003e. To retrieve the content of the variable, precede the name with a colon, for example:\u003c/p\u003e\n\u003cpre\u003etestdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\echo :foo\u003c/code\u003e\u003c/strong\u003e\nbar\n\u003c/pre\u003e\n\u003cp\u003eThis works in both regular SQL commands and meta-commands; there is more detail in \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-INTERPOLATION\" title=\"SQL Interpolation\" rel=\"nofollow\"\u003eSQL Interpolation\u003c/a\u003e, below.\u003c/p\u003e\n\u003cp\u003eIf you call \u003ccode\u003e\\set\u003c/code\u003e without a second argument, the variable is set to an empty-string value. To unset (i.e., delete) a variable, use the command \u003ccode\u003e\\unset\u003c/code\u003e. To show the values of all variables, call \u003ccode\u003e\\set\u003c/code\u003e without any argument.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003eThe arguments of \u003ccode\u003e\\set\u003c/code\u003e are subject to the same substitution rules as with other commands. Thus you can construct interesting references such as \u003ccode\u003e\\set :foo \u0026#39;something\u0026#39;\u003c/code\u003e and get \u003cspan\u003e“\u003cspan\u003esoft links\u003c/span\u003e”\u003c/span\u003e or \u003cspan\u003e“\u003cspan\u003evariable variables\u003c/span\u003e”\u003c/span\u003e of \u003cspan\u003ePerl\u003c/span\u003e or \u003cspan\u003ePHP\u003c/span\u003e fame, respectively. Unfortunately (or fortunately?), there is no way to do anything useful with these constructs. On the other hand, \u003ccode\u003e\\set bar :foo\u003c/code\u003e is a perfectly valid way to copy a variable.\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eA number of these variables are treated specially by \u003cspan\u003epsql\u003c/span\u003e. They represent certain option settings that can be changed at run time by altering the value of the variable, or in some cases represent changeable state of \u003cspan\u003epsql\u003c/span\u003e. By convention, all specially treated variables\u0026#39; names consist of all upper-case ASCII letters (and possibly digits and underscores). To ensure maximum compatibility in the future, avoid using such variable names for your own purposes.\u003c/p\u003e\n\u003cp\u003eVariables that control \u003cspan\u003epsql\u003c/span\u003e\u0026#39;s behavior generally cannot be unset or set to invalid values. An \u003ccode\u003e\\unset\u003c/code\u003e command is allowed but is interpreted as setting the variable to its default value. A \u003ccode\u003e\\set\u003c/code\u003e command without a second argument is interpreted as setting the variable to \u003ccode\u003eon\u003c/code\u003e, for control variables that accept that value, and is rejected for others. Also, control variables that accept the values \u003ccode\u003eon\u003c/code\u003e and \u003ccode\u003eoff\u003c/code\u003e will also accept other common spellings of Boolean values, such as \u003ccode\u003etrue\u003c/code\u003e and \u003ccode\u003efalse\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe specially treated variables are:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-AUTOCOMMIT\"\u003e\u003cspan\u003e\u003ccode\u003eAUTOCOMMIT\u003c/code\u003e \u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen \u003ccode\u003eon\u003c/code\u003e (the default), each SQL command is automatically committed upon successful completion. To postpone commit in this mode, you must enter a \u003ccode\u003eBEGIN\u003c/code\u003e or \u003ccode\u003eSTART TRANSACTION\u003c/code\u003e SQL command. When \u003ccode\u003eoff\u003c/code\u003e or unset, SQL commands are not committed until you explicitly issue \u003ccode\u003eCOMMIT\u003c/code\u003e or \u003ccode\u003eEND\u003c/code\u003e. The autocommit-off mode works by issuing an implicit \u003ccode\u003eBEGIN\u003c/code\u003e for you, just before any command that is not already in a transaction block and is not itself a \u003ccode\u003eBEGIN\u003c/code\u003e or other transaction-control command, nor a command that cannot be executed inside a transaction block (such as \u003ccode\u003eVACUUM\u003c/code\u003e).\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003eIn autocommit-off mode, you must explicitly abandon any failed transaction by entering \u003ccode\u003eABORT\u003c/code\u003e or \u003ccode\u003eROLLBACK\u003c/code\u003e. Also keep in mind that if you exit the session without committing, your work will be lost.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003eThe autocommit-on mode is \u003cspan\u003ePostgreSQL\u003c/span\u003e\u0026#39;s traditional behavior, but autocommit-off is closer to the SQL spec. If you prefer autocommit-off, you might wish to set it in the system-wide \u003ccode\u003epsqlrc\u003c/code\u003e file or your \u003ccode\u003e~/.psqlrc\u003c/code\u003e file.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-COMP-KEYWORD-CASE\"\u003e\u003cspan\u003e\u003ccode\u003eCOMP_KEYWORD_CASE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDetermines which letter case to use when completing an SQL key word. If set to \u003ccode\u003elower\u003c/code\u003e or \u003ccode\u003eupper\u003c/code\u003e, the completed word will be in lower or upper case, respectively. If set to \u003ccode\u003epreserve-lower\u003c/code\u003e or \u003ccode\u003epreserve-upper\u003c/code\u003e (the default), the completed word will be in the case of the word already entered, but words being completed without anything entered will be in lower or upper case, respectively.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-DBNAME\"\u003e\u003cspan\u003e\u003ccode\u003eDBNAME\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe name of the database you are currently connected to. This is set every time you connect to a database (including program start-up), but can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ECHO\"\u003e\u003cspan\u003e\u003ccode\u003eECHO\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf set to \u003ccode\u003eall\u003c/code\u003e, all nonempty input lines are printed to standard output as they are read. (This does not apply to lines read interactively.) To select this behavior on program start-up, use the switch \u003ccode\u003e-a\u003c/code\u003e. If set to \u003ccode\u003equeries\u003c/code\u003e, \u003cspan\u003epsql\u003c/span\u003e prints each query to standard output as it is sent to the server. The switch to select this behavior is \u003ccode\u003e-e\u003c/code\u003e. If set to \u003ccode\u003eerrors\u003c/code\u003e, then only failed queries are displayed on standard error output. The switch for this behavior is \u003ccode\u003e-b\u003c/code\u003e. If set to \u003ccode\u003enone\u003c/code\u003e (the default), then no queries are displayed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ECHO-HIDDEN\"\u003e\u003cspan\u003e\u003ccode\u003eECHO_HIDDEN\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen this variable is set to \u003ccode\u003eon\u003c/code\u003e and a backslash command queries the database, the query is first shown. This feature helps you to study \u003cspan\u003ePostgreSQL\u003c/span\u003e internals and provide similar functionality in your own programs. (To select this behavior on program start-up, use the switch \u003ccode\u003e-E\u003c/code\u003e.) If you set this variable to the value \u003ccode\u003enoexec\u003c/code\u003e, the queries are just shown but are not actually sent to the server and executed. The default value is \u003ccode\u003eoff\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ENCODING\"\u003e\u003cspan\u003e\u003ccode\u003eENCODING\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe current client character set encoding. This is set every time you connect to a database (including program start-up), and when you change the encoding with \u003ccode\u003e\\encoding\u003c/code\u003e, but it can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ERROR\"\u003e\u003cspan\u003e\u003ccode\u003eERROR\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003e\u003ccode\u003etrue\u003c/code\u003e if the last SQL query failed, \u003ccode\u003efalse\u003c/code\u003e if it succeeded. See also \u003ccode\u003eSQLSTATE\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-FETCH-COUNT\"\u003e\u003cspan\u003e\u003ccode\u003eFETCH_COUNT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf this variable is set to an integer value greater than zero, the results of \u003ccode\u003eSELECT\u003c/code\u003e queries are fetched and displayed in groups of that many rows, rather than the default behavior of collecting the entire result set before display. Therefore only a limited amount of memory is used, regardless of the size of the result set. Settings of 100 to 1000 are commonly used when enabling this feature. Keep in mind that when using this feature, a query might fail after having already displayed some rows.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eTip\u003c/h3\u003e\n\u003cp\u003eAlthough you can use any output format with this feature, the default \u003ccode\u003ealigned\u003c/code\u003e format tends to look bad because each group of \u003ccode\u003eFETCH_COUNT\u003c/code\u003e rows will be formatted separately, leading to varying column widths across the row groups. The other output formats work better.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-HIDE-TABLEAM\"\u003e\u003cspan\u003e\u003ccode\u003eHIDE_TABLEAM\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf this variable is set to \u003ccode\u003etrue\u003c/code\u003e, a table\u0026#39;s access method details are not displayed. This is mainly useful for regression tests.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-HIDE-TOAST-COMPRESSION\"\u003e\u003cspan\u003e\u003ccode\u003eHIDE_TOAST_COMPRESSION\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf this variable is set to \u003ccode\u003etrue\u003c/code\u003e, column compression method details are not displayed. This is mainly useful for regression tests.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-HISTCONTROL\"\u003e\u003cspan\u003e\u003ccode\u003eHISTCONTROL\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf this variable is set to \u003ccode\u003eignorespace\u003c/code\u003e, lines which begin with a space are not entered into the history list. If set to a value of \u003ccode\u003eignoredups\u003c/code\u003e, lines matching the previous history line are not entered. A value of \u003ccode\u003eignoreboth\u003c/code\u003e combines the two options. If set to \u003ccode\u003enone\u003c/code\u003e (the default), all lines read in interactive mode are saved on the history list.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis feature was shamelessly plagiarized from \u003cspan\u003eBash\u003c/span\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-HISTFILE\"\u003e\u003cspan\u003e\u003ccode\u003eHISTFILE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe file name that will be used to store the history list. If unset, the file name is taken from the \u003ccode\u003ePSQL_HISTORY\u003c/code\u003e environment variable. If that is not set either, the default is \u003ccode\u003e~/.psql_history\u003c/code\u003e, or \u003ccode\u003e%APPDATA%\\postgresql\\psql_history\u003c/code\u003e on Windows. For example, putting:\u003c/p\u003e\n\u003cpre\u003e\\set HISTFILE ~/.psql_history-:DBNAME\n\u003c/pre\u003e\n\u003cp\u003ein \u003ccode\u003e~/.psqlrc\u003c/code\u003e will cause \u003cspan\u003epsql\u003c/span\u003e to maintain a separate history for each database.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis feature was shamelessly plagiarized from \u003cspan\u003eBash\u003c/span\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-HISTSIZE\"\u003e\u003cspan\u003e\u003ccode\u003eHISTSIZE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe maximum number of commands to store in the command history (default 500). If set to a negative value, no limit is applied.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis feature was shamelessly plagiarized from \u003cspan\u003eBash\u003c/span\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-HOST\"\u003e\u003cspan\u003e\u003ccode\u003eHOST\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe database server host you are currently connected to. This is set every time you connect to a database (including program start-up), but can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-IGNOREEOF\"\u003e\u003cspan\u003e\u003ccode\u003eIGNOREEOF\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf set to 1 or less, sending an EOF character (usually \u003cspan\u003e\u003cstrong\u003eControl\u003c/strong\u003e\u003c/span\u003e+\u003cspan\u003e\u003cstrong\u003eD\u003c/strong\u003e\u003c/span\u003e) to an interactive session of \u003cspan\u003epsql\u003c/span\u003e will terminate the application. If set to a larger numeric value, that many consecutive EOF characters must be typed to make an interactive session terminate. If the variable is set to a non-numeric value, it is interpreted as 10. The default is 0.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis feature was shamelessly plagiarized from \u003cspan\u003eBash\u003c/span\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-LASTOID\"\u003e\u003cspan\u003e\u003ccode\u003eLASTOID\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe value of the last affected OID, as returned from an \u003ccode\u003eINSERT\u003c/code\u003e or \u003ccode\u003e\\lo_import\u003c/code\u003e command. This variable is only guaranteed to be valid until after the result of the next SQL command has been displayed. \u003cspan\u003ePostgreSQL\u003c/span\u003e servers since version 12 do not support OID system columns anymore, thus LASTOID will always be 0 following \u003ccode\u003eINSERT\u003c/code\u003e when targeting such servers.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-LAST-ERROR-MESSAGE\"\u003e\u003cspan\u003e\u003ccode\u003eLAST_ERROR_MESSAGE\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003eLAST_ERROR_SQLSTATE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe primary error message and associated SQLSTATE code for the most recent failed query in the current \u003cspan\u003epsql\u003c/span\u003e session, or an empty string and \u003ccode\u003e00000\u003c/code\u003e if no error has occurred in the current session.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ON-ERROR-ROLLBACK\"\u003e\u003cspan\u003e\u003ccode\u003eON_ERROR_ROLLBACK\u003c/code\u003e \u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen set to \u003ccode\u003eon\u003c/code\u003e, if a statement in a transaction block generates an error, the error is ignored and the transaction continues. When set to \u003ccode\u003einteractive\u003c/code\u003e, such errors are only ignored in interactive sessions, and not when reading script files. When set to \u003ccode\u003eoff\u003c/code\u003e (the default), a statement in a transaction block that generates an error aborts the entire transaction. The error rollback mode works by issuing an implicit \u003ccode\u003eSAVEPOINT\u003c/code\u003e for you, just before each command that is in a transaction block, and then rolling back to the savepoint if the command fails.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ON-ERROR-STOP\"\u003e\u003cspan\u003e\u003ccode\u003eON_ERROR_STOP\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, command processing continues after an error. When this variable is set to \u003ccode\u003eon\u003c/code\u003e, processing will instead stop immediately. In interactive mode, \u003cspan\u003epsql\u003c/span\u003e will return to the command prompt; otherwise, \u003cspan\u003epsql\u003c/span\u003e will exit, returning error code 3 to distinguish this case from fatal error conditions, which are reported using error code 1. In either case, any currently running scripts (the top-level script, if any, and any other scripts which it may have in invoked) will be terminated immediately. If the top-level command string contained multiple SQL commands, processing will stop with the current command.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-PIPELINE-COMMAND-COUNT\"\u003e\u003cspan\u003e\u003ccode\u003ePIPELINE_COMMAND_COUNT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe number of commands queued in an ongoing pipeline.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-PIPELINE-RESULT-COUNT\"\u003e\u003cspan\u003e\u003ccode\u003ePIPELINE_RESULT_COUNT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe number of commands of an ongoing pipeline that were followed by either a \u003ccode\u003e\\flushrequest\u003c/code\u003e or a \u003ccode\u003e\\syncpipeline\u003c/code\u003e, forcing the server to send the results. These results can be retrieved with \u003ccode\u003e\\getresults\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-PIPELINE-SYNC-COUNT\"\u003e\u003cspan\u003e\u003ccode\u003ePIPELINE_SYNC_COUNT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe number of sync messages queued in an ongoing pipeline.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-PORT\"\u003e\u003cspan\u003e\u003ccode\u003ePORT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe database server port to which you are currently connected. This is set every time you connect to a database (including program start-up), but can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-PROMPT\"\u003e\u003cspan\u003e\u003ccode\u003ePROMPT1\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003ePROMPT2\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003ePROMPT3\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThese specify what the prompts \u003cspan\u003epsql\u003c/span\u003e issues should look like. See \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PROMPTING\" title=\"Prompting\" rel=\"nofollow\"\u003ePrompting\u003c/a\u003e below.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-QUIET\"\u003e\u003cspan\u003e\u003ccode\u003eQUIET\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSetting this variable to \u003ccode\u003eon\u003c/code\u003e is equivalent to the command line option \u003ccode\u003e-q\u003c/code\u003e. It is probably not too useful in interactive mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ROW-COUNT\"\u003e\u003cspan\u003e\u003ccode\u003eROW_COUNT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe number of rows returned or affected by the last SQL query, or 0 if the query failed or did not report a row count.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SERVER-VERSION-NAME\"\u003e\u003cspan\u003e\u003ccode\u003eSERVER_VERSION_NAME\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003eSERVER_VERSION_NUM\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server\u0026#39;s version number as a string, for example \u003ccode\u003e9.6.2\u003c/code\u003e, \u003ccode\u003e10.1\u003c/code\u003e or \u003ccode\u003e11beta1\u003c/code\u003e, and in numeric form, for example \u003ccode\u003e90602\u003c/code\u003e or \u003ccode\u003e100001\u003c/code\u003e. These are set every time you connect to a database (including program start-up), but can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SERVICE\"\u003e\u003cspan\u003e\u003ccode\u003eSERVICE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe service name, if applicable.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SHELL-ERROR\"\u003e\u003cspan\u003e\u003ccode\u003eSHELL_ERROR\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003e\u003ccode\u003etrue\u003c/code\u003e if the last shell command failed, \u003ccode\u003efalse\u003c/code\u003e if it succeeded. This applies to shell commands invoked via the \u003ccode\u003e\\!\u003c/code\u003e, \u003ccode\u003e\\g\u003c/code\u003e, \u003ccode\u003e\\o\u003c/code\u003e, \u003ccode\u003e\\w\u003c/code\u003e, and \u003ccode\u003e\\copy\u003c/code\u003e meta-commands, as well as backquote (\u003ccode\u003e`\u003c/code\u003e) expansion. Note that for \u003ccode\u003e\\o\u003c/code\u003e, this variable is updated when the output pipe is closed by the next \u003ccode\u003e\\o\u003c/code\u003e command. See also \u003ccode\u003eSHELL_EXIT_CODE\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SHELL-EXIT-CODE\"\u003e\u003cspan\u003e\u003ccode\u003eSHELL_EXIT_CODE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe exit status returned by the last shell command. 0–127 represent program exit codes, 128–255 indicate termination by a signal, and -1 indicates failure to launch a program or to collect its exit status. This applies to shell commands invoked via the \u003ccode\u003e\\!\u003c/code\u003e, \u003ccode\u003e\\g\u003c/code\u003e, \u003ccode\u003e\\o\u003c/code\u003e, \u003ccode\u003e\\w\u003c/code\u003e, and \u003ccode\u003e\\copy\u003c/code\u003e meta-commands, as well as backquote (\u003ccode\u003e`\u003c/code\u003e) expansion. Note that for \u003ccode\u003e\\o\u003c/code\u003e, this variable is updated when the output pipe is closed by the next \u003ccode\u003e\\o\u003c/code\u003e command. See also \u003ccode\u003eSHELL_ERROR\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SHOW-ALL-RESULTS\"\u003e\u003cspan\u003e\u003ccode\u003eSHOW_ALL_RESULTS\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen this variable is set to \u003ccode\u003eoff\u003c/code\u003e, only the last result of a combined query (\u003ccode\u003e\\;\u003c/code\u003e) is shown instead of all of them. The default is \u003ccode\u003eon\u003c/code\u003e. The off behavior is for compatibility with older versions of \u003cspan\u003epsql\u003c/span\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SHOW-CONTEXT\"\u003e\u003cspan\u003e\u003ccode\u003eSHOW_CONTEXT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis variable can be set to the values \u003ccode\u003enever\u003c/code\u003e, \u003ccode\u003eerrors\u003c/code\u003e, or \u003ccode\u003ealways\u003c/code\u003e to control whether \u003ccode\u003eCONTEXT\u003c/code\u003e fields are displayed in messages from the server. The default is \u003ccode\u003eerrors\u003c/code\u003e (meaning that context will be shown in error messages, but not in notice or warning messages). This setting has no effect when \u003ccode\u003eVERBOSITY\u003c/code\u003e is set to \u003ccode\u003eterse\u003c/code\u003e or \u003ccode\u003esqlstate\u003c/code\u003e. (See also \u003ccode\u003e\\errverbose\u003c/code\u003e, for use when you want a verbose version of the error you just got.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SINGLELINE\"\u003e\u003cspan\u003e\u003ccode\u003eSINGLELINE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSetting this variable to \u003ccode\u003eon\u003c/code\u003e is equivalent to the command line option \u003ccode\u003e-S\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SINGLESTEP\"\u003e\u003cspan\u003e\u003ccode\u003eSINGLESTEP\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSetting this variable to \u003ccode\u003eon\u003c/code\u003e is equivalent to the command line option \u003ccode\u003e-s\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SQLSTATE\"\u003e\u003cspan\u003e\u003ccode\u003eSQLSTATE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe error code (see \u003ca href=\"/docs/18/errcodes-appendix.html\" rel=\"nofollow\"\u003eAppendix A\u003c/a\u003e) associated with the last SQL query\u0026#39;s failure, or \u003ccode\u003e00000\u003c/code\u003e if it succeeded.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-USER\"\u003e\u003cspan\u003e\u003ccode\u003eUSER\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe database user you are currently connected as. This is set every time you connect to a database (including program start-up), but can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-VERBOSITY\"\u003e\u003cspan\u003e\u003ccode\u003eVERBOSITY\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis variable can be set to the values \u003ccode\u003edefault\u003c/code\u003e, \u003ccode\u003everbose\u003c/code\u003e, \u003ccode\u003eterse\u003c/code\u003e, or \u003ccode\u003esqlstate\u003c/code\u003e to control the verbosity of error reports. (See also \u003ccode\u003e\\errverbose\u003c/code\u003e, for use when you want a verbose version of the error you just got.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-VERSION\"\u003e\u003cspan\u003e\u003ccode\u003eVERSION\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003eVERSION_NAME\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003eVERSION_NUM\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThese variables are set at program start-up to reflect \u003cspan\u003epsql\u003c/span\u003e\u0026#39;s version, respectively as a verbose string, a short string (e.g., \u003ccode\u003e9.6.2\u003c/code\u003e, \u003ccode\u003e10.1\u003c/code\u003e, or \u003ccode\u003e11beta1\u003c/code\u003e), and a number (e.g., \u003ccode\u003e90602\u003c/code\u003e or \u003ccode\u003e100001\u003c/code\u003e). They can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-WATCH-INTERVAL\"\u003e\u003cspan\u003e\u003ccode\u003eWATCH_INTERVAL\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis variable sets the default interval, in seconds, which \u003ccode\u003e\\watch\u003c/code\u003e waits between executing the query. The default is 2 seconds. Specifying an interval in the command overrides this variable.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"APP-PSQL-INTERPOLATION\"\u003e\n\u003ch4\u003eSQL Interpolation\u003c/h4\u003e\n\u003cp\u003eA key feature of \u003cspan\u003epsql\u003c/span\u003e variables is that you can substitute (\u003cspan\u003e“\u003cspan\u003einterpolate\u003c/span\u003e”\u003c/span\u003e) them into regular SQL statements, as well as the arguments of meta-commands. Furthermore, \u003cspan\u003epsql\u003c/span\u003e provides facilities for ensuring that variable values used as SQL literals and identifiers are properly quoted. The syntax for interpolating a value without any quoting is to prepend the variable name with a colon (\u003ccode\u003e:\u003c/code\u003e). For example,\u003c/p\u003e\n\u003cpre\u003etestdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\set foo \u0026#39;my_table\u0026#39;\u003c/code\u003e\u003c/strong\u003e\ntestdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003eSELECT * FROM :foo;\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003ewould query the table \u003ccode\u003emy_table\u003c/code\u003e. Note that this may be unsafe: the value of the variable is copied literally, so it can contain unbalanced quotes, or even backslash commands. You must make sure that it makes sense where you put it.\u003c/p\u003e\n\u003cp\u003eWhen a value is to be used as an SQL literal or identifier, it is safest to arrange for it to be quoted. To quote the value of a variable as an SQL literal, write a colon followed by the variable name in single quotes. To quote the value as an SQL identifier, write a colon followed by the variable name in double quotes. These constructs deal correctly with quotes and other special characters embedded within the variable value. The previous example would be more safely written this way:\u003c/p\u003e\n\u003cpre\u003etestdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\set foo \u0026#39;my_table\u0026#39;\u003c/code\u003e\u003c/strong\u003e\ntestdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003eSELECT * FROM :\u0026#34;foo\u0026#34;;\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eVariable interpolation will not be performed within quoted SQL literals and identifiers. Therefore, a construction such as \u003ccode\u003e\u0026#39;:foo\u0026#39;\u003c/code\u003e doesn\u0026#39;t work to produce a quoted literal from a variable\u0026#39;s value (and it would be unsafe if it did work, since it wouldn\u0026#39;t correctly handle quotes embedded in the value).\u003c/p\u003e\n\u003cp\u003eOne example use of this mechanism is to copy the contents of a file into a table column. First load the file into a variable and then interpolate the variable\u0026#39;s value as a quoted string:\u003c/p\u003e\n\u003cpre\u003etestdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\set content `cat my_file.txt`\u003c/code\u003e\u003c/strong\u003e\ntestdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003eINSERT INTO my_table VALUES (:\u0026#39;content\u0026#39;);\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003e(Note that this still won\u0026#39;t work if \u003ccode\u003emy_file.txt\u003c/code\u003e contains NUL bytes. \u003cspan\u003epsql\u003c/span\u003e does not support embedded NUL bytes in variable values.)\u003c/p\u003e\n\u003cp\u003eSince colons can legally appear in SQL commands, an apparent attempt at interpolation (that is, \u003ccode\u003e:name\u003c/code\u003e, \u003ccode\u003e:\u0026#39;name\u0026#39;\u003c/code\u003e, or \u003ccode\u003e:\u0026#34;name\u0026#34;\u003c/code\u003e) is not replaced unless the named variable is currently set. In any case, you can escape a colon with a backslash to protect it from substitution.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode\u003e:{?\u003cem\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e}\u003c/code\u003e special syntax returns TRUE or FALSE depending on whether the variable exists or not, and is thus always substituted, unless the colon is backslash-escaped.\u003c/p\u003e\n\u003cp\u003eThe colon syntax for variables is standard SQL for embedded query languages, such as \u003cspan\u003eECPG\u003c/span\u003e. The colon syntaxes for array slices and type casts are \u003cspan\u003ePostgreSQL\u003c/span\u003e extensions, which can sometimes conflict with the standard usage. The colon-quote syntax for escaping a variable\u0026#39;s value as an SQL literal or identifier is a \u003cspan\u003epsql\u003c/span\u003e extension.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"APP-PSQL-PROMPTING\"\u003e\n\u003ch4\u003ePrompting\u003c/h4\u003e\n\u003cp\u003eThe prompts \u003cspan\u003epsql\u003c/span\u003e issues can be customized to your preference. The three variables \u003ccode\u003ePROMPT1\u003c/code\u003e, \u003ccode\u003ePROMPT2\u003c/code\u003e, and \u003ccode\u003ePROMPT3\u003c/code\u003e contain strings and special escape sequences that describe the appearance of the prompt. Prompt 1 is the normal prompt that is issued when \u003cspan\u003epsql\u003c/span\u003e requests a new command. Prompt 2 is issued when more input is expected during command entry, for example because the command was not terminated with a semicolon or a quote was not closed. Prompt 3 is issued when you are running an SQL \u003ccode\u003eCOPY FROM STDIN\u003c/code\u003e command and you need to type in a row value on the terminal.\u003c/p\u003e\n\u003cp\u003eThe value of the selected prompt variable is printed literally, except where a percent sign (\u003ccode\u003e%\u003c/code\u003e) is encountered. Depending on the next character, certain other text is substituted instead. Defined substitutions are:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-M-UC\"\u003e\u003cspan\u003e\u003ccode\u003e%M\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe full host name (with domain name) of the database server, or \u003ccode\u003e[local]\u003c/code\u003e if the connection is over a Unix domain socket, or \u003ccode\u003e[local:\u003cem\u003e\u003ccode\u003e/dir/name\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e, if the Unix domain socket is not at the compiled in default location.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-M-LC\"\u003e\u003cspan\u003e\u003ccode\u003e%m\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe host name of the database server, truncated at the first dot, or \u003ccode\u003e[local]\u003c/code\u003e if the connection is over a Unix domain socket.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-GT\"\u003e\u003cspan\u003e\u003ccode\u003e%\u0026gt;\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe port number at which the database server is listening.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-N\"\u003e\u003cspan\u003e\u003ccode\u003e%n\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe database session user name. (The expansion of this value might change during a database session as the result of the command \u003ccode\u003eSET SESSION AUTHORIZATION\u003c/code\u003e.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-S\"\u003e\u003cspan\u003e\u003ccode\u003e%s\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe name of the service.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-SLASH\"\u003e\u003cspan\u003e\u003ccode\u003e%/\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe name of the current database.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-TILDE\"\u003e\u003cspan\u003e\u003ccode\u003e%~\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLike \u003ccode\u003e%/\u003c/code\u003e, but the output is \u003ccode\u003e~\u003c/code\u003e (tilde) if the database is your default database.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-NUMBERSIGN\"\u003e\u003cspan\u003e\u003ccode\u003e%#\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf the session user is a database superuser, then a \u003ccode\u003e#\u003c/code\u003e, otherwise a \u003ccode\u003e\u0026gt;\u003c/code\u003e. (The expansion of this value might change during a database session as the result of the command \u003ccode\u003eSET SESSION AUTHORIZATION\u003c/code\u003e.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-P\"\u003e\u003cspan\u003e\u003ccode\u003e%p\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe process ID of the backend currently connected to.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-P-UC\"\u003e\u003cspan\u003e\u003ccode\u003e%P\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePipeline status: \u003ccode\u003eoff\u003c/code\u003e when not in a pipeline, \u003ccode\u003eon\u003c/code\u003e when in an ongoing pipeline or \u003ccode\u003eabort\u003c/code\u003e when in an aborted pipeline.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-R\"\u003e\u003cspan\u003e\u003ccode\u003e%R\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIn prompt 1 normally \u003ccode\u003e=\u003c/code\u003e, but \u003ccode\u003e@\u003c/code\u003e if the session is in an inactive branch of a conditional block, or \u003ccode\u003e^\u003c/code\u003e if in single-line mode, or \u003ccode\u003e!\u003c/code\u003e if the session is disconnected from the database (which can happen if \u003ccode\u003e\\connect\u003c/code\u003e fails). In prompt 2 \u003ccode\u003e%R\u003c/code\u003e is replaced by a character that depends on why \u003cspan\u003epsql\u003c/span\u003e expects more input: \u003ccode\u003e-\u003c/code\u003e if the command simply wasn\u0026#39;t terminated yet, but \u003ccode\u003e*\u003c/code\u003e if there is an unfinished \u003ccode\u003e/* ... */\u003c/code\u003e comment, a single quote if there is an unfinished quoted string, a double quote if there is an unfinished quoted identifier, a dollar sign if there is an unfinished dollar-quoted string, or \u003ccode\u003e(\u003c/code\u003e if there is an unmatched left parenthesis. In prompt 3 \u003ccode\u003e%R\u003c/code\u003e doesn\u0026#39;t produce anything.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-X\"\u003e\u003cspan\u003e\u003ccode\u003e%x\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eTransaction status: an empty string when not in a transaction block, or \u003ccode\u003e*\u003c/code\u003e when in a transaction block, or \u003ccode\u003e!\u003c/code\u003e when in a failed transaction block, or \u003ccode\u003e?\u003c/code\u003e when the transaction state is indeterminate (for example, because there is no connection).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-L\"\u003e\u003cspan\u003e\u003ccode\u003e%l\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe line number inside the current statement, starting from \u003ccode\u003e1\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-DIGITS\"\u003e\u003cspan\u003e\u003ccode\u003e%\u003c/code\u003e\u003cem\u003e\u003ccode\u003edigits\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe character with the indicated octal code is substituted.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-NAME\"\u003e\u003cspan\u003e\u003ccode\u003e%:\u003c/code\u003e\u003cem\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003ccode\u003e:\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe value of the \u003cspan\u003epsql\u003c/span\u003e variable \u003cem\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e. See \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-VARIABLES\" title=\"Variables\" rel=\"nofollow\"\u003eVariables\u003c/a\u003e, above, for details.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-COMMAND\"\u003e\u003cspan\u003e\u003ccode\u003e%`\u003c/code\u003e\u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e\u003ccode\u003e`\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe output of \u003cem\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e, similar to ordinary \u003cspan\u003e“\u003cspan\u003eback-tick\u003c/span\u003e”\u003c/span\u003e substitution.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-SQUARE-BRACKETS\"\u003e\u003cspan\u003e\u003ccode\u003e%[\u003c/code\u003e ... \u003ccode\u003e%]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrompts can contain terminal control characters which, for example, change the color, background, or style of the prompt text, or change the title of the terminal window. In order for the line editing features of \u003cspan\u003eReadline\u003c/span\u003e to work properly, these non-printing control characters must be designated as invisible by surrounding them with \u003ccode\u003e%[\u003c/code\u003e and \u003ccode\u003e%]\u003c/code\u003e. Multiple pairs of these can occur within the prompt. For example:\u003c/p\u003e\n\u003cpre\u003etestdb=\u0026gt; \\set PROMPT1 \u0026#39;%[%033[1;33;40m%]%n@%/%R%[%033[0m%]%# \u0026#39;\n\u003c/pre\u003e\n\u003cp\u003eresults in a boldfaced (\u003ccode\u003e1;\u003c/code\u003e) yellow-on-black (\u003ccode\u003e33;40\u003c/code\u003e) prompt on VT100-compatible, color-capable terminals.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-W\"\u003e\u003cspan\u003e\u003ccode\u003e%w\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhitespace of the same width as the most recent output of \u003ccode\u003ePROMPT1\u003c/code\u003e. This can be used as a \u003ccode\u003ePROMPT2\u003c/code\u003e setting, so that multi-line statements are aligned with the first line, but there is no visible secondary prompt.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eTo insert a percent sign into your prompt, write \u003ccode\u003e%%\u003c/code\u003e. The default prompts are \u003ccode\u003e\u0026#39;%/%R%x%# \u0026#39;\u003c/code\u003e for prompts 1 and 2, and \u003ccode\u003e\u0026#39;\u0026gt;\u0026gt; \u0026#39;\u003c/code\u003e for prompt 3.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis feature was shamelessly plagiarized from \u003cspan\u003etcsh\u003c/span\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"APP-PSQL-READLINE\"\u003e\n\u003ch4\u003eCommand-Line Editing\u003c/h4\u003e\n\u003cp\u003e\u003cspan\u003epsql\u003c/span\u003e uses the \u003cspan\u003eReadline\u003c/span\u003e or \u003cspan\u003elibedit\u003c/span\u003e library, if available, for convenient line editing and retrieval. The command history is automatically saved when \u003cspan\u003epsql\u003c/span\u003e exits and is reloaded when \u003cspan\u003epsql\u003c/span\u003e starts up. Type up-arrow or control-P to retrieve previous lines.\u003c/p\u003e\n\u003cp\u003eYou can also use tab completion to fill in partially-typed keywords and SQL object names in many (by no means all) contexts. For example, at the start of a command, typing \u003ccode\u003eins\u003c/code\u003e and pressing TAB will fill in \u003ccode\u003einsert into\u003c/code\u003e . Then, typing a few characters of a table or schema name and pressing \u003ccode\u003eTAB\u003c/code\u003e will fill in the unfinished name, or offer a menu of possible completions when there\u0026#39;s more than one. (Depending on the library in use, you may need to press \u003ccode\u003eTAB\u003c/code\u003e more than once to get a menu.)\u003c/p\u003e\n\u003cp\u003eTab completion for SQL object names requires sending queries to the server to find possible matches. In some contexts this can interfere with other operations. For example, after \u003ccode\u003eBEGIN\u003c/code\u003e it will be too late to issue \u003ccode\u003eSET TRANSACTION ISOLATION LEVEL\u003c/code\u003e if a tab-completion query is issued in between. If you do not want tab completion at all, you can turn it off permanently by putting this in a file named \u003ccode\u003e.inputrc\u003c/code\u003e in your home directory:\u003c/p\u003e\n\u003cpre\u003e$if psql\nset disable-completion on\n$endif\n\u003c/pre\u003e\n\u003cp\u003e(This is not a \u003cspan\u003epsql\u003c/span\u003e but a \u003cspan\u003eReadline\u003c/span\u003e feature. Read its documentation for further details.)\u003c/p\u003e\n\u003cp\u003eThe \u003ccode\u003e-n\u003c/code\u003e (\u003ccode\u003e--no-readline\u003c/code\u003e) command line option can also be useful to disable use of \u003cspan\u003eReadline\u003c/span\u003e for a single run of \u003cspan\u003epsql\u003c/span\u003e. This prevents tab completion, use or recording of command line history, and editing of multi-line commands. It is particularly useful when you need to copy-and-paste text that contains \u003ccode\u003eTAB\u003c/code\u003e characters.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"APP-PSQL-ENVIRONMENT\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-COLUMNS\"\u003e\u003cspan\u003e\u003ccode\u003eCOLUMNS\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003ccode\u003e\\pset columns\u003c/code\u003e is zero, controls the width for the \u003ccode\u003ewrapped\u003c/code\u003e format and width for determining if wide output requires the pager or should be switched to the vertical format in expanded auto mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PGDATABASE\"\u003e\u003cspan\u003e\u003ccode\u003ePGDATABASE\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003ePGHOST\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003ePGPORT\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003ePGUSER\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDefault connection parameters (see \u003ca href=\"/docs/18/libpq-envars.html\" rel=\"nofollow\"\u003eSection 32.15\u003c/a\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PG-COLOR\"\u003e\u003cspan\u003e\u003ccode\u003ePG_COLOR\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies whether to use color in diagnostic messages. Possible values are \u003ccode\u003ealways\u003c/code\u003e, \u003ccode\u003eauto\u003c/code\u003e and \u003ccode\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PSQL-EDITOR\"\u003e\u003cspan\u003e\u003ccode\u003ePSQL_EDITOR\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003eEDITOR\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003eVISUAL\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEditor used by the \u003ccode\u003e\\e\u003c/code\u003e, \u003ccode\u003e\\ef\u003c/code\u003e, and \u003ccode\u003e\\ev\u003c/code\u003e commands. These variables are examined in the order listed; the first that is set is used. If none of them is set, the default is to use \u003ccode\u003evi\u003c/code\u003e on Unix systems or \u003ccode\u003enotepad.exe\u003c/code\u003e on Windows systems.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PSQL-EDITOR-LINENUMBER-ARG\"\u003e\u003cspan\u003e\u003ccode\u003ePSQL_EDITOR_LINENUMBER_ARG\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen \u003ccode\u003e\\e\u003c/code\u003e, \u003ccode\u003e\\ef\u003c/code\u003e, or \u003ccode\u003e\\ev\u003c/code\u003e is used with a line number argument, this variable specifies the command-line argument used to pass the starting line number to the user\u0026#39;s editor. For editors such as \u003cspan\u003eEmacs\u003c/span\u003e or \u003cspan\u003evi\u003c/span\u003e, this is a plus sign. Include a trailing space in the value of the variable if there needs to be space between the option name and the line number. Examples:\u003c/p\u003e\n\u003cpre\u003ePSQL_EDITOR_LINENUMBER_ARG=\u0026#39;+\u0026#39;\nPSQL_EDITOR_LINENUMBER_ARG=\u0026#39;--line \u0026#39;\n\u003c/pre\u003e\n\u003cp\u003eThe default is \u003ccode\u003e+\u003c/code\u003e on Unix systems (corresponding to the default editor \u003ccode\u003evi\u003c/code\u003e, and useful for many other common editors); but there is no default on Windows systems.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PSQL-HISTORY\"\u003e\u003cspan\u003e\u003ccode\u003ePSQL_HISTORY\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAlternative location for the command history file. Tilde (\u003ccode\u003e~\u003c/code\u003e) expansion is performed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PAGER\"\u003e\u003cspan\u003e\u003ccode\u003ePSQL_PAGER\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003ePAGER\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf a query\u0026#39;s results do not fit on the screen, they are piped through this command. Typical values are \u003ccode\u003emore\u003c/code\u003e or \u003ccode\u003eless\u003c/code\u003e. Use of the pager can be disabled by setting \u003ccode\u003ePSQL_PAGER\u003c/code\u003e or \u003ccode\u003ePAGER\u003c/code\u003e to an empty string, or by adjusting the pager-related options of the \u003ccode\u003e\\pset\u003c/code\u003e command. These variables are examined in the order listed; the first that is set is used. If neither of them is set, the default is to use \u003ccode\u003emore\u003c/code\u003e on most platforms, but \u003ccode\u003eless\u003c/code\u003e on Cygwin.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PSQL-WATCH-PAGER\"\u003e\u003cspan\u003e\u003ccode\u003ePSQL_WATCH_PAGER\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen a query is executed repeatedly with the \u003ccode\u003e\\watch\u003c/code\u003e command, a pager is not used by default. This behavior can be changed by setting \u003ccode\u003ePSQL_WATCH_PAGER\u003c/code\u003e to a pager command, on Unix systems. The \u003ccode\u003epspg\u003c/code\u003e pager (not part of \u003cspan\u003ePostgreSQL\u003c/span\u003e but available in many open source software distributions) can display the output of \u003ccode\u003e\\watch\u003c/code\u003e if started with the option \u003ccode\u003e--stream\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PSQLRC\"\u003e\u003cspan\u003e\u003ccode\u003ePSQLRC\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAlternative location of the user\u0026#39;s \u003ccode\u003e.psqlrc\u003c/code\u003e file. Tilde (\u003ccode\u003e~\u003c/code\u003e) expansion is performed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-SHELL\"\u003e\u003cspan\u003e\u003ccode\u003eSHELL\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCommand executed by the \u003ccode\u003e\\!\u003c/code\u003e command.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-TMPDIR\"\u003e\u003cspan\u003e\u003ccode\u003eTMPDIR\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDirectory for storing temporary files. The default is \u003ccode\u003e/tmp\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThis utility, like most other \u003cspan\u003ePostgreSQL\u003c/span\u003e utilities, also uses the environment variables supported by \u003cspan\u003elibpq\u003c/span\u003e (see \u003ca href=\"/docs/18/libpq-envars.html\" rel=\"nofollow\"\u003eSection 32.15\u003c/a\u003e).\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.21.10\"\u003e\n\u003ch2\u003eFiles\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt id=\"APP-PSQL-FILES-PSQLRC\"\u003e\u003cspan\u003e\u003ccode\u003epsqlrc\u003c/code\u003e and \u003ccode\u003e~/.psqlrc\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUnless it is passed an \u003ccode\u003e-X\u003c/code\u003e option, \u003cspan\u003epsql\u003c/span\u003e attempts to read and execute commands from the system-wide startup file (\u003ccode\u003epsqlrc\u003c/code\u003e) and then the user\u0026#39;s personal startup file (\u003ccode\u003e~/.psqlrc\u003c/code\u003e), after connecting to the database but before accepting normal commands. These files can be used to set up the client and/or the server to taste, typically with \u003ccode\u003e\\set\u003c/code\u003e and \u003ccode\u003eSET\u003c/code\u003e commands.\u003c/p\u003e\n\u003cp\u003eThe system-wide startup file is named \u003ccode\u003epsqlrc\u003c/code\u003e. By default it is sought in the installation\u0026#39;s \u003cspan\u003e“\u003cspan\u003esystem configuration\u003c/span\u003e”\u003c/span\u003e directory, which is most reliably identified by running \u003ccode\u003epg_config --sysconfdir\u003c/code\u003e. Typically this directory will be \u003ccode\u003e../etc/\u003c/code\u003e relative to the directory containing the \u003cspan\u003ePostgreSQL\u003c/span\u003e executables. The directory to look in can be set explicitly via the \u003ccode\u003ePGSYSCONFDIR\u003c/code\u003e environment variable.\u003c/p\u003e\n\u003cp\u003eThe user\u0026#39;s personal startup file is named \u003ccode\u003e.psqlrc\u003c/code\u003e and is sought in the invoking user\u0026#39;s home directory. On Windows the personal startup file is instead named \u003ccode\u003e%APPDATA%\\postgresql\\psqlrc.conf\u003c/code\u003e. In either case, this default file path can be overridden by setting the \u003ccode\u003ePSQLRC\u003c/code\u003e environment variable.\u003c/p\u003e\n\u003cp\u003eBoth the system-wide startup file and the user\u0026#39;s personal startup file can be made \u003cspan\u003epsql\u003c/span\u003e-version-specific by appending a dash and the \u003cspan\u003ePostgreSQL\u003c/span\u003e major or minor release identifier to the file name, for example \u003ccode\u003e~/.psqlrc-18\u003c/code\u003e or \u003ccode\u003e~/.psqlrc-18.6\u003c/code\u003e. The most specific version-matching file will be read in preference to a non-version-specific file. These version suffixes are added after determining the file path as explained above.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-FILES-PSQL-HISTORY\"\u003e\u003cspan\u003e\u003ccode\u003e.psql_history\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe command-line history is stored in the file \u003ccode\u003e~/.psql_history\u003c/code\u003e, or \u003ccode\u003e%APPDATA%\\postgresql\\psql_history\u003c/code\u003e on Windows.\u003c/p\u003e\n\u003cp\u003eThe location of the history file can be set explicitly via the \u003ccode\u003eHISTFILE\u003c/code\u003e \u003cspan\u003epsql\u003c/span\u003e variable or the \u003ccode\u003ePSQL_HISTORY\u003c/code\u003e environment variable.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.21.11\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003cp\u003e\u003cspan\u003epsql\u003c/span\u003e works best with servers of the same or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than \u003cspan\u003epsql\u003c/span\u003e itself. However, backslash commands of the \u003ccode\u003e\\d\u003c/code\u003e family should work with servers of versions back to 9.2, though not necessarily with servers newer than \u003cspan\u003epsql\u003c/span\u003e itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot be guaranteed in all cases.\u003c/p\u003e\n\u003cp\u003eIf you want to use \u003cspan\u003epsql\u003c/span\u003e to connect to several servers of different major versions, it is recommended that you use the newest version of \u003cspan\u003epsql\u003c/span\u003e. Alternatively, you can keep around a copy of \u003cspan\u003epsql\u003c/span\u003e from each major version and be sure to use the version that matches the respective server. But in practice, this additional complication should not be necessary.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eBefore \u003cspan\u003ePostgreSQL\u003c/span\u003e 9.6, the \u003ccode\u003e-c\u003c/code\u003e option implied \u003ccode\u003e-X\u003c/code\u003e (\u003ccode\u003e--no-psqlrc\u003c/code\u003e); this is no longer the case.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eBefore \u003cspan\u003ePostgreSQL\u003c/span\u003e 8.4, \u003cspan\u003epsql\u003c/span\u003e allowed the first argument of a single-letter backslash command to start directly after the command, without intervening whitespace. Now, some whitespace is required.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.21.12\"\u003e\n\u003ch2\u003eNotes for Windows Users\u003c/h2\u003e\n\u003cp\u003e\u003cspan\u003epsql\u003c/span\u003e is built as a \u003cspan\u003e“\u003cspan\u003econsole application\u003c/span\u003e”\u003c/span\u003e. Since the Windows console windows use a different encoding than the rest of the system, you must take special care when using 8-bit characters within \u003cspan\u003epsql\u003c/span\u003e. If \u003cspan\u003epsql\u003c/span\u003e detects a problematic console code page, it will warn you at startup. To change the console code page, two things are necessary:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003cp\u003eSet the code page by entering \u003cstrong\u003e\u003ccode\u003ecmd.exe /c chcp 1252\u003c/code\u003e\u003c/strong\u003e. (1252 is a code page that is appropriate for German; replace it with your value.) If you are using Cygwin, you can put this command in \u003ccode\u003e/etc/profile\u003c/code\u003e.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eSet the console font to \u003ccode\u003eLucida Console\u003c/code\u003e, because the raster font does not work with the ANSI code page.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"APP-PSQL-EXAMPLES\"\u003e\n\u003ch2\u003eExamples\u003c/h2\u003e\n\u003cp\u003eThe first example shows how to spread a command over several lines of input. Notice the changing prompt:\u003c/p\u003e\n\u003cpre\u003etestdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003eCREATE TABLE my_table (\u003c/code\u003e\u003c/strong\u003e\ntestdb(\u0026gt; \u003cstrong\u003e\u003ccode\u003e first integer not null default 0,\u003c/code\u003e\u003c/strong\u003e\ntestdb(\u0026gt; \u003cstrong\u003e\u003ccode\u003e second text)\u003c/code\u003e\u003c/strong\u003e\ntestdb-\u0026gt; \u003cstrong\u003e\u003ccode\u003e;\u003c/code\u003e\u003c/strong\u003e\nCREATE TABLE\n\u003c/pre\u003e\n\u003cp\u003eNow look at the table definition again:\u003c/p\u003e\n\u003cpre\u003etestdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\d my_table\u003c/code\u003e\u003c/strong\u003e\n              Table \u0026#34;public.my_table\u0026#34;\n Column |  Type   | Collation | Nullable | Default\n--------+---------+-----------+----------+---------\n first  | integer |           | not null | 0\n second | text    |           |          |\n\u003c/pre\u003e\n\u003cp\u003eNow we change the prompt to something more interesting:\u003c/p\u003e\n\u003cpre\u003etestdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\set PROMPT1 \u0026#39;%n@%m %~%R%# \u0026#39;\u003c/code\u003e\u003c/strong\u003e\npeter@localhost testdb=\u0026gt;\n\u003c/pre\u003e\n\u003cp\u003eLet\u0026#39;s assume you have filled the table with data and want to take a look at it:\u003c/p\u003e\n\u003cpre\u003epeter@localhost testdb=\u0026gt; SELECT * FROM my_table;\n first | second\n-------+--------\n     1 | one\n     2 | two\n     3 | three\n     4 | four\n(4 rows)\n\u003c/pre\u003e\n\u003cp\u003eYou can display tables in different ways by using the \u003ccode\u003e\\pset\u003c/code\u003e command:\u003c/p\u003e\n\u003cpre\u003epeter@localhost testdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\pset border 2\u003c/code\u003e\u003c/strong\u003e\nBorder style is 2.\npeter@localhost testdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003eSELECT * FROM my_table;\u003c/code\u003e\u003c/strong\u003e\n+-------+--------+\n| first | second |\n+-------+--------+\n|     1 | one    |\n|     2 | two    |\n|     3 | three  |\n|     4 | four   |\n+-------+--------+\n(4 rows)\n\npeter@localhost testdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\pset border 0\u003c/code\u003e\u003c/strong\u003e\nBorder style is 0.\npeter@localhost testdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003eSELECT * FROM my_table;\u003c/code\u003e\u003c/strong\u003e\nfirst second\n----- ------\n    1 one\n    2 two\n    3 three\n    4 four\n(4 rows)\n\npeter@localhost testdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\pset border 1\u003c/code\u003e\u003c/strong\u003e\nBorder style is 1.\npeter@localhost testdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\pset format csv\u003c/code\u003e\u003c/strong\u003e\nOutput format is csv.\npeter@localhost testdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\pset tuples_only\u003c/code\u003e\u003c/strong\u003e\nTuples only is on.\npeter@localhost testdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003eSELECT second, first FROM my_table;\u003c/code\u003e\u003c/strong\u003e\none,1\ntwo,2\nthree,3\nfour,4\npeter@localhost testdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\pset format unaligned\u003c/code\u003e\u003c/strong\u003e\nOutput format is unaligned.\npeter@localhost testdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\pset fieldsep \u0026#39;\\t\u0026#39;\u003c/code\u003e\u003c/strong\u003e\nField separator is \u0026#34;    \u0026#34;.\npeter@localhost testdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003eSELECT second, first FROM my_table;\u003c/code\u003e\u003c/strong\u003e\none     1\ntwo     2\nthree   3\nfour    4\n\u003c/pre\u003e\n\u003cp\u003eAlternatively, use the short commands:\u003c/p\u003e\n\u003cpre\u003epeter@localhost testdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\a \\t \\x\u003c/code\u003e\u003c/strong\u003e\nOutput format is aligned.\nTuples only is off.\nExpanded display is on.\npeter@localhost testdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003eSELECT * FROM my_table;\u003c/code\u003e\u003c/strong\u003e\n-[ RECORD 1 ]-\nfirst  | 1\nsecond | one\n-[ RECORD 2 ]-\nfirst  | 2\nsecond | two\n-[ RECORD 3 ]-\nfirst  | 3\nsecond | three\n-[ RECORD 4 ]-\nfirst  | 4\nsecond | four\n\u003c/pre\u003e\n\u003cp\u003eAlso, these output format options can be set for just one query by using \u003ccode\u003e\\g\u003c/code\u003e:\u003c/p\u003e\n\u003cpre\u003epeter@localhost testdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003eSELECT * FROM my_table\u003c/code\u003e\u003c/strong\u003e\npeter@localhost testdb-\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\g (format=aligned tuples_only=off expanded=on)\u003c/code\u003e\u003c/strong\u003e\n-[ RECORD 1 ]-\nfirst  | 1\nsecond | one\n-[ RECORD 2 ]-\nfirst  | 2\nsecond | two\n-[ RECORD 3 ]-\nfirst  | 3\nsecond | three\n-[ RECORD 4 ]-\nfirst  | 4\nsecond | four\n\u003c/pre\u003e\n\u003cp\u003eHere is an example of using the \u003ccode\u003e\\df\u003c/code\u003e command to find only functions with names matching \u003ccode\u003eint*pl\u003c/code\u003e and whose second argument is of type \u003ccode\u003ebigint\u003c/code\u003e:\u003c/p\u003e\n\u003cpre\u003etestdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\df int*pl * bigint\u003c/code\u003e\u003c/strong\u003e\n                          List of functions\n   Schema   |  Name   | Result data type | Argument data types | Type\n------------+---------+------------------+---------------------+------\n pg_catalog | int28pl | bigint           | smallint, bigint    | func\n pg_catalog | int48pl | bigint           | integer, bigint     | func\n pg_catalog | int8pl  | bigint           | bigint, bigint      | func\n(3 rows)\n\u003c/pre\u003e\n\u003cp\u003eHere, the \u003ccode\u003e+\u003c/code\u003e option is used to display additional information about one of these functions, and \u003ccode\u003ex\u003c/code\u003e is used to display the results in expanded mode:\u003c/p\u003e\n\u003cpre\u003etestdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\df+x int*pl integer bigint\u003c/code\u003e\u003c/strong\u003e\nList of functions\n-[ RECORD 1 ]-------+-----------------------------\nSchema              | pg_catalog\nName                | int48pl\nResult data type    | bigint\nArgument data types | integer, bigint\nType                | func\nVolatility          | immutable\nParallel            | safe\nOwner               | postgres\nSecurity            | invoker\nLeakproof?          | no\nAccess privileges   |\nLanguage            | internal\nInternal name       | int48pl\nDescription         | implementation of + operator\n\u003c/pre\u003e\n\u003cp\u003eWhen suitable, query results can be shown in a crosstab representation with the \u003ccode\u003e\\crosstabview\u003c/code\u003e command:\u003c/p\u003e\n\u003cpre\u003etestdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003eSELECT first, second, first \u0026gt; 2 AS gt2 FROM my_table;\u003c/code\u003e\u003c/strong\u003e\n first | second | gt2\n-------+--------+-----\n     1 | one    | f\n     2 | two    | f\n     3 | three  | t\n     4 | four   | t\n(4 rows)\n\ntestdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\crosstabview first second\u003c/code\u003e\u003c/strong\u003e\n first | one | two | three | four\n-------+-----+-----+-------+------\n     1 | f   |     |       |\n     2 |     | f   |       |\n     3 |     |     | t     |\n     4 |     |     |       | t\n(4 rows)\n\u003c/pre\u003e\n\u003cp\u003eThis second example shows a multiplication table with rows sorted in reverse numerical order and columns with an independent, ascending numerical order.\u003c/p\u003e\n\u003cpre\u003etestdb=\u0026gt; \u003cstrong\u003e\u003ccode\u003eSELECT t1.first as \u0026#34;A\u0026#34;, t2.first+100 AS \u0026#34;B\u0026#34;, t1.first*(t2.first+100) as \u0026#34;AxB\u0026#34;,\u003c/code\u003e\u003c/strong\u003e\ntestdb-\u0026gt; \u003cstrong\u003e\u003ccode\u003erow_number() over(order by t2.first) AS ord\u003c/code\u003e\u003c/strong\u003e\ntestdb-\u0026gt; \u003cstrong\u003e\u003ccode\u003eFROM my_table t1 CROSS JOIN my_table t2 ORDER BY 1 DESC\u003c/code\u003e\u003c/strong\u003e\ntestdb-\u0026gt; \u003cstrong\u003e\u003ccode\u003e\\crosstabview \u0026#34;A\u0026#34; \u0026#34;B\u0026#34; \u0026#34;AxB\u0026#34; ord\u003c/code\u003e\u003c/strong\u003e\n A | 101 | 102 | 103 | 104\n---+-----+-----+-----+-----\n 4 | 404 | 408 | 412 | 416\n 3 | 303 | 306 | 309 | 312\n 2 | 202 | 204 | 206 | 208\n 1 | 101 | 102 | 103 | 104\n(4 rows)\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","SourceRevision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","ContentHash":"782e64cb5ecfb0a93fab6fe37be83d6bf8cfc8a43be1a90e72fc4d12ca510267","Payload":{"description":["psql — PostgreSQL interactive terminal"],"manual_html":"\u003cdiv\u003e\u003cdiv class=\"refentry\" id=\"APP-PSQL\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\u003c/div\u003e\n\u003cdiv class=\"refnamediv\"\u003e\n\u003ch2\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e — \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e interactive terminal\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsynopsisdiv\"\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.4.21.4.1\"\u003e\u003ccode class=\"command\"\u003epsql\u003c/code\u003e [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...] [\u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e]]\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.21.5\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e is a terminal-based front-end to \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e. It enables you to type in queries interactively, issue them to \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e, and see the query results. Alternatively, input can be from a file or from command line arguments. In addition, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e provides a number of meta-commands and various shell-like features to facilitate writing scripts and automating a wide variety of tasks.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"R1-APP-PSQL-3\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-PSQL-OPTION-ECHO-ALL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-a\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--echo-all\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint all nonempty input lines to standard output as they are read. (This does not apply to lines read interactively.) This is equivalent to setting the variable \u003ccode class=\"varname\"\u003eECHO\u003c/code\u003e to \u003ccode class=\"literal\"\u003eall\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-NO-ALIGN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-A\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-align\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSwitches to unaligned output mode. (The default output mode is \u003ccode class=\"literal\"\u003ealigned\u003c/code\u003e.) This is equivalent to \u003ccode class=\"command\"\u003e\\pset format unaligned\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-ECHO-ERRORS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-b\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--echo-errors\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint failed SQL commands to standard error output. This is equivalent to setting the variable \u003ccode class=\"varname\"\u003eECHO\u003c/code\u003e to \u003ccode class=\"literal\"\u003eerrors\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-COMMAND\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-c \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--command=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies that \u003cspan class=\"application\"\u003epsql\u003c/span\u003e is to execute the given command string, \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e. This option can be repeated and combined in any order with the \u003ccode class=\"option\"\u003e-f\u003c/code\u003e option. When either \u003ccode class=\"option\"\u003e-c\u003c/code\u003e or \u003ccode class=\"option\"\u003e-f\u003c/code\u003e is specified, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e does not read commands from standard input; instead it terminates after processing all the \u003ccode class=\"option\"\u003e-c\u003c/code\u003e and \u003ccode class=\"option\"\u003e-f\u003c/code\u003e options in sequence.\u003c/p\u003e\n\u003cp\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e must be either a command string that is completely parsable by the server (i.e., it contains no \u003cspan class=\"application\"\u003epsql\u003c/span\u003e-specific features), or a single backslash command. Thus you cannot mix SQL and \u003cspan class=\"application\"\u003epsql\u003c/span\u003e meta-commands within a \u003ccode class=\"option\"\u003e-c\u003c/code\u003e option. To achieve that, you could use repeated \u003ccode class=\"option\"\u003e-c\u003c/code\u003e options or pipe the string into \u003cspan class=\"application\"\u003epsql\u003c/span\u003e, for example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003epsql -c '\\x' -c 'SELECT * FROM foo;'\n\u003c/pre\u003e\n\u003cp\u003eor\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eecho '\\x \\\\ SELECT * FROM foo;' | psql\n\u003c/pre\u003e\n\u003cp\u003e(\u003ccode class=\"literal\"\u003e\\\\\u003c/code\u003e is the separator meta-command.)\u003c/p\u003e\n\u003cp\u003eEach SQL command string passed to \u003ccode class=\"option\"\u003e-c\u003c/code\u003e is sent to the server as a single request. Because of this, the server executes it as a single transaction even if the string contains multiple SQL commands, unless there are explicit \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e/\u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e commands included in the string to divide it into multiple transactions. (See \u003ca class=\"xref\" href=\"/docs/18/protocol-flow.html#PROTOCOL-FLOW-MULTI-STATEMENT\" title=\"54.2.2.1. Multiple Statements in a Simple Query\"\u003eSection 54.2.2.1\u003c/a\u003e for more details about how the server handles multi-query strings.)\u003c/p\u003e\n\u003cp\u003eIf having several commands executed in one transaction is not desired, use repeated \u003ccode class=\"option\"\u003e-c\u003c/code\u003e commands or feed multiple commands to \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's standard input, either using \u003cspan class=\"application\"\u003eecho\u003c/span\u003e as illustrated above, or via a shell here-document, for example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003epsql \u0026lt;\u0026lt;EOF\n\\x\nSELECT * FROM foo;\nEOF\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-CSV\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--csv\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSwitches to CSV (Comma-Separated Values) output mode. This is equivalent to \u003ccode class=\"command\"\u003e\\pset format csv\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-DBNAME\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-d \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--dbname=\u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the name of the database to connect to. This is equivalent to specifying \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e as the first non-option argument on the command line. The \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e can be a \u003ca class=\"link\" href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"32.1.1. Connection Strings\"\u003econnection string\u003c/a\u003e. If so, connection string parameters will override any conflicting command line options.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-ECHO-QUERIES\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--echo-queries\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCopy all SQL commands sent to the server to standard output as well. This is equivalent to setting the variable \u003ccode class=\"varname\"\u003eECHO\u003c/code\u003e to \u003ccode class=\"literal\"\u003equeries\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-ECHO-HIDDEN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-E\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--echo-hidden\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEcho the actual queries generated by \u003ccode class=\"command\"\u003e\\d\u003c/code\u003e and other backslash commands. You can use this to study \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's internal operations. This is equivalent to setting the variable \u003ccode class=\"varname\"\u003eECHO_HIDDEN\u003c/code\u003e to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-FILE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-f \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--file=\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRead commands from the file \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e, rather than standard input. This option can be repeated and combined in any order with the \u003ccode class=\"option\"\u003e-c\u003c/code\u003e option. When either \u003ccode class=\"option\"\u003e-c\u003c/code\u003e or \u003ccode class=\"option\"\u003e-f\u003c/code\u003e is specified, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e does not read commands from standard input; instead it terminates after processing all the \u003ccode class=\"option\"\u003e-c\u003c/code\u003e and \u003ccode class=\"option\"\u003e-f\u003c/code\u003e options in sequence. Except for that, this option is largely equivalent to the meta-command \u003ccode class=\"command\"\u003e\\i\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eIf \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e is \u003ccode class=\"literal\"\u003e-\u003c/code\u003e (hyphen), then standard input is read until an EOF indication or \u003ccode class=\"command\"\u003e\\q\u003c/code\u003e meta-command. This can be used to intersperse interactive input with input from files. Note however that Readline is not used in this case (much as if \u003ccode class=\"option\"\u003e-n\u003c/code\u003e had been specified).\u003c/p\u003e\n\u003cp\u003eUsing this option is subtly different from writing \u003ccode class=\"literal\"\u003epsql \u0026lt; \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e. In general, both will do what you expect, but using \u003ccode class=\"literal\"\u003e-f\u003c/code\u003e enables some nice features such as error messages with line numbers. There is also a slight chance that using this option will reduce the start-up overhead. On the other hand, the variant using the shell's input redirection is (in theory) guaranteed to yield exactly the same output you would have received had you entered everything by hand.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-FIELD-SEPARATOR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-F \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseparator\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--field-separator=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eseparator\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUse \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseparator\u003c/code\u003e\u003c/em\u003e as the field separator for unaligned output. This is equivalent to \u003ccode class=\"command\"\u003e\\pset fieldsep\u003c/code\u003e or \u003ccode class=\"command\"\u003e\\f\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-FIELD-HOST\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-h \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehostname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--host=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ehostname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix-domain socket.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-HTML\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-H\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--html\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSwitches to HTML output mode. This is equivalent to \u003ccode class=\"command\"\u003e\\pset format html\u003c/code\u003e or the \u003ccode class=\"command\"\u003e\\H\u003c/code\u003e command.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-LIST\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-l\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--list\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eList all available databases, then exit. Other non-connection options are ignored. This is similar to the meta-command \u003ccode class=\"command\"\u003e\\list\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eWhen this option is used, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will connect to the database \u003ccode class=\"literal\"\u003epostgres\u003c/code\u003e, unless a different database is named on the command line (option \u003ccode class=\"option\"\u003e-d\u003c/code\u003e or non-option argument, possibly via a service entry, but not via an environment variable).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-LOG-FILE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-L \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--log-file=\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWrite all query output into file \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e, in addition to the normal output destination.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-NO-READLINE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-readline\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not use \u003cspan class=\"application\"\u003eReadline\u003c/span\u003e for line editing and do not use the command history (see \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-READLINE\" title=\"Command-Line Editing\"\u003ethe section called “Command-Line Editing”\u003c/a\u003e below).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-OUTPUT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-o \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--output=\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePut all query output into file \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e. This is equivalent to the command \u003ccode class=\"command\"\u003e\\o\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-PORT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-p \u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--port=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the TCP port or the local Unix-domain socket file extension on which the server is listening for connections. Defaults to the value of the \u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e environment variable or, if not set, to the port specified at compile time, usually 5432.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-PSET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-P \u003cem class=\"replaceable\"\u003e\u003ccode\u003eassignment\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--pset=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eassignment\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies printing options, in the style of \u003ccode class=\"command\"\u003e\\pset\u003c/code\u003e. Note that here you have to separate name and value with an equal sign instead of a space. For example, to set the output format to \u003cspan class=\"application\"\u003eLaTeX\u003c/span\u003e, you could write \u003ccode class=\"literal\"\u003e-P format=latex\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-QUIET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-q\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--quiet\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies that \u003cspan class=\"application\"\u003epsql\u003c/span\u003e should do its work quietly. By default, it prints welcome messages and various informational output. If this option is used, none of this happens. This is useful with the \u003ccode class=\"option\"\u003e-c\u003c/code\u003e option. This is equivalent to setting the variable \u003ccode class=\"varname\"\u003eQUIET\u003c/code\u003e to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-RECORD-SEPARATOR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-R \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseparator\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--record-separator=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eseparator\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUse \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseparator\u003c/code\u003e\u003c/em\u003e as the record separator for unaligned output. This is equivalent to \u003ccode class=\"command\"\u003e\\pset recordsep\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-SINGLE-STEP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-s\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--single-step\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRun in single-step mode. That means the user is prompted before each command is sent to the server, with the option to cancel execution as well. Use this to debug scripts.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-SINGLE-LINE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-S\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--single-line\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRuns in single-line mode where a newline terminates an SQL command, as a semicolon does.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis mode is provided for those who insist on it, but you are not necessarily encouraged to use it. In particular, if you mix SQL and meta-commands on a line the order of execution might not always be clear to the inexperienced user.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-TUPLES-ONLY\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-t\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--tuples-only\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eTurn off printing of column names and result row count footers, etc. This is equivalent to \u003ccode class=\"command\"\u003e\\t\u003c/code\u003e or \u003ccode class=\"command\"\u003e\\pset tuples_only\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-TABLE-ATTR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-T \u003cem class=\"replaceable\"\u003e\u003ccode\u003etable_options\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--table-attr=\u003cem class=\"replaceable\"\u003e\u003ccode\u003etable_options\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies options to be placed within the HTML \u003ccode class=\"sgmltag-element\"\u003etable\u003c/code\u003e tag. See \u003ccode class=\"command\"\u003e\\pset tableattr\u003c/code\u003e for details.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-USERNAME\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-U \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--username=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eConnect to the database as the user \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e instead of the default. (You must have permission to do so, of course.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-VARIABLE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-v \u003cem class=\"replaceable\"\u003e\u003ccode\u003eassignment\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--set=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eassignment\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--variable=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eassignment\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePerform a variable assignment, like the \u003ccode class=\"command\"\u003e\\set\u003c/code\u003e meta-command. Note that you must separate name and value, if any, by an equal sign on the command line. To unset a variable, leave off the equal sign. To set a variable with an empty value, use the equal sign but leave off the value. These assignments are done during command line processing, so variables that reflect connection state will get overwritten later.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-VERSION\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--version\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e version and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-NO-PASSWORD\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-w\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-password\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eNever issue a password prompt. If the server requires password authentication and a password is not available from other sources such as a \u003ccode class=\"filename\"\u003e.pgpass\u003c/code\u003e file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password.\u003c/p\u003e\n\u003cp\u003eNote that this option will remain set for the entire session, and so it affects uses of the meta-command \u003ccode class=\"command\"\u003e\\connect\u003c/code\u003e as well as the initial connection attempt.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-PASSWORD\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-W\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--password\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eForce \u003cspan class=\"application\"\u003epsql\u003c/span\u003e to prompt for a password before connecting to a database, even if the password will not be used.\u003c/p\u003e\n\u003cp\u003eIf the server requires password authentication and a password is not available from other sources such as a \u003ccode class=\"filename\"\u003e.pgpass\u003c/code\u003e file, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will prompt for a password in any case. However, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing \u003ccode class=\"option\"\u003e-W\u003c/code\u003e to avoid the extra connection attempt.\u003c/p\u003e\n\u003cp\u003eNote that this option will remain set for the entire session, and so it affects uses of the meta-command \u003ccode class=\"command\"\u003e\\connect\u003c/code\u003e as well as the initial connection attempt.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-EXPANDED\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-x\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--expanded\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eTurn on the expanded table formatting mode. This is equivalent to \u003ccode class=\"command\"\u003e\\x\u003c/code\u003e or \u003ccode class=\"command\"\u003e\\pset expanded\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-NO-PSQLRC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-X\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-psqlrc\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not read the start-up file (neither the system-wide \u003ccode class=\"filename\"\u003epsqlrc\u003c/code\u003e file nor the user's \u003ccode class=\"filename\"\u003e~/.psqlrc\u003c/code\u003e file).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-FIELD-SEPARATOR-ZERO\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-z\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--field-separator-zero\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSet the field separator for unaligned output to a zero byte. This is equivalent to \u003ccode class=\"command\"\u003e\\pset fieldsep_zero\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-RECORD-SEPARATOR-ZERO\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-0\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--record-separator-zero\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSet the record separator for unaligned output to a zero byte. This is useful for interfacing, for example, with \u003ccode class=\"literal\"\u003exargs -0\u003c/code\u003e. This is equivalent to \u003ccode class=\"command\"\u003e\\pset recordsep_zero\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-SINGLE-TRANSACTION\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-1\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--single-transaction\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option can only be used in combination with one or more \u003ccode class=\"option\"\u003e-c\u003c/code\u003e and/or \u003ccode class=\"option\"\u003e-f\u003c/code\u003e options. It causes \u003cspan class=\"application\"\u003epsql\u003c/span\u003e to issue a \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e command before the first such option and a \u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e command after the last one, thereby wrapping all the commands into a single transaction. If any of the commands fails and the variable \u003ccode class=\"varname\"\u003eON_ERROR_STOP\u003c/code\u003e was set, a \u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e command is sent instead. This ensures that either all the commands complete successfully, or no changes are applied.\u003c/p\u003e\n\u003cp\u003eIf the commands themselves contain \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e, \u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e, or \u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e, this option will not have the desired effects. Also, if an individual command cannot be executed inside a transaction block, specifying this option will cause the whole transaction to fail.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-OPTION-HELP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--help[=\u003cem class=\"replaceable\"\u003e\u003ccode\u003etopic\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow help about \u003cspan class=\"application\"\u003epsql\u003c/span\u003e and exit. The optional \u003cem class=\"replaceable\"\u003e\u003ccode\u003etopic\u003c/code\u003e\u003c/em\u003e parameter (defaulting to \u003ccode class=\"literal\"\u003eoptions\u003c/code\u003e) selects which part of \u003cspan class=\"application\"\u003epsql\u003c/span\u003e is explained: \u003ccode class=\"literal\"\u003ecommands\u003c/code\u003e describes \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's backslash commands; \u003ccode class=\"literal\"\u003eoptions\u003c/code\u003e describes the command-line options that can be passed to \u003cspan class=\"application\"\u003epsql\u003c/span\u003e; and \u003ccode class=\"literal\"\u003evariables\u003c/code\u003e shows help about \u003cspan class=\"application\"\u003epsql\u003c/span\u003e configuration variables.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.21.7\"\u003e\n\u003ch2\u003eExit Status\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e returns 0 to the shell if it finished normally, 1 if a fatal error of its own occurs (e.g., out of memory, file not found), 2 if the connection to the server went bad and the session was not interactive, and 3 if an error occurred in a script and the variable \u003ccode class=\"varname\"\u003eON_ERROR_STOP\u003c/code\u003e was set.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.21.8\"\u003e\n\u003ch2\u003eUsage\u003c/h2\u003e\n\u003cdiv class=\"refsect2\" id=\"R2-APP-PSQL-CONNECTING\"\u003e\n\u003ch3\u003eConnecting to a Database\u003c/h3\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e is a regular \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e client application. In order to connect to a database you need to know the name of your target database, the host name and port number of the server, and what database user name you want to connect as. \u003cspan class=\"application\"\u003epsql\u003c/span\u003e can be told about those parameters via command line options, namely \u003ccode class=\"option\"\u003e-d\u003c/code\u003e, \u003ccode class=\"option\"\u003e-h\u003c/code\u003e, \u003ccode class=\"option\"\u003e-p\u003c/code\u003e, and \u003ccode class=\"option\"\u003e-U\u003c/code\u003e respectively. If an argument is found that does not belong to any option it will be interpreted as the database name (or the database user name, if the database name is already given). Not all of these options are required; there are useful defaults. If you omit the host name, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will connect via a Unix-domain socket to a server on the local host, or via TCP/IP to \u003ccode class=\"literal\"\u003elocalhost\u003c/code\u003e on Windows. The default port number is determined at compile time. Since the database server uses the same default, you will not have to specify the port in most cases. The default database user name is your operating-system user name. Once the database user name is determined, it is used as the default database name. Note that you cannot just connect to any database under any database user name. Your database administrator should have informed you about your access rights.\u003c/p\u003e\n\u003cp\u003eWhen the defaults aren't quite right, you can save yourself some typing by setting the environment variables \u003ccode class=\"envar\"\u003ePGDATABASE\u003c/code\u003e, \u003ccode class=\"envar\"\u003ePGHOST\u003c/code\u003e, \u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e and/or \u003ccode class=\"envar\"\u003ePGUSER\u003c/code\u003e to appropriate values. (For additional environment variables, see \u003ca class=\"xref\" href=\"/docs/18/libpq-envars.html\" title=\"32.15. Environment Variables\"\u003eSection 32.15\u003c/a\u003e.) It is also convenient to have a \u003ccode class=\"filename\"\u003e~/.pgpass\u003c/code\u003e file to avoid regularly having to type in passwords. See \u003ca class=\"xref\" href=\"/docs/18/libpq-pgpass.html\" title=\"32.16. The Password File\"\u003eSection 32.16\u003c/a\u003e for more information.\u003c/p\u003e\n\u003cp\u003eAn alternative way to specify connection parameters is in a \u003cem class=\"parameter\"\u003e\u003ccode\u003econninfo\u003c/code\u003e\u003c/em\u003e string or a URI, which is used instead of a database name. This mechanism give you very wide control over the connection. For example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e$ \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epsql \"service=myservice sslmode=require\"\u003c/code\u003e\u003c/strong\u003e\n$ \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epsql postgresql://dbmaster:5433/mydb?sslmode=require\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eThis way you can also use LDAP for connection parameter lookup as described in \u003ca class=\"xref\" href=\"/docs/18/libpq-ldap.html\" title=\"32.18. LDAP Lookup of Connection Parameters\"\u003eSection 32.18\u003c/a\u003e. See \u003ca class=\"xref\" href=\"/docs/18/libpq-connect.html#LIBPQ-PARAMKEYWORDS\" title=\"32.1.2. Parameter Key Words\"\u003eSection 32.1.2\u003c/a\u003e for more information on all the available connection options.\u003c/p\u003e\n\u003cp\u003eIf the connection could not be made for any reason (e.g., insufficient privileges, server is not running on the targeted host, etc.), \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will return an error and terminate.\u003c/p\u003e\n\u003cp\u003eIf both standard input and standard output are a terminal, then \u003cspan class=\"application\"\u003epsql\u003c/span\u003e sets the client encoding to \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eauto\u003c/span\u003e”\u003c/span\u003e, which will detect the appropriate client encoding from the locale settings (\u003ccode class=\"envar\"\u003eLC_CTYPE\u003c/code\u003e environment variable on Unix systems). If this doesn't work out as expected, the client encoding can be overridden using the environment variable \u003ccode class=\"envar\"\u003ePGCLIENTENCODING\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"R2-APP-PSQL-4\"\u003e\n\u003ch3\u003eEntering SQL Commands\u003c/h3\u003e\n\u003cp\u003eIn normal operation, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e provides a prompt with the name of the database to which \u003cspan class=\"application\"\u003epsql\u003c/span\u003e is currently connected, followed by the string \u003ccode class=\"literal\"\u003e=\u0026gt;\u003c/code\u003e. For example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e$ \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epsql testdb\u003c/code\u003e\u003c/strong\u003e\npsql (18.6)\nType \"help\" for help.\n\ntestdb=\u0026gt;\n\u003c/pre\u003e\n\u003cp\u003eAt the prompt, the user can type in SQL commands. Ordinarily, input lines are sent to the server when a command-terminating semicolon is reached. An end of line does not terminate a command. Thus commands can be spread over several lines for clarity. If the command was sent and executed without error, the results of the command are displayed on the screen.\u003c/p\u003e\n\u003cp\u003eIf untrusted users have access to a database that has not adopted a \u003ca class=\"link\" href=\"/docs/18/ddl-schemas.html#DDL-SCHEMAS-PATTERNS\" title=\"5.10.6. Usage Patterns\"\u003esecure schema usage pattern\u003c/a\u003e, begin your session by removing publicly-writable schemas from \u003ccode class=\"varname\"\u003esearch_path\u003c/code\u003e. One can add \u003ccode class=\"literal\"\u003eoptions=-csearch_path=\u003c/code\u003e to the connection string or issue \u003ccode class=\"literal\"\u003eSELECT pg_catalog.set_config('search_path', '', false)\u003c/code\u003e before other SQL commands. This consideration is not specific to \u003cspan class=\"application\"\u003epsql\u003c/span\u003e; it applies to every interface for executing arbitrary SQL commands.\u003c/p\u003e\n\u003cp\u003eWhenever a command is executed, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e also polls for asynchronous notification events generated by \u003ca class=\"link\" href=\"/docs/18/sql-listen.html\" title=\"LISTEN\"\u003e\u003ccode class=\"command\"\u003eLISTEN\u003c/code\u003e\u003c/a\u003e and \u003ca class=\"link\" href=\"/docs/18/sql-notify.html\" title=\"NOTIFY\"\u003e\u003ccode class=\"command\"\u003eNOTIFY\u003c/code\u003e\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eWhile C-style block comments are passed to the server for processing and removal, SQL-standard comments are removed by \u003cspan class=\"application\"\u003epsql\u003c/span\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"APP-PSQL-META-COMMANDS\"\u003e\n\u003ch3\u003eMeta-Commands\u003c/h3\u003e\n\u003cp\u003eAnything you enter in \u003cspan class=\"application\"\u003epsql\u003c/span\u003e that begins with an unquoted backslash is a \u003cspan class=\"application\"\u003epsql\u003c/span\u003e meta-command that is processed by \u003cspan class=\"application\"\u003epsql\u003c/span\u003e itself. These commands make \u003cspan class=\"application\"\u003epsql\u003c/span\u003e more useful for administration or scripting. Meta-commands are often called slash or backslash commands.\u003c/p\u003e\n\u003cp\u003eThe format of a \u003cspan class=\"application\"\u003epsql\u003c/span\u003e command is the backslash, followed immediately by a command verb, then any arguments. The arguments are separated from the command verb and each other by any number of whitespace characters.\u003c/p\u003e\n\u003cp\u003eTo include whitespace in an argument you can quote it with single quotes. To include a single quote in an argument, write two single quotes within single-quoted text. Anything contained in single quotes is furthermore subject to C-like substitutions for \u003ccode class=\"literal\"\u003e\\n\u003c/code\u003e (new line), \u003ccode class=\"literal\"\u003e\\t\u003c/code\u003e (tab), \u003ccode class=\"literal\"\u003e\\b\u003c/code\u003e (backspace), \u003ccode class=\"literal\"\u003e\\r\u003c/code\u003e (carriage return), \u003ccode class=\"literal\"\u003e\\f\u003c/code\u003e (form feed), \u003ccode class=\"literal\"\u003e\\\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003edigits\u003c/code\u003e\u003c/em\u003e (octal), and \u003ccode class=\"literal\"\u003e\\x\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003edigits\u003c/code\u003e\u003c/em\u003e (hexadecimal). A backslash preceding any other character within single-quoted text quotes that single character, whatever it is.\u003c/p\u003e\n\u003cp\u003eIf an unquoted colon (\u003ccode class=\"literal\"\u003e:\u003c/code\u003e) followed by a \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variable name appears within an argument, it is replaced by the variable's value, as described in \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-INTERPOLATION\" title=\"SQL Interpolation\"\u003eSQL Interpolation\u003c/a\u003e below. The forms \u003ccode class=\"literal\"\u003e:'\u003cem class=\"replaceable\"\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e'\u003c/code\u003e and \u003ccode class=\"literal\"\u003e:\"\u003cem class=\"replaceable\"\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e\"\u003c/code\u003e described there work as well. The \u003ccode class=\"literal\"\u003e:{?\u003cem class=\"replaceable\"\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e}\u003c/code\u003e syntax allows testing whether a variable is defined. It is substituted by TRUE or FALSE. Escaping the colon with a backslash protects it from substitution.\u003c/p\u003e\n\u003cp\u003eWithin an argument, text that is enclosed in backquotes (\u003ccode class=\"literal\"\u003e`\u003c/code\u003e) is taken as a command line that is passed to the shell. The output of the command (with any trailing newline removed) replaces the backquoted text. Within the text enclosed in backquotes, no special quoting or other processing occurs, except that appearances of \u003ccode class=\"literal\"\u003e:\u003cem class=\"replaceable\"\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e where \u003cem class=\"replaceable\"\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e is a \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variable name are replaced by the variable's value. Also, appearances of \u003ccode class=\"literal\"\u003e:'\u003cem class=\"replaceable\"\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e'\u003c/code\u003e are replaced by the variable's value suitably quoted to become a single shell command argument. (The latter form is almost always preferable, unless you are very sure of what is in the variable.) Because carriage return and line feed characters cannot be safely quoted on all platforms, the \u003ccode class=\"literal\"\u003e:'\u003cem class=\"replaceable\"\u003e\u003ccode\u003evariable_name\u003c/code\u003e\u003c/em\u003e'\u003c/code\u003e form prints an error message and does not substitute the variable value when such characters appear in the value.\u003c/p\u003e\n\u003cp\u003eSome commands take an SQL identifier (such as a table name) as argument. These arguments follow the syntax rules of SQL: Unquoted letters are forced to lowercase, while double quotes (\u003ccode class=\"literal\"\u003e\"\u003c/code\u003e) protect letters from case conversion and allow incorporation of whitespace into the identifier. Within double quotes, paired double quotes reduce to a single double quote in the resulting name. For example, \u003ccode class=\"literal\"\u003eFOO\"BAR\"BAZ\u003c/code\u003e is interpreted as \u003ccode class=\"literal\"\u003efooBARbaz\u003c/code\u003e, and \u003ccode class=\"literal\"\u003e\"A weird\"\" name\"\u003c/code\u003e becomes \u003ccode class=\"literal\"\u003eA weird\" name\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eParsing for arguments stops at the end of the line, or when another unquoted backslash is found. An unquoted backslash is taken as the beginning of a new meta-command. The special sequence \u003ccode class=\"literal\"\u003e\\\\\u003c/code\u003e (two backslashes) marks the end of arguments and continues parsing SQL commands, if any. That way SQL and \u003cspan class=\"application\"\u003epsql\u003c/span\u003e commands can be freely mixed on a line. But in any case, the arguments of a meta-command cannot continue beyond the end of the line.\u003c/p\u003e\n\u003cp\u003eMany of the meta-commands act on the \u003cem class=\"firstterm\"\u003ecurrent query buffer\u003c/em\u003e. This is simply a buffer holding whatever SQL command text has been typed but not yet sent to the server for execution. This will include previous input lines as well as any text appearing before the meta-command on the same line.\u003c/p\u003e\n\u003cp\u003eMany of the meta-commands also allow \u003ccode class=\"literal\"\u003ex\u003c/code\u003e to be appended as an option. This will cause the results to be displayed in expanded mode, as if \u003ccode class=\"command\"\u003e\\x\u003c/code\u003e or \u003ccode class=\"command\"\u003e\\pset expanded\u003c/code\u003e had been used.\u003c/p\u003e\n\u003cp\u003eThe following meta-commands are defined:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-A\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\a\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf 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 \u003ccode class=\"command\"\u003e\\pset\u003c/code\u003e for a more general solution.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-BIND\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\bind\u003c/code\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e ] ...\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets query parameters for the next query execution, with the specified parameters passed for any parameter placeholders (\u003ccode class=\"literal\"\u003e$1\u003c/code\u003e etc.).\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eINSERT INTO tbl1 VALUES ($1, $2) \\bind 'first value' 'second value' \\g\n\u003c/pre\u003e\n\u003cp\u003eThis also works for query-execution commands besides \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e, such as \u003ccode class=\"literal\"\u003e\\gx\u003c/code\u003e and \u003ccode class=\"literal\"\u003e\\gset\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThis command causes the extended query protocol (see \u003ca class=\"xref\" href=\"/docs/18/protocol-overview.html#PROTOCOL-QUERY-CONCEPTS\" title=\"54.1.2. Extended Query Overview\"\u003eSection 54.1.2\u003c/a\u003e) to be used, unlike normal \u003cspan class=\"application\"\u003epsql\u003c/span\u003e operation, which uses the simple query protocol. So this command can be useful to test the extended query protocol from \u003cspan class=\"application\"\u003epsql\u003c/span\u003e. (The extended query protocol is used even if the query has no parameters and this command specifies zero parameters.) This command affects only the next query executed; all subsequent queries will use the simple query protocol by default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-BIND-NAMED\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\bind_named\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003estatement_name\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eparameter\u003c/code\u003e\u003c/em\u003e ] ...\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e\\bind_named\u003c/code\u003e is equivalent to \u003ccode class=\"literal\"\u003e\\bind\u003c/code\u003e, except that it takes the name of an existing prepared statement as first parameter. An empty string denotes the unnamed prepared statement.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eINSERT INTO tbls1 VALUES ($1, $2) \\parse stmt1\n\\bind_named stmt1 'first value' 'second value' \\g\n\u003c/pre\u003e\n\u003cp\u003eThis command causes the extended query protocol (see \u003ca class=\"xref\" href=\"/docs/18/protocol-overview.html#PROTOCOL-QUERY-CONCEPTS\" title=\"54.1.2. Extended Query Overview\"\u003eSection 54.1.2\u003c/a\u003e) to be used, unlike normal \u003cspan class=\"application\"\u003epsql\u003c/span\u003e operation, which uses the simple query protocol. So this command can be useful to test the extended query protocol from \u003cspan class=\"application\"\u003epsql\u003c/span\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-C-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\c\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\connect [ -reuse-previous=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eon|off\u003c/code\u003e\u003c/em\u003e ] [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e ] [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e ] [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e ] | \u003cem class=\"replaceable\"\u003e\u003ccode\u003econninfo\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEstablishes a new connection to a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 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 \u003cem class=\"replaceable\"\u003e\u003ccode\u003econninfo\u003c/code\u003e\u003c/em\u003e connection string as detailed in \u003ca class=\"xref\" href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"32.1.1. Connection Strings\"\u003eSection 32.1.1\u003c/a\u003e. If no arguments are given, a new connection is made using the same parameters as before.\u003c/p\u003e\n\u003cp\u003eSpecifying any of \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e, \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e or \u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e as \u003ccode class=\"literal\"\u003e-\u003c/code\u003e is equivalent to omitting that parameter.\u003c/p\u003e\n\u003cp\u003eThe new connection can re-use connection parameters from the previous connection; not only database name, user, host, and port, but other settings such as \u003cem class=\"replaceable\"\u003e\u003ccode\u003esslmode\u003c/code\u003e\u003c/em\u003e. By default, parameters are re-used in the positional syntax, but not when a \u003cem class=\"replaceable\"\u003e\u003ccode\u003econninfo\u003c/code\u003e\u003c/em\u003e string is given. Passing a first argument of \u003ccode class=\"literal\"\u003e-reuse-previous=on\u003c/code\u003e or \u003ccode class=\"literal\"\u003e-reuse-previous=off\u003c/code\u003e overrides that default. If parameters are re-used, then any parameter not explicitly specified as a positional parameter or in the \u003cem class=\"replaceable\"\u003e\u003ccode\u003econninfo\u003c/code\u003e\u003c/em\u003e string is taken from the existing connection's parameters. An exception is that if the \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e setting is changed from its previous value using the positional syntax, any \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehostaddr\u003c/code\u003e\u003c/em\u003e setting present in the existing connection's parameters is dropped. Also, any password used for the existing connection will be re-used only if the user, host, and port settings are not changed. When the command neither specifies nor reuses a particular parameter, the \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e default is used.\u003c/p\u003e\n\u003cp\u003eIf the new connection is successfully made, the previous connection is closed. If the connection attempt fails (wrong user name, access denied, etc.), the previous connection will be kept if \u003cspan class=\"application\"\u003epsql\u003c/span\u003e is in interactive mode. But when executing a non-interactive script, the old connection is closed and an error is reported. That may or may not terminate the script; if it does not, all database-accessing commands will fail until another \u003ccode class=\"literal\"\u003e\\connect\u003c/code\u003e command is successfully executed. 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. Note that whenever a \u003ccode class=\"literal\"\u003e\\connect\u003c/code\u003e command attempts to re-use parameters, the values re-used are those of the last successful connection, not of any failed attempts made subsequently. However, in the case of a non-interactive \u003ccode class=\"literal\"\u003e\\connect\u003c/code\u003e failure, no parameters are allowed to be re-used later, since the script would likely be expecting the values from the failed \u003ccode class=\"literal\"\u003e\\connect\u003c/code\u003e to be re-used.\u003c/p\u003e\n\u003cp\u003eExamples:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e=\u0026gt; \\c mydb myuser host.dom 6432\n=\u0026gt; \\c service=foo\n=\u0026gt; \\c \"host=localhost port=5432 dbname=mydb connect_timeout=10 sslmode=disable\"\n=\u0026gt; \\c -reuse-previous=on sslmode=require    -- changes only sslmode\n=\u0026gt; \\c postgresql://tom@localhost/mydb?application_name=myapp\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-C-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\C [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003etitle\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the title of any tables being printed as the result of a query or unset any such title. This command is equivalent to \u003ccode class=\"literal\"\u003e\\pset title \u003cem class=\"replaceable\"\u003e\u003ccode\u003etitle\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e. (The name of this command derives from \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003ecaption\u003c/span\u003e”\u003c/span\u003e, as it was previously only used to set the caption in an HTML table.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-CD\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\cd [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eChanges the current working directory to \u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e. Without argument, changes to the current user's home directory. For details on how home directories are found, see \u003ca class=\"xref\" href=\"/docs/18/libpq-pgpass.html\" title=\"32.16. The Password File\"\u003eSection 32.16\u003c/a\u003e.\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eTo print your current working directory, use \u003ccode class=\"literal\"\u003e\\! pwd\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-CLOSE-PREPARED\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\close_prepared\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eprepared_statement_name\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCloses 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.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT $1 \\parse stmt1\n\\close_prepared stmt1\n\u003c/pre\u003e\n\u003cp\u003eThis command causes the extended query protocol to be used, unlike normal \u003cspan class=\"application\"\u003epsql\u003c/span\u003e operation, which uses the simple query protocol. So this command can be useful to test the extended query protocol from \u003cspan class=\"application\"\u003epsql\u003c/span\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-CONNINFO\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\conninfo\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eOutputs information about the current database connection, including SSL-related information if SSL is in use.\u003c/p\u003e\n\u003cp\u003eNote that the \u003ccode class=\"structfield\"\u003eClient User\u003c/code\u003e field shows the user at the time of connection, while the \u003ccode class=\"structfield\"\u003eSuperuser\u003c/code\u003e field indicates whether the current user (in the current execution context) has superuser privileges. These users are usually the same, but they can differ, for example, if the current user was changed with the \u003ccode class=\"command\"\u003eSET ROLE\u003c/code\u003e command.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMANDS-COPY\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\copy { \u003cem class=\"replaceable\"\u003e\u003ccode\u003etable\u003c/code\u003e\u003c/em\u003e [ ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolumn_list\u003c/code\u003e\u003c/em\u003e ) ] } \u003ccode class=\"literal\"\u003efrom\u003c/code\u003e { \u003cem class=\"replaceable\"\u003e\u003ccode\u003e'filename'\u003c/code\u003e\u003c/em\u003e | program \u003cem class=\"replaceable\"\u003e\u003ccode\u003e'command'\u003c/code\u003e\u003c/em\u003e | stdin | pstdin } [ [ with ] ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e [, ...] ) ] [ where \u003cem class=\"replaceable\"\u003e\u003ccode\u003econdition\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\copy { \u003cem class=\"replaceable\"\u003e\u003ccode\u003etable\u003c/code\u003e\u003c/em\u003e [ ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolumn_list\u003c/code\u003e\u003c/em\u003e ) ] | ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003equery\u003c/code\u003e\u003c/em\u003e ) } \u003ccode class=\"literal\"\u003eto\u003c/code\u003e { \u003cem class=\"replaceable\"\u003e\u003ccode\u003e'filename'\u003c/code\u003e\u003c/em\u003e | program \u003cem class=\"replaceable\"\u003e\u003ccode\u003e'command'\u003c/code\u003e\u003c/em\u003e | stdout | pstdout } [ [ with ] ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e [, ...] ) ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePerforms a frontend (client) copy. This is an operation that runs an SQL \u003ca class=\"link\" href=\"/docs/18/sql-copy.html\" title=\"COPY\"\u003e\u003ccode class=\"command\"\u003eCOPY\u003c/code\u003e\u003c/a\u003e command, but instead of the server reading or writing the specified file, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e 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.\u003c/p\u003e\n\u003cp\u003eWhen \u003ccode class=\"literal\"\u003eprogram\u003c/code\u003e is specified, \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e is executed by \u003cspan class=\"application\"\u003epsql\u003c/span\u003e and the data passed from or to \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e is routed between the server and the client. Again, the execution privileges are those of the local user, not the server, and no SQL superuser privileges are required.\u003c/p\u003e\n\u003cp\u003eFor \u003ccode class=\"literal\"\u003e\\copy ... from stdin\u003c/code\u003e, data rows are read from the same source that issued the command, continuing until a line containing only \u003ccode class=\"literal\"\u003e\\.\u003c/code\u003e is read or the stream reaches EOF. This option is useful for populating tables in-line within an SQL script file. For \u003ccode class=\"literal\"\u003e\\copy ... to stdout\u003c/code\u003e, output is sent to the same place as \u003cspan class=\"application\"\u003epsql\u003c/span\u003e command output, and the \u003ccode class=\"literal\"\u003eCOPY \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e command status is not printed (since it might be confused with a data row). To read/write \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's standard input or output regardless of the current command source or \u003ccode class=\"literal\"\u003e\\o\u003c/code\u003e option, write \u003ccode class=\"literal\"\u003efrom pstdin\u003c/code\u003e or \u003ccode class=\"literal\"\u003eto pstdout\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe syntax of this command is similar to that of the SQL \u003ca class=\"link\" href=\"/docs/18/sql-copy.html\" title=\"COPY\"\u003e\u003ccode class=\"command\"\u003eCOPY\u003c/code\u003e\u003c/a\u003e command. All options other than the data source/destination are as specified for \u003ccode class=\"command\"\u003eCOPY\u003c/code\u003e. Because of this, special parsing rules apply to the \u003ccode class=\"command\"\u003e\\copy\u003c/code\u003e meta-command. Unlike most other meta-commands, the entire remainder of the line is always taken to be the arguments of \u003ccode class=\"command\"\u003e\\copy\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments.\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eAnother way to obtain the same result as \u003ccode class=\"literal\"\u003e\\copy ... to\u003c/code\u003e is to use the SQL \u003ccode class=\"literal\"\u003eCOPY ... TO STDOUT\u003c/code\u003e command and terminate it with \u003ccode class=\"literal\"\u003e\\g \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\g |\u003cem class=\"replaceable\"\u003e\u003ccode\u003eprogram\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e. Unlike \u003ccode class=\"literal\"\u003e\\copy\u003c/code\u003e, this method allows the command to span multiple lines; also, variable interpolation and backquote expansion can be used.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eThese operations are not as efficient as the SQL \u003ccode class=\"command\"\u003eCOPY\u003c/code\u003e command with a file or program data source or destination, because all data must pass through the client/server connection. For large amounts of data the SQL command might be preferable.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-COPYRIGHT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\copyright\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShows the copyright and distribution terms of \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMANDS-CROSSTABVIEW\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\crosstabview [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolD\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003esortcolH\u003c/code\u003e\u003c/em\u003e ] ] ] ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eExecutes the current query buffer (like \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e) and shows the results in a crosstab grid. The query must return at least three columns. The output column identified by \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e becomes a vertical header and the output column identified by \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e becomes a horizontal header. \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolD\u003c/code\u003e\u003c/em\u003e identifies the output column to display within the grid. \u003cem class=\"replaceable\"\u003e\u003ccode\u003esortcolH\u003c/code\u003e\u003c/em\u003e identifies an optional sort column for the horizontal header.\u003c/p\u003e\n\u003cp\u003eEach column specification can be a column number (starting at 1) or a column name. The usual SQL case folding and quoting rules apply to column names. If omitted, \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e is taken as column 1 and \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e as column 2. \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e must differ from \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolD\u003c/code\u003e\u003c/em\u003e is not specified, then there must be exactly three columns in the query result, and the column that is neither \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e nor \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e is taken to be \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolD\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eThe vertical header, displayed as the leftmost column, contains the values found in column \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e, in the same order as in the query results, but with duplicates removed.\u003c/p\u003e\n\u003cp\u003eThe horizontal header, displayed as the first row, contains the values found in column \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e, with duplicates removed. By default, these appear in the same order as in the query results. But if the optional \u003cem class=\"replaceable\"\u003e\u003ccode\u003esortcolH\u003c/code\u003e\u003c/em\u003e argument is given, it identifies a column whose values must be integer numbers, and the values from \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e will appear in the horizontal header sorted according to the corresponding \u003cem class=\"replaceable\"\u003e\u003ccode\u003esortcolH\u003c/code\u003e\u003c/em\u003e values.\u003c/p\u003e\n\u003cp\u003eInside the crosstab grid, for each distinct value \u003ccode class=\"literal\"\u003ex\u003c/code\u003e of \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e and each distinct value \u003ccode class=\"literal\"\u003ey\u003c/code\u003e of \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e, the cell located at the intersection \u003ccode class=\"literal\"\u003e(x,y)\u003c/code\u003e contains the value of the \u003ccode class=\"literal\"\u003ecolD\u003c/code\u003e column in the query result row for which the value of \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolH\u003c/code\u003e\u003c/em\u003e is \u003ccode class=\"literal\"\u003ex\u003c/code\u003e and the value of \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecolV\u003c/code\u003e\u003c/em\u003e is \u003ccode class=\"literal\"\u003ey\u003c/code\u003e. If there is no such row, the cell is empty. If there are multiple such rows, an error is reported.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-D\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\d[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eFor each relation (table, view, materialized view, index, sequence, or foreign table) or composite type matching the \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e, show all columns, their types, the tablespace (if not the default) and any special attributes such as \u003ccode class=\"literal\"\u003eNOT NULL\u003c/code\u003e or defaults. Associated indexes, constraints, rules, and triggers are also shown. For foreign tables, the associated foreign server is shown as well. (\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eMatching the pattern\u003c/span\u003e”\u003c/span\u003e is defined in \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003ePatterns\u003c/a\u003e below.)\u003c/p\u003e\n\u003cp\u003eFor some types of relation, \u003ccode class=\"literal\"\u003e\\d\u003c/code\u003e shows additional information for each column: column values for sequences, indexed expressions for indexes, and foreign data wrapper options for foreign tables.\u003c/p\u003e\n\u003cp\u003eThe command form \u003ccode class=\"literal\"\u003e\\d+\u003c/code\u003e 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, the view definition if the relation is a view, a non-default \u003ca class=\"link\" href=\"/docs/18/sql-altertable.html#SQL-ALTERTABLE-REPLICA-IDENTITY\"\u003ereplica identity\u003c/a\u003e setting and the \u003ca class=\"link\" href=\"/docs/18/sql-create-access-method.html\" title=\"CREATE ACCESS METHOD\"\u003eaccess method\u003c/a\u003e name if the relation has an access method.\u003c/p\u003e\n\u003cp\u003eBy default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eIf \u003ccode class=\"command\"\u003e\\d\u003c/code\u003e is used without a \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e argument, it is equivalent to \u003ccode class=\"command\"\u003e\\dtvmsE\u003c/code\u003e which will show a list of all visible tables, views, materialized views, sequences and foreign tables. This is purely a convenience measure.\u003c/p\u003e\n\u003cp\u003eAs with many other commands, if \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode, but note that this only applies when \u003ccode class=\"command\"\u003e\\d\u003c/code\u003e is used without a \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e argument, and the \u003ccode class=\"literal\"\u003ex\u003c/code\u003e modifier cannot appear immediately after the \u003ccode class=\"command\"\u003e\\d\u003c/code\u003e (because \u003ccode class=\"command\"\u003e\\dx\u003c/code\u003e is a different command); the \u003ccode class=\"literal\"\u003ex\u003c/code\u003e modifier may only appear after an \u003ccode class=\"literal\"\u003eS\u003c/code\u003e or \u003ccode class=\"literal\"\u003e+\u003c/code\u003e modifier. For example, \u003ccode class=\"command\"\u003e\\d+x\u003c/code\u003e is equivalent to \u003ccode class=\"command\"\u003e\\dtvmsE+x\u003c/code\u003e and will show a list of all relations in expanded mode.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DA-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\da[Sx] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists aggregate functions, together with their return type and the data types they operate on. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only aggregates whose names match the pattern are shown. By default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DA-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dA[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists access methods. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only access methods whose names match the pattern are shown. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each access method is listed with its associated handler function and description.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DAC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dAc[x+] [\u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [\u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einput-type-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e]]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists operator classes (see \u003ca class=\"xref\" href=\"/docs/18/xindex.html#XINDEX-OPCLASS\" title=\"36.16.1. Index Methods and Operator Classes\"\u003eSection 36.16.1\u003c/a\u003e). If \u003cem class=\"replaceable\"\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e is specified, only operator classes associated with access methods whose names match that pattern are listed. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003einput-type-pattern\u003c/code\u003e\u003c/em\u003e is specified, only operator classes associated with input types whose names match that pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each operator class is listed with its associated operator family and owner.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DAF\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dAf[x+] [\u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [\u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einput-type-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e]]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists operator families (see \u003ca class=\"xref\" href=\"/docs/18/xindex.html#XINDEX-OPFAMILY\" title=\"36.16.5. Operator Classes and Operator Families\"\u003eSection 36.16.5\u003c/a\u003e). If \u003cem class=\"replaceable\"\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e is specified, only operator families associated with access methods whose names match that pattern are listed. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003einput-type-pattern\u003c/code\u003e\u003c/em\u003e is specified, only operator families associated with input types whose names match that pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each operator family is listed with its owner.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DAO\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dAo[x+] [\u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [\u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoperator-family-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e]]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists operators associated with operator families (see \u003ca class=\"xref\" href=\"/docs/18/xindex.html#XINDEX-STRATEGIES\" title=\"36.16.2. Index Method Strategies\"\u003eSection 36.16.2\u003c/a\u003e). If \u003cem class=\"replaceable\"\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e is specified, only members of operator families associated with access methods whose names match that pattern are listed. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoperator-family-pattern\u003c/code\u003e\u003c/em\u003e is specified, only members of operator families whose names match that pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DAP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dAp[x+] [\u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [\u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoperator-family-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e]]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists support functions associated with operator families (see \u003ca class=\"xref\" href=\"/docs/18/xindex.html#XINDEX-SUPPORT\" title=\"36.16.3. Index Method Support Routines\"\u003eSection 36.16.3\u003c/a\u003e). If \u003cem class=\"replaceable\"\u003e\u003ccode\u003eaccess-method-pattern\u003c/code\u003e\u003c/em\u003e is specified, only functions of operator families associated with access methods whose names match that pattern are listed. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoperator-family-pattern\u003c/code\u003e\u003c/em\u003e is specified, only functions of operator families whose names match that pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, functions are displayed verbosely, with their actual parameter lists.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DB\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\db[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists tablespaces. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only tablespaces whose names match the pattern are shown. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each tablespace is listed with its associated options, on-disk size, permissions and description.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DC-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dc[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists conversions between character-set encodings. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only conversions whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each object is listed with its associated description.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DCONFIG\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dconfig[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists server configuration parameters and their values. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only parameters whose names match the pattern are listed. Without a \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e, only parameters that are set to non-default values are listed. (Use \u003ccode class=\"literal\"\u003e\\dconfig *\u003c/code\u003e to see all parameters.) If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DC-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dC[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists type casts. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only casts whose source or target types match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DD-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dd[Sx] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShows the descriptions of objects of type \u003ccode class=\"literal\"\u003econstraint\u003c/code\u003e, \u003ccode class=\"literal\"\u003eoperator class\u003c/code\u003e, \u003ccode class=\"literal\"\u003eoperator family\u003c/code\u003e, \u003ccode class=\"literal\"\u003erule\u003c/code\u003e, and \u003ccode class=\"literal\"\u003etrigger\u003c/code\u003e. All other comments may be viewed by the respective backslash commands for those object types.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e\\dd\u003c/code\u003e displays descriptions for objects matching the \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e, or of visible objects of the appropriate type if no argument is given. But in either case, only objects that have a description are listed. By default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003cp\u003eDescriptions for objects can be created with the \u003ca class=\"link\" href=\"/docs/18/sql-comment.html\" title=\"COMMENT\"\u003e\u003ccode class=\"command\"\u003eCOMMENT\u003c/code\u003e\u003c/a\u003e SQL command.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DD-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dD[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists domains. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only domains whose names match the pattern are shown. By default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each object is listed with its associated permissions and description.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DDP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\ddp[x] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists 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 \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only entries whose role name or schema name matches the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003cp\u003eThe \u003ca class=\"link\" href=\"/docs/18/sql-alterdefaultprivileges.html\" title=\"ALTER DEFAULT PRIVILEGES\"\u003e\u003ccode class=\"command\"\u003eALTER DEFAULT PRIVILEGES\u003c/code\u003e\u003c/a\u003e command is used to set default access privileges. The meaning of the privilege display is explained in \u003ca class=\"xref\" href=\"/docs/18/ddl-priv.html\" title=\"5.8. Privileges\"\u003eSection 5.8\u003c/a\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dE[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\di[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dm[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\ds[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dt[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dv[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIn this group of commands, the letters \u003ccode class=\"literal\"\u003eE\u003c/code\u003e, \u003ccode class=\"literal\"\u003ei\u003c/code\u003e, \u003ccode class=\"literal\"\u003em\u003c/code\u003e, \u003ccode class=\"literal\"\u003es\u003c/code\u003e, \u003ccode class=\"literal\"\u003et\u003c/code\u003e, and \u003ccode class=\"literal\"\u003ev\u003c/code\u003e 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, \u003ccode class=\"literal\"\u003e\\dti\u003c/code\u003e lists tables and indexes. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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 \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only objects whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DES\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\des[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists foreign servers (mnemonic: \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eexternal servers\u003c/span\u003e”\u003c/span\u003e). If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those servers whose name matches the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\det[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists foreign tables (mnemonic: \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eexternal tables\u003c/span\u003e”\u003c/span\u003e). If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only entries whose table name or schema name matches the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, generic options and the foreign table description are also displayed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DEU\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\deu[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists user mappings (mnemonic: \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eexternal users\u003c/span\u003e”\u003c/span\u003e). If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those mappings whose user names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, additional information about each mapping is shown.\u003c/p\u003e\n\u003cdiv class=\"caution\"\u003e\n\u003ch3 class=\"title\"\u003eCaution\u003c/h3\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e\\deu+\u003c/code\u003e might also display the user name and password of the remote user, so care should be taken not to disclose them.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DEW\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dew[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists foreign-data wrappers (mnemonic: \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eexternal wrappers\u003c/span\u003e”\u003c/span\u003e). If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those foreign-data wrappers whose name matches the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, the access privileges, options, and description of the foreign-data wrapper are also shown.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DF-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\df[anptwSx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003earg_pattern\u003c/code\u003e\u003c/em\u003e ... ] ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists functions, together with their result data types, argument data types, and function types, which are classified as \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eagg\u003c/span\u003e”\u003c/span\u003e (aggregate), \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003enormal\u003c/span\u003e”\u003c/span\u003e, \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eprocedure\u003c/span\u003e”\u003c/span\u003e, \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003etrigger\u003c/span\u003e”\u003c/span\u003e, or \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003ewindow\u003c/span\u003e”\u003c/span\u003e. To display only functions of specific type(s), add the corresponding letters \u003ccode class=\"literal\"\u003ea\u003c/code\u003e, \u003ccode class=\"literal\"\u003en\u003c/code\u003e, \u003ccode class=\"literal\"\u003ep\u003c/code\u003e, \u003ccode class=\"literal\"\u003et\u003c/code\u003e, or \u003ccode class=\"literal\"\u003ew\u003c/code\u003e to the command. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e 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 \u003ccode class=\"literal\"\u003e-\u003c/code\u003e as the last \u003cem class=\"replaceable\"\u003e\u003ccode\u003earg_pattern\u003c/code\u003e\u003c/em\u003e.) By default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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 \u003ccode class=\"literal\"\u003e\\sf\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DF-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dF[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists text search configurations. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only configurations whose names match the pattern are shown. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DFD\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dFd[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists text search dictionaries. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only dictionaries whose names match the pattern are shown. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, additional information is shown about each selected dictionary, including the underlying text search template and the option values.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DFP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dFp[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists text search parsers. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only parsers whose names match the pattern are shown. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DFT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dFt[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists text search templates. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only templates whose names match the pattern are shown. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, additional information is shown about each template, including the underlying function names.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DG\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dg[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists database roles. (Since the concepts of \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eusers\u003c/span\u003e”\u003c/span\u003e and \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003egroups\u003c/span\u003e”\u003c/span\u003e have been unified into \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eroles\u003c/span\u003e”\u003c/span\u003e, this command is now equivalent to \u003ccode class=\"literal\"\u003e\\du\u003c/code\u003e.) By default, only user-created roles are shown; supply the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system roles. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those roles whose names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, additional information is shown about each role; currently this adds the comment for each role.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DL-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dl[x+]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis is an alias for \u003ccode class=\"command\"\u003e\\lo_list\u003c/code\u003e, which shows a list of large objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each large object is listed with its associated permissions, if any.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DL-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dL[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists procedural languages. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only languages whose names match the pattern are listed. By default, only user-created languages are shown; supply the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each language is listed with its call handler, validator, access privileges, and whether it is a system object.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dn[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists schemas (namespaces). If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only schemas whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each object is listed with its associated permissions and description, if any.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DO-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\do[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003earg_pattern\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003earg_pattern\u003c/code\u003e\u003c/em\u003e ] ] ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists operators with their operand and result types. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only operators whose names match the pattern are listed. If one \u003cem class=\"replaceable\"\u003e\u003ccode\u003earg_pattern\u003c/code\u003e\u003c/em\u003e is specified, only prefix operators whose right argument's type name matches that pattern are listed. If two \u003cem class=\"replaceable\"\u003e\u003ccode\u003earg_pattern\u003c/code\u003e\u003c/em\u003es are specified, only binary operators whose argument type names match those patterns are listed. (Alternatively, write \u003ccode class=\"literal\"\u003e-\u003c/code\u003e for the unused argument of a unary operator.) By default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DO-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dO[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists collations. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only collations whose names match the pattern are listed. By default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DP-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dp[Sx] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists tables, views and sequences with their associated access privileges. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e 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 \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003cp\u003eThe \u003ca class=\"link\" href=\"/docs/18/sql-grant.html\" title=\"GRANT\"\u003e\u003ccode class=\"command\"\u003eGRANT\u003c/code\u003e\u003c/a\u003e and \u003ca class=\"link\" href=\"/docs/18/sql-revoke.html\" title=\"REVOKE\"\u003e\u003ccode class=\"command\"\u003eREVOKE\u003c/code\u003e\u003c/a\u003e commands are used to set access privileges. The meaning of the privilege display is explained in \u003ca class=\"xref\" href=\"/docs/18/ddl-priv.html\" title=\"5.8. Privileges\"\u003eSection 5.8\u003c/a\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DP-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dP[itnx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists partitioned relations. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only entries whose name matches the pattern are listed. The modifiers \u003ccode class=\"literal\"\u003et\u003c/code\u003e (tables) and \u003ccode class=\"literal\"\u003ei\u003c/code\u003e (indexes) can be appended to the command, filtering the kind of relations to list. By default, partitioned tables and indexes are listed.\u003c/p\u003e\n\u003cp\u003eIf the modifier \u003ccode class=\"literal\"\u003en\u003c/code\u003e (\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003enested\u003c/span\u003e”\u003c/span\u003e) is used, or a pattern is specified, then non-root partitioned relations are included, and a column is shown displaying the parent of each partitioned relation.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, the sum of the sizes of each relation's partitions is also displayed, along with the relation's description. If \u003ccode class=\"literal\"\u003en\u003c/code\u003e is combined with \u003ccode class=\"literal\"\u003e+\u003c/code\u003e, two sizes are shown: one including the total size of directly-attached leaf partitions, and another showing the total size of all partitions, including indirectly attached sub-partitions.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DRDS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\drds[x] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003erole-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003edatabase-pattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ] ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists defined configuration settings. These settings can be role-specific, database-specific, or both. \u003cem class=\"replaceable\"\u003e\u003ccode\u003erole-pattern\u003c/code\u003e\u003c/em\u003e and \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatabase-pattern\u003c/code\u003e\u003c/em\u003e are used to select specific roles and databases to list, respectively. If omitted, or if \u003ccode class=\"literal\"\u003e*\u003c/code\u003e is specified, all settings are listed, including those not role-specific or database-specific, respectively. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003cp\u003eThe \u003ca class=\"link\" href=\"/docs/18/sql-alterrole.html\" title=\"ALTER ROLE\"\u003e\u003ccode class=\"command\"\u003eALTER ROLE\u003c/code\u003e\u003c/a\u003e and \u003ca class=\"link\" href=\"/docs/18/sql-alterdatabase.html\" title=\"ALTER DATABASE\"\u003e\u003ccode class=\"command\"\u003eALTER DATABASE\u003c/code\u003e\u003c/a\u003e commands are used to define per-role and per-database configuration settings.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DRG\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\drg[Sx] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists information about each granted role membership, including assigned options (\u003ccode class=\"literal\"\u003eADMIN\u003c/code\u003e, \u003ccode class=\"literal\"\u003eINHERIT\u003c/code\u003e and/or \u003ccode class=\"literal\"\u003eSET\u003c/code\u003e) and grantor. See the \u003ca class=\"link\" href=\"/docs/18/sql-grant.html\" title=\"GRANT\"\u003e\u003ccode class=\"command\"\u003eGRANT\u003c/code\u003e\u003c/a\u003e command for information about role memberships.\u003c/p\u003e\n\u003cp\u003eBy default, only grants to user-created roles are shown; supply the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system roles. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only grants to those roles whose names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DRP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dRp[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists replication publications. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those publications whose names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, the tables and schemas associated with each publication are shown as well.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DRS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dRs[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists replication subscriptions. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those subscriptions whose names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, additional properties of the subscriptions are shown.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dT[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists data types. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only types whose names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each type is listed with its internal name and size, its allowed values if it is an \u003ccode class=\"type\"\u003eenum\u003c/code\u003e type, and its associated permissions. By default, only user-created objects are shown; supply a pattern or the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DU\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\du[Sx+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists database roles. (Since the concepts of \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eusers\u003c/span\u003e”\u003c/span\u003e and \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003egroups\u003c/span\u003e”\u003c/span\u003e have been unified into \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eroles\u003c/span\u003e”\u003c/span\u003e, this command is now equivalent to \u003ccode class=\"literal\"\u003e\\dg\u003c/code\u003e.) By default, only user-created roles are shown; supply the \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system roles. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those roles whose names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, additional information is shown about each role; currently this adds the comment for each role.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DX-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dx[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists installed extensions. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those extensions whose names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, all the objects belonging to each matching extension are listed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DX-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dX[x] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists extended statistics. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those extended statistics whose names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003cp\u003eThe status of each kind of extended statistics is shown in a column named after its statistic kind (e.g. Ndistinct). \u003ccode class=\"literal\"\u003edefined\u003c/code\u003e means that it was requested when creating the statistics, and NULL means it wasn't requested. You can use \u003ccode class=\"structname\"\u003epg_stats_ext\u003c/code\u003e if you'd like to know whether \u003ca class=\"link\" href=\"/docs/18/sql-analyze.html\" title=\"ANALYZE\"\u003e\u003ccode class=\"command\"\u003eANALYZE\u003c/code\u003e\u003c/a\u003e was run and statistics are available to the planner.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-DY\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\dy[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists event triggers. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only those event triggers whose names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each object is listed with its associated description.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-EDIT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\e\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\edit\u003c/code\u003e \u003ccode class=\"literal\"\u003e[ \u003cspan class=\"optional\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ] [ \u003cspan class=\"optional\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eline_number\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e is specified, the file is edited; after the editor exits, the file's content is copied into the current query buffer. If no \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e 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.\u003c/p\u003e\n\u003cp\u003eIf you edit a file or the previous query, and you quit the editor without modifying the file, the query buffer is cleared. Otherwise, the new contents of the query buffer are re-parsed according to the normal rules of \u003cspan class=\"application\"\u003epsql\u003c/span\u003e, treating the whole buffer as a single line. Any complete queries are immediately executed; that is, if the query buffer contains or ends with a semicolon, everything up to that point is executed and removed from the query buffer. Whatever remains in the query buffer is redisplayed. Type semicolon or \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e to send it, or \u003ccode class=\"literal\"\u003e\\r\u003c/code\u003e to cancel it by clearing the query buffer.\u003c/p\u003e\n\u003cp\u003eTreating the buffer as a single line primarily affects meta-commands: whatever is in the buffer after a meta-command will be taken as argument(s) to the meta-command, even if it spans multiple lines. (Thus you cannot make meta-command-using scripts this way. Use \u003ccode class=\"command\"\u003e\\i\u003c/code\u003e for that.)\u003c/p\u003e\n\u003cp\u003eIf a line number is specified, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will position the cursor on the specified line of the file or query buffer. Note that if a single all-digits argument is given, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e assumes it is a line number, not a file name.\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eSee \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-ENVIRONMENT\" title=\"Environment\"\u003eEnvironment\u003c/a\u003e, below, for how to configure and customize your editor.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-ECHO\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\echo \u003cem class=\"replaceable\"\u003e\u003ccode\u003etext\u003c/code\u003e\u003c/em\u003e [ ... ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrints 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:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\echo `date`\u003c/code\u003e\u003c/strong\u003e\nTue Oct 26 21:40:57 CEST 1999\n\u003c/pre\u003e\n\u003cp\u003eIf the first argument is an unquoted \u003ccode class=\"literal\"\u003e-n\u003c/code\u003e the trailing newline is not written (nor is the first argument).\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eIf you use the \u003ccode class=\"command\"\u003e\\o\u003c/code\u003e command to redirect your query output you might wish to use \u003ccode class=\"command\"\u003e\\qecho\u003c/code\u003e instead of this command. See also \u003ccode class=\"command\"\u003e\\warn\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-EF\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\ef [ \u003cspan class=\"optional\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003efunction_description\u003c/code\u003e\u003c/em\u003e [ \u003cspan class=\"optional\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eline_number\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ]\u003c/span\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command fetches and edits the definition of the named function or procedure, in the form of a \u003ccode class=\"command\"\u003eCREATE OR REPLACE FUNCTION\u003c/code\u003e or \u003ccode class=\"command\"\u003eCREATE OR REPLACE PROCEDURE\u003c/code\u003e command. Editing is done in the same way as for \u003ccode class=\"literal\"\u003e\\edit\u003c/code\u003e. 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 \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e to send it, or \u003ccode class=\"literal\"\u003e\\r\u003c/code\u003e to cancel.\u003c/p\u003e\n\u003cp\u003eThe target function can be specified by name alone, or by name and arguments, for example \u003ccode class=\"literal\"\u003efoo(integer, text)\u003c/code\u003e. The argument types must be given if there is more than one function of the same name.\u003c/p\u003e\n\u003cp\u003eIf no function is specified, a blank \u003ccode class=\"command\"\u003eCREATE FUNCTION\u003c/code\u003e template is presented for editing.\u003c/p\u003e\n\u003cp\u003eIf a line number is specified, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will position the cursor on the specified line of the function body. (Note that the function body typically does not begin on the first line of the file.)\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument(s) of \u003ccode class=\"command\"\u003e\\ef\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments.\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eSee \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-ENVIRONMENT\" title=\"Environment\"\u003eEnvironment\u003c/a\u003e, below, for how to configure and customize your editor.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-ENCODING\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\encoding [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eencoding\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the client character set encoding. Without an argument, this command shows the current encoding.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-ERRVERBOSE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\errverbose\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRepeats the most recent server error message at maximum verbosity, as though \u003ccode class=\"varname\"\u003eVERBOSITY\u003c/code\u003e were set to \u003ccode class=\"literal\"\u003everbose\u003c/code\u003e and \u003ccode class=\"varname\"\u003eSHOW_CONTEXT\u003c/code\u003e were set to \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-EV\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\ev [ \u003cspan class=\"optional\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eview_name\u003c/code\u003e\u003c/em\u003e [ \u003cspan class=\"optional\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eline_number\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e ]\u003c/span\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command fetches and edits the definition of the named view, in the form of a \u003ccode class=\"command\"\u003eCREATE OR REPLACE VIEW\u003c/code\u003e command. Editing is done in the same way as for \u003ccode class=\"literal\"\u003e\\edit\u003c/code\u003e. 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 \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e to send it, or \u003ccode class=\"literal\"\u003e\\r\u003c/code\u003e to cancel.\u003c/p\u003e\n\u003cp\u003eIf no view is specified, a blank \u003ccode class=\"command\"\u003eCREATE VIEW\u003c/code\u003e template is presented for editing.\u003c/p\u003e\n\u003cp\u003eIf a line number is specified, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will position the cursor on the specified line of the view definition.\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument(s) of \u003ccode class=\"command\"\u003e\\ev\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-F\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\f [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the field separator for unaligned query output. The default is the vertical bar (\u003ccode class=\"literal\"\u003e|\u003c/code\u003e). It is equivalent to \u003ccode class=\"command\"\u003e\\pset fieldsep\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-G\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\g [ (\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [...]) ] [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\g [ (\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [...]) ] [ |\u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSends the current query buffer to the server for execution.\u003c/p\u003e\n\u003cp\u003eIf parentheses appear after \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e, they surround a space-separated list of \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e\u003ccode class=\"literal\"\u003e=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e formatting-option clauses, which are interpreted in the same way as \u003ccode class=\"literal\"\u003e\\pset\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e commands, but take effect only for the duration of this query. In this list, spaces are not allowed around \u003ccode class=\"literal\"\u003e=\u003c/code\u003e signs, but are required between option clauses. If \u003ccode class=\"literal\"\u003e=\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is omitted, the named \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e is changed in the same way as for \u003ccode class=\"literal\"\u003e\\pset\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e with no explicit \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eIf a \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e or \u003ccode class=\"literal\"\u003e|\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e argument is given, the query's output is written to the named file or piped to the given shell command, instead of displaying it as usual. The file or command is written to only if the query successfully returns zero or more tuples, not if the query fails or is a non-data-returning SQL command.\u003c/p\u003e\n\u003cp\u003eIf the current query buffer is empty, the most recently sent query is re-executed instead. Except for that behavior, \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e without any arguments is essentially equivalent to a semicolon. With arguments, \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e provides a \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eone-shot\u003c/span\u003e”\u003c/span\u003e alternative to the \u003ccode class=\"command\"\u003e\\o\u003c/code\u003e command, and additionally allows one-shot adjustments of the output formatting options normally set by \u003ccode class=\"literal\"\u003e\\pset\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eWhen the last argument begins with \u003ccode class=\"literal\"\u003e|\u003c/code\u003e, the entire remainder of the line is taken to be the \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e to execute, and neither variable interpolation nor backquote expansion are performed in it. The rest of the line is simply passed literally to the shell.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-GDESC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\gdesc\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShows 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.\u003c/p\u003e\n\u003cp\u003eIf the current query buffer is empty, the most recently sent query is described instead.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-GETENV\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\getenv \u003cem class=\"replaceable\"\u003e\u003ccode\u003epsql_var\u003c/code\u003e\u003c/em\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eenv_var\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eGets the value of the environment variable \u003cem class=\"replaceable\"\u003e\u003ccode\u003eenv_var\u003c/code\u003e\u003c/em\u003e and assigns it to the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variable \u003cem class=\"replaceable\"\u003e\u003ccode\u003epsql_var\u003c/code\u003e\u003c/em\u003e. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003eenv_var\u003c/code\u003e\u003c/em\u003e is not defined in the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e process's environment, \u003cem class=\"replaceable\"\u003e\u003ccode\u003epsql_var\u003c/code\u003e\u003c/em\u003e is not changed. Example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\getenv home HOME\u003c/code\u003e\u003c/strong\u003e\n=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\echo :home\u003c/code\u003e\u003c/strong\u003e\n/home/postgres\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-GEXEC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\gexec\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSends 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 \u003ccode class=\"structname\"\u003emy_table\u003c/code\u003e:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT format('create index on my_table(%I)', attname)\u003c/code\u003e\u003c/strong\u003e\n-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eFROM pg_attribute\u003c/code\u003e\u003c/strong\u003e\n-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eWHERE attrelid = 'my_table'::regclass AND attnum \u0026gt; 0\u003c/code\u003e\u003c/strong\u003e\n-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eORDER BY attnum\u003c/code\u003e\u003c/strong\u003e\n-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\gexec\u003c/code\u003e\u003c/strong\u003e\nCREATE INDEX\nCREATE INDEX\nCREATE INDEX\nCREATE INDEX\n\u003c/pre\u003e\n\u003cp\u003eThe generated queries are executed in the order in which the rows are returned, and left-to-right within each row if there is more than one column. NULL fields are ignored. The generated queries are sent literally to the server for processing, so they cannot be \u003cspan class=\"application\"\u003epsql\u003c/span\u003e meta-commands nor contain \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variable references. If any individual query fails, execution of the remaining queries continues unless \u003ccode class=\"varname\"\u003eON_ERROR_STOP\u003c/code\u003e is set. Execution of each query is subject to \u003ccode class=\"varname\"\u003eECHO\u003c/code\u003e processing. (Setting \u003ccode class=\"varname\"\u003eECHO\u003c/code\u003e to \u003ccode class=\"literal\"\u003eall\u003c/code\u003e or \u003ccode class=\"literal\"\u003equeries\u003c/code\u003e is often advisable when using \u003ccode class=\"command\"\u003e\\gexec\u003c/code\u003e.) Query logging, single-step mode, timing, and other query execution features apply to each generated query as well.\u003c/p\u003e\n\u003cp\u003eIf the current query buffer is empty, the most recently sent query is re-executed instead.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-GSET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\gset [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSends the current query buffer to the server and stores the query's output into \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variables (see \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-VARIABLES\" title=\"Variables\"\u003eVariables\u003c/a\u003e 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:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT 'hello' AS var1, 10 AS var2\u003c/code\u003e\u003c/strong\u003e\n-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\gset\u003c/code\u003e\u003c/strong\u003e\n=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\echo :var1 :var2\u003c/code\u003e\u003c/strong\u003e\nhello 10\n\u003c/pre\u003e\n\u003cp\u003eIf you specify a \u003cem class=\"replaceable\"\u003e\u003ccode\u003eprefix\u003c/code\u003e\u003c/em\u003e, that string is prepended to the query's column names to create the variable names to use:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT 'hello' AS var1, 10 AS var2\u003c/code\u003e\u003c/strong\u003e\n-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\gset result_\u003c/code\u003e\u003c/strong\u003e\n=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\echo :result_var1 :result_var2\u003c/code\u003e\u003c/strong\u003e\nhello 10\n\u003c/pre\u003e\n\u003cp\u003eIf a column result is NULL, the corresponding variable is unset rather than being set.\u003c/p\u003e\n\u003cp\u003eIf the query fails or does not return one row, no variables are changed.\u003c/p\u003e\n\u003cp\u003eIf the current query buffer is empty, the most recently sent query is re-executed instead.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-GX\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\gx [ (\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [...]) ] [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\gx [ (\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [...]) ] [ |\u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003e\\gx\u003c/code\u003e is equivalent to \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e, except that it forces expanded output mode for this query, as if \u003ccode class=\"literal\"\u003eexpanded=on\u003c/code\u003e were included in the list of \u003ccode class=\"literal\"\u003e\\pset\u003c/code\u003e options. See also \u003ccode class=\"literal\"\u003e\\x\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-HELP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\h\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\help\u003c/code\u003e \u003ccode class=\"literal\"\u003e[ \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eGives syntax help on the specified SQL command. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e is not specified, then \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will list all the commands for which syntax help is available. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e is an asterisk (\u003ccode class=\"literal\"\u003e*\u003c/code\u003e), then syntax help on all SQL commands is shown.\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument(s) of \u003ccode class=\"command\"\u003e\\help\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eTo simplify typing, commands that consists of several words do not have to be quoted. Thus it is fine to type \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\help alter table\u003c/code\u003e\u003c/strong\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-HTML\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\H\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\html\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eTurns 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 \u003ccode class=\"command\"\u003e\\pset\u003c/code\u003e about setting other output options.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-INCLUDE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\i\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\include\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eReads input from the file \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e and executes it as though it had been typed on the keyboard.\u003c/p\u003e\n\u003cp\u003eIf \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e is \u003ccode class=\"literal\"\u003e-\u003c/code\u003e (hyphen), then standard input is read until an EOF indication or \u003ccode class=\"command\"\u003e\\q\u003c/code\u003e meta-command. This can be used to intersperse interactive input with input from files. Note that Readline behavior will be used only if it is active at the outermost level.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eIf you want to see the lines on the screen as they are read you must set the variable \u003ccode class=\"varname\"\u003eECHO\u003c/code\u003e to \u003ccode class=\"literal\"\u003eall\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"PSQL-METACOMMAND-IF\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\if\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\elif\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\else\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\endif\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis group of commands implements nestable conditional blocks. A conditional block must begin with an \u003ccode class=\"command\"\u003e\\if\u003c/code\u003e and end with an \u003ccode class=\"command\"\u003e\\endif\u003c/code\u003e. In between there may be any number of \u003ccode class=\"command\"\u003e\\elif\u003c/code\u003e clauses, which may optionally be followed by a single \u003ccode class=\"command\"\u003e\\else\u003c/code\u003e clause. Ordinary queries and other types of backslash commands may (and usually do) appear between the commands forming a conditional block.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode class=\"command\"\u003e\\if\u003c/code\u003e and \u003ccode class=\"command\"\u003e\\elif\u003c/code\u003e commands read their argument(s) and evaluate them as a Boolean expression. If the expression yields \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e then processing continues normally; otherwise, lines are skipped until a matching \u003ccode class=\"command\"\u003e\\elif\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\else\u003c/code\u003e, or \u003ccode class=\"command\"\u003e\\endif\u003c/code\u003e is reached. Once an \u003ccode class=\"command\"\u003e\\if\u003c/code\u003e or \u003ccode class=\"command\"\u003e\\elif\u003c/code\u003e test has succeeded, the arguments of later \u003ccode class=\"command\"\u003e\\elif\u003c/code\u003e commands in the same block are not evaluated but are treated as false. Lines following an \u003ccode class=\"command\"\u003e\\else\u003c/code\u003e are processed only if no earlier matching \u003ccode class=\"command\"\u003e\\if\u003c/code\u003e or \u003ccode class=\"command\"\u003e\\elif\u003c/code\u003e succeeded.\u003c/p\u003e\n\u003cp\u003eThe \u003cem class=\"replaceable\"\u003e\u003ccode\u003eexpression\u003c/code\u003e\u003c/em\u003e argument of an \u003ccode class=\"command\"\u003e\\if\u003c/code\u003e or \u003ccode class=\"command\"\u003e\\elif\u003c/code\u003e command is subject to variable interpolation and backquote expansion, just like any other backslash command argument. After that it is evaluated like the value of an on/off option variable. So a valid value is any unambiguous case-insensitive match for one of: \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e, \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e, \u003ccode class=\"literal\"\u003e1\u003c/code\u003e, \u003ccode class=\"literal\"\u003e0\u003c/code\u003e, \u003ccode class=\"literal\"\u003eon\u003c/code\u003e, \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e, \u003ccode class=\"literal\"\u003eyes\u003c/code\u003e, \u003ccode class=\"literal\"\u003eno\u003c/code\u003e. For example, \u003ccode class=\"literal\"\u003et\u003c/code\u003e, \u003ccode class=\"literal\"\u003eT\u003c/code\u003e, and \u003ccode class=\"literal\"\u003etR\u003c/code\u003e will all be considered to be \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eExpressions that do not properly evaluate to true or false will generate a warning and be treated as false.\u003c/p\u003e\n\u003cp\u003eLines being skipped are parsed normally to identify queries and backslash commands, but queries are not sent to the server, and backslash commands other than conditionals (\u003ccode class=\"command\"\u003e\\if\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\elif\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\else\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\endif\u003c/code\u003e) are ignored. Conditional commands are checked only for valid nesting. Variable references in skipped lines are not expanded, and backquote expansion is not performed either.\u003c/p\u003e\n\u003cp\u003eAll the backslash commands of a given conditional block must appear in the same source file. If EOF is reached on the main input file or an \u003ccode class=\"command\"\u003e\\include\u003c/code\u003e-ed file before all local \u003ccode class=\"command\"\u003e\\if\u003c/code\u003e-blocks have been closed, then \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will raise an error.\u003c/p\u003e\n\u003cp\u003eHere is an example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e-- check for the existence of two separate records in the database and store\n-- the results in separate psql variables\nSELECT\n    EXISTS(SELECT 1 FROM customer WHERE customer_id = 123) as is_customer,\n    EXISTS(SELECT 1 FROM employee WHERE employee_id = 456) as is_employee\n\\gset\n\\if :is_customer\n    SELECT * FROM customer WHERE customer_id = 123;\n\\elif :is_employee\n    \\echo 'is not a customer but is an employee'\n    SELECT * FROM employee WHERE employee_id = 456;\n\\else\n    \\if yes\n        \\echo 'not a customer or employee'\n    \\else\n        \\echo 'this will never print'\n    \\endif\n\\endif\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-INCLUDE-RELATIVE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\ir\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\include_relative\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe \u003ccode class=\"literal\"\u003e\\ir\u003c/code\u003e command is similar to \u003ccode class=\"literal\"\u003e\\i\u003c/code\u003e, but resolves relative file names differently. When executing in interactive mode, the two commands behave identically. However, when invoked from a script, \u003ccode class=\"literal\"\u003e\\ir\u003c/code\u003e interprets file names relative to the directory in which the script is located, rather than the current working directory.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-LIST\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\l[x+]\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\list[x+] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eList the databases in the server and show their names, owners, character set encodings, and access privileges. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e is specified, only databases whose names match the pattern are listed. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e 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 \u003ccode class=\"literal\"\u003eCONNECT\u003c/code\u003e privilege, or if the current user is a superuser or has privileges of the \u003ccode class=\"literal\"\u003epg_read_all_stats\u003c/code\u003e role.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-LO-EXPORT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\lo_export \u003cem class=\"replaceable\"\u003e\u003ccode\u003eloid\u003c/code\u003e\u003c/em\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eReads the large object with OID \u003cem class=\"replaceable\"\u003e\u003ccode\u003eloid\u003c/code\u003e\u003c/em\u003e from the database and writes it to \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e. Note that this is subtly different from the server function \u003ccode class=\"function\"\u003elo_export\u003c/code\u003e, which acts with the permissions of the user that the database server runs as and on the server's file system.\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eUse \u003ccode class=\"command\"\u003e\\lo_list\u003c/code\u003e to find out the large object's OID.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-LO-IMPORT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\lo_import \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecomment\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eStores the file into a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e large object. Optionally, it associates the given comment with the object. Example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003efoo=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\lo_import '/home/peter/pictures/photo.xcf' 'a picture of me'\u003c/code\u003e\u003c/strong\u003e\nlo_import 152801\n\u003c/pre\u003e\n\u003cp\u003eThe response indicates that the large object received object ID 152801, which can be used to access the newly-created large object in the future. For the sake of readability, it is recommended to always associate a human-readable comment with every object. Both OIDs and comments can be viewed with the \u003ccode class=\"command\"\u003e\\lo_list\u003c/code\u003e command.\u003c/p\u003e\n\u003cp\u003eNote that this command is subtly different from the server-side \u003ccode class=\"function\"\u003elo_import\u003c/code\u003e because it acts as the local user on the local file system, rather than the server's user and file system.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-LO-LIST\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\lo_list[x+]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShows a list of all \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e large objects currently stored in the database, along with any comments provided for them. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode. If \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, each large object is listed with its associated permissions, if any.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-LO-UNLINK\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\lo_unlink \u003cem class=\"replaceable\"\u003e\u003ccode\u003eloid\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDeletes the large object with OID \u003cem class=\"replaceable\"\u003e\u003ccode\u003eloid\u003c/code\u003e\u003c/em\u003e from the database.\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eUse \u003ccode class=\"command\"\u003e\\lo_list\u003c/code\u003e to find out the large object's OID.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-OUT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\o\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\out [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\o\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\out [ |\u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eArranges to save future query results to the file \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e or pipe future results to the shell command \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e. If no argument is specified, the query output is reset to the standard output.\u003c/p\u003e\n\u003cp\u003eIf the argument begins with \u003ccode class=\"literal\"\u003e|\u003c/code\u003e, then the entire remainder of the line is taken to be the \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e to execute, and neither variable interpolation nor backquote expansion are performed in it. The rest of the line is simply passed literally to the shell.\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eQuery results\u003c/span\u003e”\u003c/span\u003e includes all tables, command responses, and notices obtained from the database server, as well as output of various backslash commands that query the database (such as \u003ccode class=\"command\"\u003e\\d\u003c/code\u003e); but not error messages.\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eTo intersperse text output in between query results, use \u003ccode class=\"command\"\u003e\\qecho\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PRINT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\p\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\print\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint the current query buffer to the standard output. If the current query buffer is empty, the most recently executed query is printed instead.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PARSE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\parse \u003cem class=\"replaceable\"\u003e\u003ccode\u003estatement_name\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreates 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.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT $1 \\parse stmt1\n\u003c/pre\u003e\n\u003cp\u003eThis command causes the extended query protocol to be used, unlike normal \u003cspan class=\"application\"\u003epsql\u003c/span\u003e operation, which uses the simple query protocol. A \u003ca class=\"xref\" href=\"/docs/18/protocol-message-formats.html#PROTOCOL-MESSAGE-FORMATS-PARSE\"\u003eParse (F)\u003c/a\u003e message will be issued by this command so it can be useful to test the extended query protocol from \u003cspan class=\"application\"\u003epsql\u003c/span\u003e. This command affects only the next query executed; all subsequent queries will use the simple query protocol by default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PASSWORD\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\password [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eChanges 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 \u003ccode class=\"command\"\u003eALTER ROLE\u003c/code\u003e command. This makes sure that the new password does not appear in cleartext in the command history, the server log, or elsewhere.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PROMPT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\prompt [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003etext\u003c/code\u003e\u003c/em\u003e ] \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrompts the user to supply text, which is assigned to the variable \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e. An optional prompt string, \u003cem class=\"replaceable\"\u003e\u003ccode\u003etext\u003c/code\u003e\u003c/em\u003e, can be specified. (For multiword prompts, surround the text with single quotes.)\u003c/p\u003e\n\u003cp\u003eBy default, \u003ccode class=\"literal\"\u003e\\prompt\u003c/code\u003e uses the terminal for input and output. However, if the \u003ccode class=\"option\"\u003e-f\u003c/code\u003e command line switch was used, \u003ccode class=\"literal\"\u003e\\prompt\u003c/code\u003e uses standard input and standard output.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\pset [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e ] ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command sets options affecting the output of query result tables. \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e indicates which option is to be set. The semantics of \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e vary depending on the selected option. For some options, omitting \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e causes the option to be toggled or unset, as described under the particular option. If no such behavior is mentioned, then omitting \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e just results in the current setting being displayed.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003e\\pset\u003c/code\u003e without any arguments displays the current status of all printing options.\u003c/p\u003e\n\u003cp\u003eAdjustable printing options are:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-BORDER\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eborder\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e must be a number. In general, the higher the number the more borders and lines the tables will have, but details depend on the particular format. In HTML format, this will translate directly into the \u003ccode class=\"literal\"\u003eborder=...\u003c/code\u003e attribute. In most other formats only values 0 (no border), 1 (internal dividing lines), and 2 (table frame) make sense, and values above 2 will be treated the same as \u003ccode class=\"literal\"\u003eborder = 2\u003c/code\u003e. The \u003ccode class=\"literal\"\u003elatex\u003c/code\u003e and \u003ccode class=\"literal\"\u003elatex-longtable\u003c/code\u003e formats additionally allow a value of 3 to add dividing lines between data rows.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-COLUMNS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ecolumns\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the target width for the \u003ccode class=\"literal\"\u003ewrapped\u003c/code\u003e format, and also the width limit for determining whether output is wide enough to require the pager or switch to the vertical display in expanded auto mode. Zero (the default) causes the target width to be controlled by the environment variable \u003ccode class=\"envar\"\u003eCOLUMNS\u003c/code\u003e, or the detected screen width if \u003ccode class=\"envar\"\u003eCOLUMNS\u003c/code\u003e is not set. In addition, if \u003ccode class=\"literal\"\u003ecolumns\u003c/code\u003e is zero then the \u003ccode class=\"literal\"\u003ewrapped\u003c/code\u003e format only affects screen output. If \u003ccode class=\"literal\"\u003ecolumns\u003c/code\u003e is nonzero then file and pipe output is wrapped to that width as well.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-CSV-FIELDSEP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ecsv_fieldsep\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the field separator to be used in CSV output format. If the separator character appears in a field's value, that field is output within double quotes, following standard CSV rules. The default is a comma.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-EXPANDED\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eexpanded\u003c/code\u003e (or \u003ccode class=\"literal\"\u003ex\u003c/code\u003e)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is specified it must be either \u003ccode class=\"literal\"\u003eon\u003c/code\u003e or \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e, which will enable or disable expanded mode, or \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is omitted the command toggles between the on and off settings. When expanded mode 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 \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003ehorizontal\u003c/span\u003e”\u003c/span\u003e mode. In the auto setting, the expanded mode is used whenever the query output has more than one column and is wider than the screen; otherwise, the regular mode is used. The auto setting is only effective in the aligned and wrapped formats. In other formats, it always behaves as if the expanded mode is off.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-FIELDSEP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003efieldsep\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the field separator to be used in unaligned output format. That way one can create, for example, tab-separated output, which other programs might prefer. To set a tab as field separator, type \u003ccode class=\"literal\"\u003e\\pset fieldsep '\\t'\u003c/code\u003e. The default field separator is \u003ccode class=\"literal\"\u003e'|'\u003c/code\u003e (a vertical bar).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-FIELDSEP-ZERO\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003efieldsep_zero\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the field separator to use in unaligned output format to a zero byte.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-FOOTER\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003efooter\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is specified it must be either \u003ccode class=\"literal\"\u003eon\u003c/code\u003e or \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e which will enable or disable display of the table footer (the \u003ccode class=\"literal\"\u003e(\u003cem class=\"replaceable\"\u003e\u003ccode\u003en\u003c/code\u003e\u003c/em\u003e rows)\u003c/code\u003e count). If \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is omitted the command toggles footer display on or off.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-FORMAT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eformat\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the output format to one of \u003ccode class=\"literal\"\u003ealigned\u003c/code\u003e, \u003ccode class=\"literal\"\u003easciidoc\u003c/code\u003e, \u003ccode class=\"literal\"\u003ecsv\u003c/code\u003e, \u003ccode class=\"literal\"\u003ehtml\u003c/code\u003e, \u003ccode class=\"literal\"\u003elatex\u003c/code\u003e, \u003ccode class=\"literal\"\u003elatex-longtable\u003c/code\u003e, \u003ccode class=\"literal\"\u003etroff-ms\u003c/code\u003e, \u003ccode class=\"literal\"\u003eunaligned\u003c/code\u003e, or \u003ccode class=\"literal\"\u003ewrapped\u003c/code\u003e. Unique abbreviations are allowed.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003ealigned\u003c/code\u003e format is the standard, human-readable, nicely formatted text output; this is the default.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eunaligned\u003c/code\u003e format writes all columns of a row on one line, separated by the currently active field separator. This is useful for creating output that might be intended to be read in by other programs, for example, tab-separated or comma-separated format. However, the field separator character is not treated specially if it appears in a column's value; so CSV format may be better suited for such purposes.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003ecsv\u003c/code\u003e format  writes column values separated by commas, applying the quoting rules described in \u003ca class=\"ulink\" href=\"https://datatracker.ietf.org/doc/html/rfc4180\"\u003eRFC 4180\u003c/a\u003e. This output is compatible with the CSV format of the server's \u003ccode class=\"command\"\u003eCOPY\u003c/code\u003e command. A header line with column names is generated unless the \u003ccode class=\"literal\"\u003etuples_only\u003c/code\u003e parameter is \u003ccode class=\"literal\"\u003eon\u003c/code\u003e. Titles and footers are not printed. Each row is terminated by the system-dependent end-of-line character, which is typically a single newline (\u003ccode class=\"literal\"\u003e\\n\u003c/code\u003e) for Unix-like systems or a carriage return and newline sequence (\u003ccode class=\"literal\"\u003e\\r\\n\u003c/code\u003e) for Microsoft Windows. Field separator characters other than comma can be selected with \u003ccode class=\"command\"\u003e\\pset csv_fieldsep\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003ewrapped\u003c/code\u003e format is like \u003ccode class=\"literal\"\u003ealigned\u003c/code\u003e but wraps wide data values across lines to make the output fit in the target column width. The target width is determined as described under the \u003ccode class=\"literal\"\u003ecolumns\u003c/code\u003e option. Note that \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will not attempt to wrap column header titles; therefore, \u003ccode class=\"literal\"\u003ewrapped\u003c/code\u003e format behaves the same as \u003ccode class=\"literal\"\u003ealigned\u003c/code\u003e if the total width needed for column headers exceeds the target.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode class=\"literal\"\u003easciidoc\u003c/code\u003e, \u003ccode class=\"literal\"\u003ehtml\u003c/code\u003e, \u003ccode class=\"literal\"\u003elatex\u003c/code\u003e, \u003ccode class=\"literal\"\u003elatex-longtable\u003c/code\u003e, and \u003ccode class=\"literal\"\u003etroff-ms\u003c/code\u003e formats 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 necessary in HTML, but in \u003cspan class=\"application\"\u003eLaTeX\u003c/span\u003e you must have a complete document wrapper. The \u003ccode class=\"literal\"\u003elatex\u003c/code\u003e format uses \u003cspan class=\"application\"\u003eLaTeX\u003c/span\u003e's \u003ccode class=\"literal\"\u003etabular\u003c/code\u003e environment. The \u003ccode class=\"literal\"\u003elatex-longtable\u003c/code\u003e format requires the \u003cspan class=\"application\"\u003eLaTeX\u003c/span\u003e \u003ccode class=\"literal\"\u003elongtable\u003c/code\u003e and \u003ccode class=\"literal\"\u003ebooktabs\u003c/code\u003e packages.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-LINESTYLE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003elinestyle\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the border line drawing style to one of \u003ccode class=\"literal\"\u003eascii\u003c/code\u003e, \u003ccode class=\"literal\"\u003eold-ascii\u003c/code\u003e, or \u003ccode class=\"literal\"\u003eunicode\u003c/code\u003e. Unique abbreviations are allowed. (That would mean one letter is enough.) The default setting is \u003ccode class=\"literal\"\u003eascii\u003c/code\u003e. This option only affects the \u003ccode class=\"literal\"\u003ealigned\u003c/code\u003e and \u003ccode class=\"literal\"\u003ewrapped\u003c/code\u003e output formats.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eascii\u003c/code\u003e style uses plain ASCII characters. Newlines in data are shown using a \u003ccode class=\"literal\"\u003e+\u003c/code\u003e symbol in the right-hand margin. When the \u003ccode class=\"literal\"\u003ewrapped\u003c/code\u003e format wraps data from one line to the next without a newline character, a dot (\u003ccode class=\"literal\"\u003e.\u003c/code\u003e) is shown in the right-hand margin of the first line, and again in the left-hand margin of the following line.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eold-ascii\u003c/code\u003e style uses plain ASCII characters, using the formatting style used in \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 8.4 and earlier. Newlines in data are shown using a \u003ccode class=\"literal\"\u003e:\u003c/code\u003e symbol in place of the left-hand column separator. When the data is wrapped from one line to the next without a newline character, a \u003ccode class=\"literal\"\u003e;\u003c/code\u003e symbol is used in place of the left-hand column separator.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eunicode\u003c/code\u003e style uses Unicode box-drawing characters. Newlines in data are shown using a carriage return symbol in the right-hand margin. When the data is wrapped from one line to the next without a newline character, an ellipsis symbol is shown in the right-hand margin of the first line, and again in the left-hand margin of the following line.\u003c/p\u003e\n\u003cp\u003eWhen the \u003ccode class=\"literal\"\u003eborder\u003c/code\u003e setting is greater than zero, the \u003ccode class=\"literal\"\u003elinestyle\u003c/code\u003e option also determines the characters with which the border lines are drawn. Plain ASCII characters work everywhere, but Unicode characters look nicer on displays that recognize them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-NULL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003enull\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the string to be printed in place of a null value. The default is to print nothing, which can easily be mistaken for an empty string. For example, one might prefer \u003ccode class=\"literal\"\u003e\\pset null '(null)'\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-NUMERICLOCALE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003enumericlocale\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is specified it must be either \u003ccode class=\"literal\"\u003eon\u003c/code\u003e or \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e which will enable or disable display of a locale-specific character to separate groups of digits to the left of the decimal marker. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is omitted the command toggles between regular and locale-specific numeric output.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-PAGER\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003epager\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eControls use of a pager program for query and \u003cspan class=\"application\"\u003epsql\u003c/span\u003e help output. When the \u003ccode class=\"literal\"\u003epager\u003c/code\u003e option is \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e, the pager program is not used. When the \u003ccode class=\"literal\"\u003epager\u003c/code\u003e option is \u003ccode class=\"literal\"\u003eon\u003c/code\u003e, the pager is used when appropriate, i.e., when the output is to a terminal and will not fit on the screen. The \u003ccode class=\"literal\"\u003epager\u003c/code\u003e option can also be set to \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e, which causes the pager to be used for all terminal output regardless of whether it fits on the screen. \u003ccode class=\"literal\"\u003e\\pset pager\u003c/code\u003e without a \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e toggles pager use on and off.\u003c/p\u003e\n\u003cp\u003eIf the environment variable \u003ccode class=\"envar\"\u003ePSQL_PAGER\u003c/code\u003e or \u003ccode class=\"envar\"\u003ePAGER\u003c/code\u003e is set, output to be paged is piped to the specified program. Otherwise a platform-dependent default program (such as \u003ccode class=\"filename\"\u003emore\u003c/code\u003e) is used.\u003c/p\u003e\n\u003cp\u003eWhen using the \u003ccode class=\"literal\"\u003e\\watch\u003c/code\u003e command to execute a query repeatedly, the environment variable \u003ccode class=\"envar\"\u003ePSQL_WATCH_PAGER\u003c/code\u003e is used to find the pager program instead, on Unix systems. This is configured separately because it may confuse traditional pagers, but can be used to send output to tools that understand \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's output format (such as \u003ccode class=\"filename\"\u003epspg --stream\u003c/code\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-PAGER-MIN-LINES\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003epager_min_lines\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003ccode class=\"literal\"\u003epager_min_lines\u003c/code\u003e is set to a number greater than the page height, the pager program will not be called unless there are at least this many lines of output to show. The default setting is 0.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-RECORDSEP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003erecordsep\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the record (line) separator to use in unaligned output format. The default is a newline character.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-RECORDSEP-ZERO\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003erecordsep_zero\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the record separator to use in unaligned output format to a zero byte.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-TABLEATTR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003etableattr\u003c/code\u003e (or \u003ccode class=\"literal\"\u003eT\u003c/code\u003e)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIn HTML format, this specifies attributes to be placed inside the \u003ccode class=\"sgmltag-element\"\u003etable\u003c/code\u003e tag. This could for example be \u003ccode class=\"literal\"\u003ecellpadding\u003c/code\u003e or \u003ccode class=\"literal\"\u003ebgcolor\u003c/code\u003e. Note that you probably don't want to specify \u003ccode class=\"literal\"\u003eborder\u003c/code\u003e here, as that is already taken care of by \u003ccode class=\"literal\"\u003e\\pset border\u003c/code\u003e. If no \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is given, the table attributes are unset.\u003c/p\u003e\n\u003cp\u003eIn \u003ccode class=\"literal\"\u003elatex-longtable\u003c/code\u003e format, this controls the proportional width of each column containing a left-aligned data type. It is specified as a whitespace-separated list of values, e.g., \u003ccode class=\"literal\"\u003e'0.2 0.2 0.6'\u003c/code\u003e. Unspecified output columns use the last specified value.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-TITLE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003etitle\u003c/code\u003e (or \u003ccode class=\"literal\"\u003eC\u003c/code\u003e)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the table title for any subsequently printed tables. This can be used to give your output descriptive tags. If no \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is given, the title is unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-TUPLES-ONLY\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003etuples_only\u003c/code\u003e (or \u003ccode class=\"literal\"\u003et\u003c/code\u003e)\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is specified it must be either \u003ccode class=\"literal\"\u003eon\u003c/code\u003e or \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e which will enable or disable tuples-only mode. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is omitted the command toggles between regular and tuples-only output. Regular output includes extra information such as column headers, titles, and various footers. In tuples-only mode, only actual table data is shown.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-UNICODE-BORDER-LINESTYLE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eunicode_border_linestyle\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the border drawing style for the \u003ccode class=\"literal\"\u003eunicode\u003c/code\u003e line style to one of \u003ccode class=\"literal\"\u003esingle\u003c/code\u003e or \u003ccode class=\"literal\"\u003edouble\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-UNICODE-COLUMN-LINESTYLE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eunicode_column_linestyle\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the column drawing style for the \u003ccode class=\"literal\"\u003eunicode\u003c/code\u003e line style to one of \u003ccode class=\"literal\"\u003esingle\u003c/code\u003e or \u003ccode class=\"literal\"\u003edouble\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-UNICODE-HEADER-LINESTYLE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eunicode_header_linestyle\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the header drawing style for the \u003ccode class=\"literal\"\u003eunicode\u003c/code\u003e line style to one of \u003ccode class=\"literal\"\u003esingle\u003c/code\u003e or \u003ccode class=\"literal\"\u003edouble\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PSET-XHEADER-WIDTH\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003exheader_width\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the maximum width of the header for expanded output to one of \u003ccode class=\"literal\"\u003efull\u003c/code\u003e (the default value), \u003ccode class=\"literal\"\u003ecolumn\u003c/code\u003e, \u003ccode class=\"literal\"\u003epage\u003c/code\u003e, or an \u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger value\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003efull\u003c/code\u003e: the expanded header is not truncated, and will be as wide as the widest output line.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003ecolumn\u003c/code\u003e: truncate the header line to the width of the first column.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003epage\u003c/code\u003e: truncate the header line to the terminal width.\u003c/p\u003e\n\u003cp\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003einteger value\u003c/code\u003e\u003c/em\u003e: specify the exact maximum width of the header line.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eIllustrations of how these different formats look can be seen in \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-EXAMPLES\" title=\"Examples\"\u003eExamples\u003c/a\u003e, below.\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eThere are various shortcut commands for \u003ccode class=\"command\"\u003e\\pset\u003c/code\u003e. See \u003ccode class=\"command\"\u003e\\a\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\C\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\f\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\H\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\t\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\T\u003c/code\u003e, and \u003ccode class=\"command\"\u003e\\x\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-QUIT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\q\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\quit\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eQuits the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e program. In a script file, only execution of that script is terminated.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-QECHO\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\qecho \u003cem class=\"replaceable\"\u003e\u003ccode\u003etext\u003c/code\u003e\u003c/em\u003e [ ... ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command is identical to \u003ccode class=\"command\"\u003e\\echo\u003c/code\u003e except that the output will be written to the query output channel, as set by \u003ccode class=\"command\"\u003e\\o\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-RESET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\r\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\reset\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eResets (clears) the query buffer.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-RESTRICT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\restrict \u003cem class=\"replaceable\"\u003e\u003ccode\u003erestrict_key\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnter \"restricted\" mode with the provided key. In this mode, the only allowed meta-command is \u003ccode class=\"command\"\u003e\\unrestrict\u003c/code\u003e, to exit restricted mode. The key may contain only alphanumeric characters.\u003c/p\u003e\n\u003cp\u003eThis command is primarily intended for use in plain-text dumps generated by \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e, \u003cspan class=\"application\"\u003epg_dumpall\u003c/span\u003e, and \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e, but it may be useful elsewhere.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-S\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\s [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's command line history to \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e. If \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e is omitted, the history is written to the standard output (using the pager if appropriate). This command is not available if \u003cspan class=\"application\"\u003epsql\u003c/span\u003e was built without \u003cspan class=\"application\"\u003eReadline\u003c/span\u003e support.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-SET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\set [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e [ ... ] ] ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variable \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e to \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e, 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 \u003ccode class=\"command\"\u003e\\unset\u003c/code\u003e command.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003e\\set\u003c/code\u003e without any arguments displays the names and values of all currently-set \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variables.\u003c/p\u003e\n\u003cp\u003eValid variable names can contain letters, digits, and underscores. See \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-VARIABLES\" title=\"Variables\"\u003eVariables\u003c/a\u003e below for details. Variable names are case-sensitive.\u003c/p\u003e\n\u003cp\u003eCertain variables are special, in that they control \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's behavior or are automatically set to reflect connection state. These variables are documented in \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-VARIABLES\" title=\"Variables\"\u003eVariables\u003c/a\u003e, below.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis command is unrelated to the SQL command \u003ca class=\"link\" href=\"/docs/18/sql-set.html\" title=\"SET\"\u003e\u003ccode class=\"command\"\u003eSET\u003c/code\u003e\u003c/a\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-SETENV\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\setenv \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the environment variable \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e to \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e, or if the \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e is not supplied, unsets the environment variable. Example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\setenv PAGER less\u003c/code\u003e\u003c/strong\u003e\ntestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\setenv LESS -imx4F\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-SF\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\sf[+] \u003cem class=\"replaceable\"\u003e\u003ccode\u003efunction_description\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command fetches and shows the definition of the named function or procedure, in the form of a \u003ccode class=\"command\"\u003eCREATE OR REPLACE FUNCTION\u003c/code\u003e or \u003ccode class=\"command\"\u003eCREATE OR REPLACE PROCEDURE\u003c/code\u003e command. The definition is printed to the current query output channel, as set by \u003ccode class=\"command\"\u003e\\o\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe target function can be specified by name alone, or by name and arguments, for example \u003ccode class=\"literal\"\u003efoo(integer, text)\u003c/code\u003e. The argument types must be given if there is more than one function of the same name.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, then the output lines are numbered, with the first line of the function body being line 1.\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument(s) of \u003ccode class=\"command\"\u003e\\sf\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-SV\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\sv[+] \u003cem class=\"replaceable\"\u003e\u003ccode\u003eview_name\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command fetches and shows the definition of the named view, in the form of a \u003ccode class=\"command\"\u003eCREATE OR REPLACE VIEW\u003c/code\u003e command. The definition is printed to the current query output channel, as set by \u003ccode class=\"command\"\u003e\\o\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode class=\"literal\"\u003e+\u003c/code\u003e is appended to the command name, then the output lines are numbered from 1.\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument(s) of \u003ccode class=\"command\"\u003e\\sv\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-PIPELINE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\startpipeline\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\sendpipeline\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\syncpipeline\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\endpipeline\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\flushrequest\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\flush\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\getresults [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber_results\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis group of commands implements pipelining of SQL statements. A pipeline must begin with a \u003ccode class=\"command\"\u003e\\startpipeline\u003c/code\u003e and end with an \u003ccode class=\"command\"\u003e\\endpipeline\u003c/code\u003e. In between there may be any number of \u003ccode class=\"command\"\u003e\\syncpipeline\u003c/code\u003e commands, which sends a \u003ca class=\"link\" href=\"/docs/18/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY\" title=\"54.2.3. Extended Query\"\u003esync message\u003c/a\u003e 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 \u003ca class=\"xref\" href=\"/docs/18/libpq-pipeline-mode.html\" title=\"32.5. Pipeline Mode\"\u003eSection 32.5\u003c/a\u003e for more details.\u003c/p\u003e\n\u003cp\u003eAll queries executed while a pipeline is ongoing use the extended query protocol. Queries are appended to the pipeline when ending with a semicolon. The meta-commands \u003ccode class=\"literal\"\u003e\\bind\u003c/code\u003e, \u003ccode class=\"literal\"\u003e\\bind_named\u003c/code\u003e, \u003ccode class=\"literal\"\u003e\\close_prepared\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\parse\u003c/code\u003e can be used in an ongoing pipeline. While a pipeline is ongoing, \u003ccode class=\"literal\"\u003e\\sendpipeline\u003c/code\u003e will append the current query buffer to the pipeline. Other meta-commands like \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e, \u003ccode class=\"literal\"\u003e\\gx\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\gdesc\u003c/code\u003e are not allowed in pipeline mode.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003e\\flushrequest\u003c/code\u003e appends a flush command to the pipeline, allowing to read results with \u003ccode class=\"command\"\u003e\\getresults\u003c/code\u003e without issuing a sync or ending the pipeline. \u003ccode class=\"command\"\u003e\\getresults\u003c/code\u003e will automatically push unsent data to the server. \u003ccode class=\"command\"\u003e\\flush\u003c/code\u003e can be used to manually push unsent data.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003e\\getresults\u003c/code\u003e accepts an optional \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber_results\u003c/code\u003e\u003c/em\u003e parameter. If provided, only the first \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber_results\u003c/code\u003e\u003c/em\u003e pending results will be read. If not provided or \u003ccode class=\"literal\"\u003e0\u003c/code\u003e, all pending results are read.\u003c/p\u003e\n\u003cp\u003eWhen pipeline mode is active, a dedicated prompt variable is available to report the pipeline status. See \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PROMPTING-P-UC\"\u003e\u003ccode class=\"literal\"\u003e%P\u003c/code\u003e\u003c/a\u003e for more details\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"command\"\u003eCOPY\u003c/code\u003e is not supported while in pipeline mode.\u003c/p\u003e\n\u003cp\u003eExample:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e\\startpipeline\nSELECT * FROM pg_class;\nSELECT 1 \\bind \\sendpipeline\n\\flushrequest\n\\getresults\n\\endpipeline\n\u003c/pre\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-T-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\t\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eToggles the display of output column name headings and row count footer. This command is equivalent to \u003ccode class=\"literal\"\u003e\\pset tuples_only\u003c/code\u003e and is provided for convenience.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-T-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\T \u003cem class=\"replaceable\"\u003e\u003ccode\u003etable_options\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies attributes to be placed within the \u003ccode class=\"sgmltag-element\"\u003etable\u003c/code\u003e tag in HTML output format. This command is equivalent to \u003ccode class=\"literal\"\u003e\\pset tableattr \u003cem class=\"replaceable\"\u003e\u003ccode\u003etable_options\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-TIMING\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\timing [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eon\u003c/code\u003e\u003c/em\u003e | \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoff\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWith 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-UNRESTRICT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\unrestrict \u003cem class=\"replaceable\"\u003e\u003ccode\u003erestrict_key\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eExit \"restricted\" mode (i.e., where all other meta-commands are blocked), provided the specified key matches the one given to \u003ccode class=\"command\"\u003e\\restrict\u003c/code\u003e when restricted mode was entered.\u003c/p\u003e\n\u003cp\u003eThis command is primarily intended for use in plain-text dumps generated by \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e, \u003cspan class=\"application\"\u003epg_dumpall\u003c/span\u003e, and \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e, but it may be useful elsewhere.\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument of \u003ccode class=\"command\"\u003e\\unrestrict\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-UNSET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\unset \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUnsets (deletes) the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variable \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eMost variables that control \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's behavior cannot be unset; instead, an \u003ccode class=\"literal\"\u003e\\unset\u003c/code\u003e command is interpreted as setting them to their default values. See \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-VARIABLES\" title=\"Variables\"\u003eVariables\u003c/a\u003e below.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-WRITE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\w\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\write\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\w\u003c/code\u003e or \u003ccode class=\"literal\"\u003e\\write\u003c/code\u003e \u003ccode class=\"literal\"\u003e|\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWrites the current query buffer to the file \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e or pipes it to the shell command \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e. If the current query buffer is empty, the most recently executed query is written instead.\u003c/p\u003e\n\u003cp\u003eIf the argument begins with \u003ccode class=\"literal\"\u003e|\u003c/code\u003e, then the entire remainder of the line is taken to be the \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e to execute, and neither variable interpolation nor backquote expansion are performed in it. The rest of the line is simply passed literally to the shell.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-WARN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\warn \u003cem class=\"replaceable\"\u003e\u003ccode\u003etext\u003c/code\u003e\u003c/em\u003e [ ... ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis command is identical to \u003ccode class=\"command\"\u003e\\echo\u003c/code\u003e except that the output will be written to \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's standard error channel, rather than standard output.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-WATCH\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\watch [ i[nterval]=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e ] [ c[ount]=\u003cem class=\"replaceable\"\u003e\u003ccode\u003etimes\u003c/code\u003e\u003c/em\u003e ] [ m[in_rows]=\u003cem class=\"replaceable\"\u003e\u003ccode\u003erows\u003c/code\u003e\u003c/em\u003e ] [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRepeatedly execute the current query buffer (as \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e 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 \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-VARIABLES-WATCH-INTERVAL\"\u003e\u003ccode class=\"varname\"\u003eWATCH_INTERVAL\u003c/code\u003e\u003c/a\u003e. For backwards compatibility, \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e can be specified with or without an \u003ccode class=\"literal\"\u003einterval=\u003c/code\u003e prefix. Each query result is displayed with a header that includes the \u003ccode class=\"literal\"\u003e\\pset title\u003c/code\u003e string (if any), the time as of query start, and the delay interval.\u003c/p\u003e\n\u003cp\u003eIf the current query buffer is empty, the most recently sent query is re-executed instead.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-X\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\x [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eon\u003c/code\u003e\u003c/em\u003e | \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoff\u003c/code\u003e\u003c/em\u003e | \u003cem class=\"replaceable\"\u003e\u003ccode\u003eauto\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets or toggles expanded table formatting mode. As such it is equivalent to \u003ccode class=\"literal\"\u003e\\pset expanded\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-Z\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\z[Sx] [ \u003ca class=\"link\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e\u003c/a\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLists tables, views and sequences with their associated access privileges. If a \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e 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 \u003ccode class=\"literal\"\u003eS\u003c/code\u003e modifier to include system objects. If \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is appended to the command name, the results are displayed in expanded mode.\u003c/p\u003e\n\u003cp\u003eThis is an alias for \u003ccode class=\"command\"\u003e\\dp\u003c/code\u003e (\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003edisplay privileges\u003c/span\u003e”\u003c/span\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-EXCLAMATION-MARK\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\! [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWith no argument, escapes to a sub-shell; \u003cspan class=\"application\"\u003epsql\u003c/span\u003e resumes when the sub-shell exits. With an argument, executes the shell command \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e.\u003c/p\u003e\n\u003cp\u003eUnlike most other meta-commands, the entire remainder of the line is always taken to be the argument(s) of \u003ccode class=\"command\"\u003e\\!\u003c/code\u003e, and neither variable interpolation nor backquote expansion are performed in the arguments. The rest of the line is simply passed literally to the shell.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-QUESTION-MARK\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\? [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003etopic\u003c/code\u003e\u003c/em\u003e ]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShows help information. The optional \u003cem class=\"replaceable\"\u003e\u003ccode\u003etopic\u003c/code\u003e\u003c/em\u003e parameter (defaulting to \u003ccode class=\"literal\"\u003ecommands\u003c/code\u003e) selects which part of \u003cspan class=\"application\"\u003epsql\u003c/span\u003e is explained: \u003ccode class=\"literal\"\u003ecommands\u003c/code\u003e describes \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's backslash commands; \u003ccode class=\"literal\"\u003eoptions\u003c/code\u003e describes the command-line options that can be passed to \u003cspan class=\"application\"\u003epsql\u003c/span\u003e; and \u003ccode class=\"literal\"\u003evariables\u003c/code\u003e shows help about \u003cspan class=\"application\"\u003epsql\u003c/span\u003e configuration variables.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-META-COMMAND-SEMICOLON\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e\\;\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBackslash-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.\u003c/p\u003e\n\u003cp\u003eNormally, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will dispatch an SQL command to the server as soon as it reaches the command-ending semicolon, even if more input remains on the current line. Thus for example entering\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eselect 1; select 2; select 3;\n\u003c/pre\u003e\n\u003cp\u003ewill result in the three SQL commands being individually sent to the server, with each one's results being displayed before continuing to the next command. However, a semicolon entered as \u003ccode class=\"literal\"\u003e\\;\u003c/code\u003e will not trigger command processing, so that the command before it and the one after are effectively combined and sent to the server in one request. So for example\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eselect 1\\; select 2\\; select 3;\n\u003c/pre\u003e\n\u003cp\u003eresults in sending the three SQL commands to the server in a single request, when the non-backslashed semicolon is reached. The server executes such a request as a single transaction, unless there are explicit \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e/\u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e commands included in the string to divide it into multiple transactions. (See \u003ca class=\"xref\" href=\"/docs/18/protocol-flow.html#PROTOCOL-FLOW-MULTI-STATEMENT\" title=\"54.2.2.1. Multiple Statements in a Simple Query\"\u003eSection 54.2.2.1\u003c/a\u003e for more details about how the server handles multi-query strings.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect3\" id=\"APP-PSQL-PATTERNS\"\u003e\n\u003ch4\u003ePatterns\u003c/h4\u003e\n\u003cp\u003eThe various \u003ccode class=\"literal\"\u003e\\d\u003c/code\u003e commands accept a \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e parameter to specify the object name(s) to be displayed. In the simplest case, a pattern is just the exact name of the object. The characters within a pattern are normally folded to lower case, just as in SQL names; for example, \u003ccode class=\"literal\"\u003e\\dt FOO\u003c/code\u003e will display the table named \u003ccode class=\"literal\"\u003efoo\u003c/code\u003e. As in SQL names, placing double quotes around a pattern stops folding to lower case. Should you need to include an actual double quote character in a pattern, write it as a pair of double quotes within a double-quote sequence; again this is in accord with the rules for SQL quoted identifiers. For example, \u003ccode class=\"literal\"\u003e\\dt \"FOO\"\"BAR\"\u003c/code\u003e will display the table named \u003ccode class=\"literal\"\u003eFOO\"BAR\u003c/code\u003e (not \u003ccode class=\"literal\"\u003efoo\"bar\u003c/code\u003e). Unlike the normal rules for SQL names, you can put double quotes around just part of a pattern, for instance \u003ccode class=\"literal\"\u003e\\dt FOO\"FOO\"BAR\u003c/code\u003e will display the table named \u003ccode class=\"literal\"\u003efooFOObar\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eWhenever the \u003cem class=\"replaceable\"\u003e\u003ccode\u003epattern\u003c/code\u003e\u003c/em\u003e parameter is omitted completely, the \u003ccode class=\"literal\"\u003e\\d\u003c/code\u003e commands display all objects that are visible in the current schema search path — this is equivalent to using \u003ccode class=\"literal\"\u003e*\u003c/code\u003e as the pattern. (An object is said to be \u003cem class=\"firstterm\"\u003evisible\u003c/em\u003e if its containing schema is in the search path and no object of the same kind and name appears earlier in the search path. This is equivalent to the statement that the object can be referenced by name without explicit schema qualification.) To see all objects in the database regardless of visibility, use \u003ccode class=\"literal\"\u003e*.*\u003c/code\u003e as the pattern.\u003c/p\u003e\n\u003cp\u003eWithin a pattern, \u003ccode class=\"literal\"\u003e*\u003c/code\u003e matches any sequence of characters (including no characters) and \u003ccode class=\"literal\"\u003e?\u003c/code\u003e matches any single character. (This notation is comparable to Unix shell file name patterns.) For example, \u003ccode class=\"literal\"\u003e\\dt int*\u003c/code\u003e displays tables whose names begin with \u003ccode class=\"literal\"\u003eint\u003c/code\u003e. But within double quotes, \u003ccode class=\"literal\"\u003e*\u003c/code\u003e and \u003ccode class=\"literal\"\u003e?\u003c/code\u003e lose these special meanings and are just matched literally.\u003c/p\u003e\n\u003cp\u003eA relation pattern that contains a dot (\u003ccode class=\"literal\"\u003e.\u003c/code\u003e) is interpreted as a schema name pattern followed by an object name pattern. For example, \u003ccode class=\"literal\"\u003e\\dt foo*.*bar*\u003c/code\u003e displays all tables whose table name includes \u003ccode class=\"literal\"\u003ebar\u003c/code\u003e that are in schemas whose schema name starts with \u003ccode class=\"literal\"\u003efoo\u003c/code\u003e. When no dot appears, then the pattern matches only objects that are visible in the current schema search path. Again, a dot within double quotes loses its special meaning and is matched literally. A relation pattern that contains two dots (\u003ccode class=\"literal\"\u003e.\u003c/code\u003e) is interpreted as a database name followed by a schema name pattern followed by an object name pattern. The database name portion will not be treated as a pattern and must match the name of the currently connected database, else an error will be raised.\u003c/p\u003e\n\u003cp\u003eA schema pattern that contains a dot (\u003ccode class=\"literal\"\u003e.\u003c/code\u003e) is interpreted as a database name followed by a schema name pattern. For example, \u003ccode class=\"literal\"\u003e\\dn mydb.*foo*\u003c/code\u003e displays all schemas whose schema name includes \u003ccode class=\"literal\"\u003efoo\u003c/code\u003e. The database name portion will not be treated as a pattern and must match the name of the currently connected database, else an error will be raised.\u003c/p\u003e\n\u003cp\u003eAdvanced users can use regular-expression notations such as character classes, for example \u003ccode class=\"literal\"\u003e[0-9]\u003c/code\u003e to match any digit. All regular expression special characters work as specified in \u003ca class=\"xref\" href=\"/docs/18/functions-matching.html#FUNCTIONS-POSIX-REGEXP\" title=\"9.7.3. POSIX Regular Expressions\"\u003eSection 9.7.3\u003c/a\u003e, except for \u003ccode class=\"literal\"\u003e.\u003c/code\u003e which is taken as a separator as mentioned above, \u003ccode class=\"literal\"\u003e*\u003c/code\u003e which is translated to the regular-expression notation \u003ccode class=\"literal\"\u003e.*\u003c/code\u003e, \u003ccode class=\"literal\"\u003e?\u003c/code\u003e which is translated to \u003ccode class=\"literal\"\u003e.\u003c/code\u003e, and \u003ccode class=\"literal\"\u003e$\u003c/code\u003e which is matched literally. You can emulate these pattern characters at need by writing \u003ccode class=\"literal\"\u003e?\u003c/code\u003e for \u003ccode class=\"literal\"\u003e.\u003c/code\u003e, \u003ccode class=\"literal\"\u003e(\u003cem class=\"replaceable\"\u003e\u003ccode\u003eR\u003c/code\u003e\u003c/em\u003e+|)\u003c/code\u003e for \u003ccode class=\"literal\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eR\u003c/code\u003e\u003c/em\u003e*\u003c/code\u003e, or \u003ccode class=\"literal\"\u003e(\u003cem class=\"replaceable\"\u003e\u003ccode\u003eR\u003c/code\u003e\u003c/em\u003e|)\u003c/code\u003e for \u003ccode class=\"literal\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003eR\u003c/code\u003e\u003c/em\u003e?\u003c/code\u003e. \u003ccode class=\"literal\"\u003e$\u003c/code\u003e is not needed as a regular-expression character since the pattern must match the whole name, unlike the usual interpretation of regular expressions (in other words, \u003ccode class=\"literal\"\u003e$\u003c/code\u003e is automatically appended to your pattern). Write \u003ccode class=\"literal\"\u003e*\u003c/code\u003e at the beginning and/or end if you don't wish the pattern to be anchored. Note that within double quotes, all regular expression special characters lose their special meanings and are matched literally. Also, the regular expression special characters are matched literally in operator name patterns (i.e., the argument of \u003ccode class=\"literal\"\u003e\\do\u003c/code\u003e).\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"id-1.9.4.21.8.5\"\u003e\n\u003ch3\u003eAdvanced Features\u003c/h3\u003e\n\u003cdiv class=\"refsect3\" id=\"APP-PSQL-VARIABLES\"\u003e\n\u003ch4\u003eVariables\u003c/h4\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e provides variable substitution features similar to common Unix command shells. Variables are simply name/value pairs, where the value can be any string of any length. The name must consist of letters (including non-Latin letters), digits, and underscores.\u003c/p\u003e\n\u003cp\u003eTo set a variable, use the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e meta-command \u003ccode class=\"command\"\u003e\\set\u003c/code\u003e. For example,\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\set foo bar\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003esets the variable \u003ccode class=\"literal\"\u003efoo\u003c/code\u003e to the value \u003ccode class=\"literal\"\u003ebar\u003c/code\u003e. To retrieve the content of the variable, precede the name with a colon, for example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\echo :foo\u003c/code\u003e\u003c/strong\u003e\nbar\n\u003c/pre\u003e\n\u003cp\u003eThis works in both regular SQL commands and meta-commands; there is more detail in \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-INTERPOLATION\" title=\"SQL Interpolation\"\u003eSQL Interpolation\u003c/a\u003e, below.\u003c/p\u003e\n\u003cp\u003eIf you call \u003ccode class=\"command\"\u003e\\set\u003c/code\u003e without a second argument, the variable is set to an empty-string value. To unset (i.e., delete) a variable, use the command \u003ccode class=\"command\"\u003e\\unset\u003c/code\u003e. To show the values of all variables, call \u003ccode class=\"command\"\u003e\\set\u003c/code\u003e without any argument.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eThe arguments of \u003ccode class=\"command\"\u003e\\set\u003c/code\u003e are subject to the same substitution rules as with other commands. Thus you can construct interesting references such as \u003ccode class=\"literal\"\u003e\\set :foo 'something'\u003c/code\u003e and get \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003esoft links\u003c/span\u003e”\u003c/span\u003e or \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003evariable variables\u003c/span\u003e”\u003c/span\u003e of \u003cspan class=\"productname\"\u003ePerl\u003c/span\u003e or \u003cspan class=\"productname\"\u003ePHP\u003c/span\u003e fame, respectively. Unfortunately (or fortunately?), there is no way to do anything useful with these constructs. On the other hand, \u003ccode class=\"literal\"\u003e\\set bar :foo\u003c/code\u003e is a perfectly valid way to copy a variable.\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eA number of these variables are treated specially by \u003cspan class=\"application\"\u003epsql\u003c/span\u003e. They represent certain option settings that can be changed at run time by altering the value of the variable, or in some cases represent changeable state of \u003cspan class=\"application\"\u003epsql\u003c/span\u003e. By convention, all specially treated variables' names consist of all upper-case ASCII letters (and possibly digits and underscores). To ensure maximum compatibility in the future, avoid using such variable names for your own purposes.\u003c/p\u003e\n\u003cp\u003eVariables that control \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's behavior generally cannot be unset or set to invalid values. An \u003ccode class=\"literal\"\u003e\\unset\u003c/code\u003e command is allowed but is interpreted as setting the variable to its default value. A \u003ccode class=\"literal\"\u003e\\set\u003c/code\u003e command without a second argument is interpreted as setting the variable to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e, for control variables that accept that value, and is rejected for others. Also, control variables that accept the values \u003ccode class=\"literal\"\u003eon\u003c/code\u003e and \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e will also accept other common spellings of Boolean values, such as \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e and \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe specially treated variables are:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-AUTOCOMMIT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eAUTOCOMMIT\u003c/code\u003e \u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen \u003ccode class=\"literal\"\u003eon\u003c/code\u003e (the default), each SQL command is automatically committed upon successful completion. To postpone commit in this mode, you must enter a \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e or \u003ccode class=\"command\"\u003eSTART TRANSACTION\u003c/code\u003e SQL command. When \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e or unset, SQL commands are not committed until you explicitly issue \u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e or \u003ccode class=\"command\"\u003eEND\u003c/code\u003e. The autocommit-off mode works by issuing an implicit \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e for you, just before any command that is not already in a transaction block and is not itself a \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e or other transaction-control command, nor a command that cannot be executed inside a transaction block (such as \u003ccode class=\"command\"\u003eVACUUM\u003c/code\u003e).\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eIn autocommit-off mode, you must explicitly abandon any failed transaction by entering \u003ccode class=\"command\"\u003eABORT\u003c/code\u003e or \u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e. Also keep in mind that if you exit the session without committing, your work will be lost.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eThe autocommit-on mode is \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e's traditional behavior, but autocommit-off is closer to the SQL spec. If you prefer autocommit-off, you might wish to set it in the system-wide \u003ccode class=\"filename\"\u003epsqlrc\u003c/code\u003e file or your \u003ccode class=\"filename\"\u003e~/.psqlrc\u003c/code\u003e file.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-COMP-KEYWORD-CASE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eCOMP_KEYWORD_CASE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDetermines which letter case to use when completing an SQL key word. If set to \u003ccode class=\"literal\"\u003elower\u003c/code\u003e or \u003ccode class=\"literal\"\u003eupper\u003c/code\u003e, the completed word will be in lower or upper case, respectively. If set to \u003ccode class=\"literal\"\u003epreserve-lower\u003c/code\u003e or \u003ccode class=\"literal\"\u003epreserve-upper\u003c/code\u003e (the default), the completed word will be in the case of the word already entered, but words being completed without anything entered will be in lower or upper case, respectively.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-DBNAME\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eDBNAME\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe name of the database you are currently connected to. This is set every time you connect to a database (including program start-up), but can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ECHO\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eECHO\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf set to \u003ccode class=\"literal\"\u003eall\u003c/code\u003e, all nonempty input lines are printed to standard output as they are read. (This does not apply to lines read interactively.) To select this behavior on program start-up, use the switch \u003ccode class=\"option\"\u003e-a\u003c/code\u003e. If set to \u003ccode class=\"literal\"\u003equeries\u003c/code\u003e, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e prints each query to standard output as it is sent to the server. The switch to select this behavior is \u003ccode class=\"option\"\u003e-e\u003c/code\u003e. If set to \u003ccode class=\"literal\"\u003eerrors\u003c/code\u003e, then only failed queries are displayed on standard error output. The switch for this behavior is \u003ccode class=\"option\"\u003e-b\u003c/code\u003e. If set to \u003ccode class=\"literal\"\u003enone\u003c/code\u003e (the default), then no queries are displayed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ECHO-HIDDEN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eECHO_HIDDEN\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen this variable is set to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e and a backslash command queries the database, the query is first shown. This feature helps you to study \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e internals and provide similar functionality in your own programs. (To select this behavior on program start-up, use the switch \u003ccode class=\"option\"\u003e-E\u003c/code\u003e.) If you set this variable to the value \u003ccode class=\"literal\"\u003enoexec\u003c/code\u003e, the queries are just shown but are not actually sent to the server and executed. The default value is \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ENCODING\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eENCODING\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe current client character set encoding. This is set every time you connect to a database (including program start-up), and when you change the encoding with \u003ccode class=\"literal\"\u003e\\encoding\u003c/code\u003e, but it can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ERROR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eERROR\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003etrue\u003c/code\u003e if the last SQL query failed, \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e if it succeeded. See also \u003ccode class=\"varname\"\u003eSQLSTATE\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-FETCH-COUNT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eFETCH_COUNT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf this variable is set to an integer value greater than zero, the results of \u003ccode class=\"command\"\u003eSELECT\u003c/code\u003e queries are fetched and displayed in groups of that many rows, rather than the default behavior of collecting the entire result set before display. Therefore only a limited amount of memory is used, regardless of the size of the result set. Settings of 100 to 1000 are commonly used when enabling this feature. Keep in mind that when using this feature, a query might fail after having already displayed some rows.\u003c/p\u003e\n\u003cdiv class=\"tip\"\u003e\n\u003ch3 class=\"title\"\u003eTip\u003c/h3\u003e\n\u003cp\u003eAlthough you can use any output format with this feature, the default \u003ccode class=\"literal\"\u003ealigned\u003c/code\u003e format tends to look bad because each group of \u003ccode class=\"varname\"\u003eFETCH_COUNT\u003c/code\u003e rows will be formatted separately, leading to varying column widths across the row groups. The other output formats work better.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-HIDE-TABLEAM\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eHIDE_TABLEAM\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf this variable is set to \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e, a table's access method details are not displayed. This is mainly useful for regression tests.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-HIDE-TOAST-COMPRESSION\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eHIDE_TOAST_COMPRESSION\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf this variable is set to \u003ccode class=\"literal\"\u003etrue\u003c/code\u003e, column compression method details are not displayed. This is mainly useful for regression tests.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-HISTCONTROL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eHISTCONTROL\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf this variable is set to \u003ccode class=\"literal\"\u003eignorespace\u003c/code\u003e, lines which begin with a space are not entered into the history list. If set to a value of \u003ccode class=\"literal\"\u003eignoredups\u003c/code\u003e, lines matching the previous history line are not entered. A value of \u003ccode class=\"literal\"\u003eignoreboth\u003c/code\u003e combines the two options. If set to \u003ccode class=\"literal\"\u003enone\u003c/code\u003e (the default), all lines read in interactive mode are saved on the history list.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis feature was shamelessly plagiarized from \u003cspan class=\"application\"\u003eBash\u003c/span\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-HISTFILE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eHISTFILE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe file name that will be used to store the history list. If unset, the file name is taken from the \u003ccode class=\"envar\"\u003ePSQL_HISTORY\u003c/code\u003e environment variable. If that is not set either, the default is \u003ccode class=\"filename\"\u003e~/.psql_history\u003c/code\u003e, or \u003ccode class=\"filename\"\u003e%APPDATA%\\postgresql\\psql_history\u003c/code\u003e on Windows. For example, putting:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e\\set HISTFILE ~/.psql_history-:DBNAME\n\u003c/pre\u003e\n\u003cp\u003ein \u003ccode class=\"filename\"\u003e~/.psqlrc\u003c/code\u003e will cause \u003cspan class=\"application\"\u003epsql\u003c/span\u003e to maintain a separate history for each database.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis feature was shamelessly plagiarized from \u003cspan class=\"application\"\u003eBash\u003c/span\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-HISTSIZE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eHISTSIZE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe maximum number of commands to store in the command history (default 500). If set to a negative value, no limit is applied.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis feature was shamelessly plagiarized from \u003cspan class=\"application\"\u003eBash\u003c/span\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-HOST\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eHOST\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe database server host you are currently connected to. This is set every time you connect to a database (including program start-up), but can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-IGNOREEOF\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eIGNOREEOF\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf set to 1 or less, sending an EOF character (usually \u003cspan class=\"keycap\"\u003e\u003cstrong\u003eControl\u003c/strong\u003e\u003c/span\u003e+\u003cspan class=\"keycap\"\u003e\u003cstrong\u003eD\u003c/strong\u003e\u003c/span\u003e) to an interactive session of \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will terminate the application. If set to a larger numeric value, that many consecutive EOF characters must be typed to make an interactive session terminate. If the variable is set to a non-numeric value, it is interpreted as 10. The default is 0.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis feature was shamelessly plagiarized from \u003cspan class=\"application\"\u003eBash\u003c/span\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-LASTOID\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eLASTOID\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe value of the last affected OID, as returned from an \u003ccode class=\"command\"\u003eINSERT\u003c/code\u003e or \u003ccode class=\"command\"\u003e\\lo_import\u003c/code\u003e command. This variable is only guaranteed to be valid until after the result of the next SQL command has been displayed. \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e servers since version 12 do not support OID system columns anymore, thus LASTOID will always be 0 following \u003ccode class=\"command\"\u003eINSERT\u003c/code\u003e when targeting such servers.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-LAST-ERROR-MESSAGE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eLAST_ERROR_MESSAGE\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eLAST_ERROR_SQLSTATE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe primary error message and associated SQLSTATE code for the most recent failed query in the current \u003cspan class=\"application\"\u003epsql\u003c/span\u003e session, or an empty string and \u003ccode class=\"literal\"\u003e00000\u003c/code\u003e if no error has occurred in the current session.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ON-ERROR-ROLLBACK\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eON_ERROR_ROLLBACK\u003c/code\u003e \u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen set to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e, if a statement in a transaction block generates an error, the error is ignored and the transaction continues. When set to \u003ccode class=\"literal\"\u003einteractive\u003c/code\u003e, such errors are only ignored in interactive sessions, and not when reading script files. When set to \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e (the default), a statement in a transaction block that generates an error aborts the entire transaction. The error rollback mode works by issuing an implicit \u003ccode class=\"command\"\u003eSAVEPOINT\u003c/code\u003e for you, just before each command that is in a transaction block, and then rolling back to the savepoint if the command fails.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ON-ERROR-STOP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eON_ERROR_STOP\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, command processing continues after an error. When this variable is set to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e, processing will instead stop immediately. In interactive mode, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will return to the command prompt; otherwise, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e will exit, returning error code 3 to distinguish this case from fatal error conditions, which are reported using error code 1. In either case, any currently running scripts (the top-level script, if any, and any other scripts which it may have in invoked) will be terminated immediately. If the top-level command string contained multiple SQL commands, processing will stop with the current command.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-PIPELINE-COMMAND-COUNT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003ePIPELINE_COMMAND_COUNT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe number of commands queued in an ongoing pipeline.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-PIPELINE-RESULT-COUNT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003ePIPELINE_RESULT_COUNT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe number of commands of an ongoing pipeline that were followed by either a \u003ccode class=\"command\"\u003e\\flushrequest\u003c/code\u003e or a \u003ccode class=\"command\"\u003e\\syncpipeline\u003c/code\u003e, forcing the server to send the results. These results can be retrieved with \u003ccode class=\"command\"\u003e\\getresults\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-PIPELINE-SYNC-COUNT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003ePIPELINE_SYNC_COUNT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe number of sync messages queued in an ongoing pipeline.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-PORT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003ePORT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe database server port to which you are currently connected. This is set every time you connect to a database (including program start-up), but can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-PROMPT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003ePROMPT1\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003ePROMPT2\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003ePROMPT3\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThese specify what the prompts \u003cspan class=\"application\"\u003epsql\u003c/span\u003e issues should look like. See \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PROMPTING\" title=\"Prompting\"\u003ePrompting\u003c/a\u003e below.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-QUIET\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eQUIET\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSetting this variable to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e is equivalent to the command line option \u003ccode class=\"option\"\u003e-q\u003c/code\u003e. It is probably not too useful in interactive mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-ROW-COUNT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eROW_COUNT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe number of rows returned or affected by the last SQL query, or 0 if the query failed or did not report a row count.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SERVER-VERSION-NAME\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eSERVER_VERSION_NAME\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eSERVER_VERSION_NUM\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server's version number as a string, for example \u003ccode class=\"literal\"\u003e9.6.2\u003c/code\u003e, \u003ccode class=\"literal\"\u003e10.1\u003c/code\u003e or \u003ccode class=\"literal\"\u003e11beta1\u003c/code\u003e, and in numeric form, for example \u003ccode class=\"literal\"\u003e90602\u003c/code\u003e or \u003ccode class=\"literal\"\u003e100001\u003c/code\u003e. These are set every time you connect to a database (including program start-up), but can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SERVICE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eSERVICE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe service name, if applicable.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SHELL-ERROR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eSHELL_ERROR\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003etrue\u003c/code\u003e if the last shell command failed, \u003ccode class=\"literal\"\u003efalse\u003c/code\u003e if it succeeded. This applies to shell commands invoked via the \u003ccode class=\"literal\"\u003e\\!\u003c/code\u003e, \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e, \u003ccode class=\"literal\"\u003e\\o\u003c/code\u003e, \u003ccode class=\"literal\"\u003e\\w\u003c/code\u003e, and \u003ccode class=\"literal\"\u003e\\copy\u003c/code\u003e meta-commands, as well as backquote (\u003ccode class=\"literal\"\u003e`\u003c/code\u003e) expansion. Note that for \u003ccode class=\"literal\"\u003e\\o\u003c/code\u003e, this variable is updated when the output pipe is closed by the next \u003ccode class=\"literal\"\u003e\\o\u003c/code\u003e command. See also \u003ccode class=\"varname\"\u003eSHELL_EXIT_CODE\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SHELL-EXIT-CODE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eSHELL_EXIT_CODE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe exit status returned by the last shell command. 0–127 represent program exit codes, 128–255 indicate termination by a signal, and -1 indicates failure to launch a program or to collect its exit status. This applies to shell commands invoked via the \u003ccode class=\"literal\"\u003e\\!\u003c/code\u003e, \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e, \u003ccode class=\"literal\"\u003e\\o\u003c/code\u003e, \u003ccode class=\"literal\"\u003e\\w\u003c/code\u003e, and \u003ccode class=\"literal\"\u003e\\copy\u003c/code\u003e meta-commands, as well as backquote (\u003ccode class=\"literal\"\u003e`\u003c/code\u003e) expansion. Note that for \u003ccode class=\"literal\"\u003e\\o\u003c/code\u003e, this variable is updated when the output pipe is closed by the next \u003ccode class=\"literal\"\u003e\\o\u003c/code\u003e command. See also \u003ccode class=\"varname\"\u003eSHELL_ERROR\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SHOW-ALL-RESULTS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eSHOW_ALL_RESULTS\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen this variable is set to \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e, only the last result of a combined query (\u003ccode class=\"literal\"\u003e\\;\u003c/code\u003e) is shown instead of all of them. The default is \u003ccode class=\"literal\"\u003eon\u003c/code\u003e. The off behavior is for compatibility with older versions of \u003cspan class=\"application\"\u003epsql\u003c/span\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SHOW-CONTEXT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eSHOW_CONTEXT\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis variable can be set to the values \u003ccode class=\"literal\"\u003enever\u003c/code\u003e, \u003ccode class=\"literal\"\u003eerrors\u003c/code\u003e, or \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e to control whether \u003ccode class=\"literal\"\u003eCONTEXT\u003c/code\u003e fields are displayed in messages from the server. The default is \u003ccode class=\"literal\"\u003eerrors\u003c/code\u003e (meaning that context will be shown in error messages, but not in notice or warning messages). This setting has no effect when \u003ccode class=\"varname\"\u003eVERBOSITY\u003c/code\u003e is set to \u003ccode class=\"literal\"\u003eterse\u003c/code\u003e or \u003ccode class=\"literal\"\u003esqlstate\u003c/code\u003e. (See also \u003ccode class=\"command\"\u003e\\errverbose\u003c/code\u003e, for use when you want a verbose version of the error you just got.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SINGLELINE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eSINGLELINE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSetting this variable to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e is equivalent to the command line option \u003ccode class=\"option\"\u003e-S\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SINGLESTEP\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eSINGLESTEP\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSetting this variable to \u003ccode class=\"literal\"\u003eon\u003c/code\u003e is equivalent to the command line option \u003ccode class=\"option\"\u003e-s\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-SQLSTATE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eSQLSTATE\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe error code (see \u003ca class=\"xref\" href=\"/docs/18/errcodes-appendix.html\" title=\"Appendix A. PostgreSQL Error Codes\"\u003eAppendix A\u003c/a\u003e) associated with the last SQL query's failure, or \u003ccode class=\"literal\"\u003e00000\u003c/code\u003e if it succeeded.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-USER\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eUSER\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe database user you are currently connected as. This is set every time you connect to a database (including program start-up), but can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-VERBOSITY\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eVERBOSITY\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis variable can be set to the values \u003ccode class=\"literal\"\u003edefault\u003c/code\u003e, \u003ccode class=\"literal\"\u003everbose\u003c/code\u003e, \u003ccode class=\"literal\"\u003eterse\u003c/code\u003e, or \u003ccode class=\"literal\"\u003esqlstate\u003c/code\u003e to control the verbosity of error reports. (See also \u003ccode class=\"command\"\u003e\\errverbose\u003c/code\u003e, for use when you want a verbose version of the error you just got.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-VERSION\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eVERSION\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eVERSION_NAME\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eVERSION_NUM\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThese variables are set at program start-up to reflect \u003cspan class=\"application\"\u003epsql\u003c/span\u003e's version, respectively as a verbose string, a short string (e.g., \u003ccode class=\"literal\"\u003e9.6.2\u003c/code\u003e, \u003ccode class=\"literal\"\u003e10.1\u003c/code\u003e, or \u003ccode class=\"literal\"\u003e11beta1\u003c/code\u003e), and a number (e.g., \u003ccode class=\"literal\"\u003e90602\u003c/code\u003e or \u003ccode class=\"literal\"\u003e100001\u003c/code\u003e). They can be changed or unset.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-VARIABLES-WATCH-INTERVAL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"varname\"\u003eWATCH_INTERVAL\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis variable sets the default interval, in seconds, which \u003ccode class=\"command\"\u003e\\watch\u003c/code\u003e waits between executing the query. The default is 2 seconds. Specifying an interval in the command overrides this variable.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect3\" id=\"APP-PSQL-INTERPOLATION\"\u003e\n\u003ch4\u003eSQL Interpolation\u003c/h4\u003e\n\u003cp\u003eA key feature of \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variables is that you can substitute (\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003einterpolate\u003c/span\u003e”\u003c/span\u003e) them into regular SQL statements, as well as the arguments of meta-commands. Furthermore, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e provides facilities for ensuring that variable values used as SQL literals and identifiers are properly quoted. The syntax for interpolating a value without any quoting is to prepend the variable name with a colon (\u003ccode class=\"literal\"\u003e:\u003c/code\u003e). For example,\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\set foo 'my_table'\u003c/code\u003e\u003c/strong\u003e\ntestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT * FROM :foo;\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003ewould query the table \u003ccode class=\"literal\"\u003emy_table\u003c/code\u003e. Note that this may be unsafe: the value of the variable is copied literally, so it can contain unbalanced quotes, or even backslash commands. You must make sure that it makes sense where you put it.\u003c/p\u003e\n\u003cp\u003eWhen a value is to be used as an SQL literal or identifier, it is safest to arrange for it to be quoted. To quote the value of a variable as an SQL literal, write a colon followed by the variable name in single quotes. To quote the value as an SQL identifier, write a colon followed by the variable name in double quotes. These constructs deal correctly with quotes and other special characters embedded within the variable value. The previous example would be more safely written this way:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\set foo 'my_table'\u003c/code\u003e\u003c/strong\u003e\ntestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT * FROM :\"foo\";\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eVariable interpolation will not be performed within quoted SQL literals and identifiers. Therefore, a construction such as \u003ccode class=\"literal\"\u003e':foo'\u003c/code\u003e doesn't work to produce a quoted literal from a variable's value (and it would be unsafe if it did work, since it wouldn't correctly handle quotes embedded in the value).\u003c/p\u003e\n\u003cp\u003eOne example use of this mechanism is to copy the contents of a file into a table column. First load the file into a variable and then interpolate the variable's value as a quoted string:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\set content `cat my_file.txt`\u003c/code\u003e\u003c/strong\u003e\ntestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eINSERT INTO my_table VALUES (:'content');\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003e(Note that this still won't work if \u003ccode class=\"filename\"\u003emy_file.txt\u003c/code\u003e contains NUL bytes. \u003cspan class=\"application\"\u003epsql\u003c/span\u003e does not support embedded NUL bytes in variable values.)\u003c/p\u003e\n\u003cp\u003eSince colons can legally appear in SQL commands, an apparent attempt at interpolation (that is, \u003ccode class=\"literal\"\u003e:name\u003c/code\u003e, \u003ccode class=\"literal\"\u003e:'name'\u003c/code\u003e, or \u003ccode class=\"literal\"\u003e:\"name\"\u003c/code\u003e) is not replaced unless the named variable is currently set. In any case, you can escape a colon with a backslash to protect it from substitution.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode class=\"literal\"\u003e:{?\u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e}\u003c/code\u003e special syntax returns TRUE or FALSE depending on whether the variable exists or not, and is thus always substituted, unless the colon is backslash-escaped.\u003c/p\u003e\n\u003cp\u003eThe colon syntax for variables is standard SQL for embedded query languages, such as \u003cspan class=\"application\"\u003eECPG\u003c/span\u003e. The colon syntaxes for array slices and type casts are \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e extensions, which can sometimes conflict with the standard usage. The colon-quote syntax for escaping a variable's value as an SQL literal or identifier is a \u003cspan class=\"application\"\u003epsql\u003c/span\u003e extension.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect3\" id=\"APP-PSQL-PROMPTING\"\u003e\n\u003ch4\u003ePrompting\u003c/h4\u003e\n\u003cp\u003eThe prompts \u003cspan class=\"application\"\u003epsql\u003c/span\u003e issues can be customized to your preference. The three variables \u003ccode class=\"varname\"\u003ePROMPT1\u003c/code\u003e, \u003ccode class=\"varname\"\u003ePROMPT2\u003c/code\u003e, and \u003ccode class=\"varname\"\u003ePROMPT3\u003c/code\u003e contain strings and special escape sequences that describe the appearance of the prompt. Prompt 1 is the normal prompt that is issued when \u003cspan class=\"application\"\u003epsql\u003c/span\u003e requests a new command. Prompt 2 is issued when more input is expected during command entry, for example because the command was not terminated with a semicolon or a quote was not closed. Prompt 3 is issued when you are running an SQL \u003ccode class=\"command\"\u003eCOPY FROM STDIN\u003c/code\u003e command and you need to type in a row value on the terminal.\u003c/p\u003e\n\u003cp\u003eThe value of the selected prompt variable is printed literally, except where a percent sign (\u003ccode class=\"literal\"\u003e%\u003c/code\u003e) is encountered. Depending on the next character, certain other text is substituted instead. Defined substitutions are:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-M-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%M\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe full host name (with domain name) of the database server, or \u003ccode class=\"literal\"\u003e[local]\u003c/code\u003e if the connection is over a Unix domain socket, or \u003ccode class=\"literal\"\u003e[local:\u003cem class=\"replaceable\"\u003e\u003ccode\u003e/dir/name\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e, if the Unix domain socket is not at the compiled in default location.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-M-LC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%m\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe host name of the database server, truncated at the first dot, or \u003ccode class=\"literal\"\u003e[local]\u003c/code\u003e if the connection is over a Unix domain socket.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-GT\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%\u0026gt;\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe port number at which the database server is listening.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-N\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%n\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe database session user name. (The expansion of this value might change during a database session as the result of the command \u003ccode class=\"command\"\u003eSET SESSION AUTHORIZATION\u003c/code\u003e.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-S\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%s\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe name of the service.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-SLASH\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%/\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe name of the current database.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-TILDE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%~\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eLike \u003ccode class=\"literal\"\u003e%/\u003c/code\u003e, but the output is \u003ccode class=\"literal\"\u003e~\u003c/code\u003e (tilde) if the database is your default database.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-NUMBERSIGN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%#\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf the session user is a database superuser, then a \u003ccode class=\"literal\"\u003e#\u003c/code\u003e, otherwise a \u003ccode class=\"literal\"\u003e\u0026gt;\u003c/code\u003e. (The expansion of this value might change during a database session as the result of the command \u003ccode class=\"command\"\u003eSET SESSION AUTHORIZATION\u003c/code\u003e.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-P\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%p\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe process ID of the backend currently connected to.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-P-UC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%P\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePipeline status: \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e when not in a pipeline, \u003ccode class=\"literal\"\u003eon\u003c/code\u003e when in an ongoing pipeline or \u003ccode class=\"literal\"\u003eabort\u003c/code\u003e when in an aborted pipeline.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-R\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%R\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIn prompt 1 normally \u003ccode class=\"literal\"\u003e=\u003c/code\u003e, but \u003ccode class=\"literal\"\u003e@\u003c/code\u003e if the session is in an inactive branch of a conditional block, or \u003ccode class=\"literal\"\u003e^\u003c/code\u003e if in single-line mode, or \u003ccode class=\"literal\"\u003e!\u003c/code\u003e if the session is disconnected from the database (which can happen if \u003ccode class=\"command\"\u003e\\connect\u003c/code\u003e fails). In prompt 2 \u003ccode class=\"literal\"\u003e%R\u003c/code\u003e is replaced by a character that depends on why \u003cspan class=\"application\"\u003epsql\u003c/span\u003e expects more input: \u003ccode class=\"literal\"\u003e-\u003c/code\u003e if the command simply wasn't terminated yet, but \u003ccode class=\"literal\"\u003e*\u003c/code\u003e if there is an unfinished \u003ccode class=\"literal\"\u003e/* ... */\u003c/code\u003e comment, a single quote if there is an unfinished quoted string, a double quote if there is an unfinished quoted identifier, a dollar sign if there is an unfinished dollar-quoted string, or \u003ccode class=\"literal\"\u003e(\u003c/code\u003e if there is an unmatched left parenthesis. In prompt 3 \u003ccode class=\"literal\"\u003e%R\u003c/code\u003e doesn't produce anything.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-X\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%x\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eTransaction status: an empty string when not in a transaction block, or \u003ccode class=\"literal\"\u003e*\u003c/code\u003e when in a transaction block, or \u003ccode class=\"literal\"\u003e!\u003c/code\u003e when in a failed transaction block, or \u003ccode class=\"literal\"\u003e?\u003c/code\u003e when the transaction state is indeterminate (for example, because there is no connection).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-L\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%l\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe line number inside the current statement, starting from \u003ccode class=\"literal\"\u003e1\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-DIGITS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003edigits\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe character with the indicated octal code is substituted.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-NAME\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%:\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003ccode class=\"literal\"\u003e:\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe value of the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variable \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e. See \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-VARIABLES\" title=\"Variables\"\u003eVariables\u003c/a\u003e, above, for details.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-COMMAND\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%`\u003c/code\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e\u003ccode class=\"literal\"\u003e`\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe output of \u003cem class=\"replaceable\"\u003e\u003ccode\u003ecommand\u003c/code\u003e\u003c/em\u003e, similar to ordinary \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eback-tick\u003c/span\u003e”\u003c/span\u003e substitution.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-SQUARE-BRACKETS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%[\u003c/code\u003e ... \u003ccode class=\"literal\"\u003e%]\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrompts can contain terminal control characters which, for example, change the color, background, or style of the prompt text, or change the title of the terminal window. In order for the line editing features of \u003cspan class=\"application\"\u003eReadline\u003c/span\u003e to work properly, these non-printing control characters must be designated as invisible by surrounding them with \u003ccode class=\"literal\"\u003e%[\u003c/code\u003e and \u003ccode class=\"literal\"\u003e%]\u003c/code\u003e. Multiple pairs of these can occur within the prompt. For example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \\set PROMPT1 '%[%033[1;33;40m%]%n@%/%R%[%033[0m%]%# '\n\u003c/pre\u003e\n\u003cp\u003eresults in a boldfaced (\u003ccode class=\"literal\"\u003e1;\u003c/code\u003e) yellow-on-black (\u003ccode class=\"literal\"\u003e33;40\u003c/code\u003e) prompt on VT100-compatible, color-capable terminals.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-PROMPTING-W\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003e%w\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhitespace of the same width as the most recent output of \u003ccode class=\"varname\"\u003ePROMPT1\u003c/code\u003e. This can be used as a \u003ccode class=\"varname\"\u003ePROMPT2\u003c/code\u003e setting, so that multi-line statements are aligned with the first line, but there is no visible secondary prompt.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eTo insert a percent sign into your prompt, write \u003ccode class=\"literal\"\u003e%%\u003c/code\u003e. The default prompts are \u003ccode class=\"literal\"\u003e'%/%R%x%# '\u003c/code\u003e for prompts 1 and 2, and \u003ccode class=\"literal\"\u003e'\u0026gt;\u0026gt; '\u003c/code\u003e for prompt 3.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis feature was shamelessly plagiarized from \u003cspan class=\"application\"\u003etcsh\u003c/span\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect3\" id=\"APP-PSQL-READLINE\"\u003e\n\u003ch4\u003eCommand-Line Editing\u003c/h4\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e uses the \u003cspan class=\"application\"\u003eReadline\u003c/span\u003e or \u003cspan class=\"application\"\u003elibedit\u003c/span\u003e library, if available, for convenient line editing and retrieval. The command history is automatically saved when \u003cspan class=\"application\"\u003epsql\u003c/span\u003e exits and is reloaded when \u003cspan class=\"application\"\u003epsql\u003c/span\u003e starts up. Type up-arrow or control-P to retrieve previous lines.\u003c/p\u003e\n\u003cp\u003eYou can also use tab completion to fill in partially-typed keywords and SQL object names in many (by no means all) contexts. For example, at the start of a command, typing \u003ccode class=\"literal\"\u003eins\u003c/code\u003e and pressing TAB will fill in \u003ccode class=\"literal\"\u003einsert into\u003c/code\u003e . Then, typing a few characters of a table or schema name and pressing \u003ccode class=\"literal\"\u003eTAB\u003c/code\u003e will fill in the unfinished name, or offer a menu of possible completions when there's more than one. (Depending on the library in use, you may need to press \u003ccode class=\"literal\"\u003eTAB\u003c/code\u003e more than once to get a menu.)\u003c/p\u003e\n\u003cp\u003eTab completion for SQL object names requires sending queries to the server to find possible matches. In some contexts this can interfere with other operations. For example, after \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e it will be too late to issue \u003ccode class=\"command\"\u003eSET TRANSACTION ISOLATION LEVEL\u003c/code\u003e if a tab-completion query is issued in between. If you do not want tab completion at all, you can turn it off permanently by putting this in a file named \u003ccode class=\"filename\"\u003e.inputrc\u003c/code\u003e in your home directory:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003e$if psql\nset disable-completion on\n$endif\n\u003c/pre\u003e\n\u003cp\u003e(This is not a \u003cspan class=\"application\"\u003epsql\u003c/span\u003e but a \u003cspan class=\"application\"\u003eReadline\u003c/span\u003e feature. Read its documentation for further details.)\u003c/p\u003e\n\u003cp\u003eThe \u003ccode class=\"option\"\u003e-n\u003c/code\u003e (\u003ccode class=\"option\"\u003e--no-readline\u003c/code\u003e) command line option can also be useful to disable use of \u003cspan class=\"application\"\u003eReadline\u003c/span\u003e for a single run of \u003cspan class=\"application\"\u003epsql\u003c/span\u003e. This prevents tab completion, use or recording of command line history, and editing of multi-line commands. It is particularly useful when you need to copy-and-paste text that contains \u003ccode class=\"literal\"\u003eTAB\u003c/code\u003e characters.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"APP-PSQL-ENVIRONMENT\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-COLUMNS\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003eCOLUMNS\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf \u003ccode class=\"literal\"\u003e\\pset columns\u003c/code\u003e is zero, controls the width for the \u003ccode class=\"literal\"\u003ewrapped\u003c/code\u003e format and width for determining if wide output requires the pager or should be switched to the vertical format in expanded auto mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PGDATABASE\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGDATABASE\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGHOST\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGUSER\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDefault connection parameters (see \u003ca class=\"xref\" href=\"/docs/18/libpq-envars.html\" title=\"32.15. Environment Variables\"\u003eSection 32.15\u003c/a\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PG-COLOR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePG_COLOR\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies whether to use color in diagnostic messages. Possible values are \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e, \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e and \u003ccode class=\"literal\"\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PSQL-EDITOR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePSQL_EDITOR\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003eEDITOR\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003eVISUAL\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEditor used by the \u003ccode class=\"command\"\u003e\\e\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\ef\u003c/code\u003e, and \u003ccode class=\"command\"\u003e\\ev\u003c/code\u003e commands. These variables are examined in the order listed; the first that is set is used. If none of them is set, the default is to use \u003ccode class=\"filename\"\u003evi\u003c/code\u003e on Unix systems or \u003ccode class=\"filename\"\u003enotepad.exe\u003c/code\u003e on Windows systems.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PSQL-EDITOR-LINENUMBER-ARG\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePSQL_EDITOR_LINENUMBER_ARG\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen \u003ccode class=\"command\"\u003e\\e\u003c/code\u003e, \u003ccode class=\"command\"\u003e\\ef\u003c/code\u003e, or \u003ccode class=\"command\"\u003e\\ev\u003c/code\u003e is used with a line number argument, this variable specifies the command-line argument used to pass the starting line number to the user's editor. For editors such as \u003cspan class=\"productname\"\u003eEmacs\u003c/span\u003e or \u003cspan class=\"productname\"\u003evi\u003c/span\u003e, this is a plus sign. Include a trailing space in the value of the variable if there needs to be space between the option name and the line number. Examples:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003ePSQL_EDITOR_LINENUMBER_ARG='+'\nPSQL_EDITOR_LINENUMBER_ARG='--line '\n\u003c/pre\u003e\n\u003cp\u003eThe default is \u003ccode class=\"literal\"\u003e+\u003c/code\u003e on Unix systems (corresponding to the default editor \u003ccode class=\"filename\"\u003evi\u003c/code\u003e, and useful for many other common editors); but there is no default on Windows systems.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PSQL-HISTORY\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePSQL_HISTORY\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAlternative location for the command history file. Tilde (\u003ccode class=\"literal\"\u003e~\u003c/code\u003e) expansion is performed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PAGER\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePSQL_PAGER\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePAGER\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf a query's results do not fit on the screen, they are piped through this command. Typical values are \u003ccode class=\"literal\"\u003emore\u003c/code\u003e or \u003ccode class=\"literal\"\u003eless\u003c/code\u003e. Use of the pager can be disabled by setting \u003ccode class=\"envar\"\u003ePSQL_PAGER\u003c/code\u003e or \u003ccode class=\"envar\"\u003ePAGER\u003c/code\u003e to an empty string, or by adjusting the pager-related options of the \u003ccode class=\"command\"\u003e\\pset\u003c/code\u003e command. These variables are examined in the order listed; the first that is set is used. If neither of them is set, the default is to use \u003ccode class=\"literal\"\u003emore\u003c/code\u003e on most platforms, but \u003ccode class=\"literal\"\u003eless\u003c/code\u003e on Cygwin.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PSQL-WATCH-PAGER\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePSQL_WATCH_PAGER\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen a query is executed repeatedly with the \u003ccode class=\"command\"\u003e\\watch\u003c/code\u003e command, a pager is not used by default. This behavior can be changed by setting \u003ccode class=\"envar\"\u003ePSQL_WATCH_PAGER\u003c/code\u003e to a pager command, on Unix systems. The \u003ccode class=\"literal\"\u003epspg\u003c/code\u003e pager (not part of \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e but available in many open source software distributions) can display the output of \u003ccode class=\"command\"\u003e\\watch\u003c/code\u003e if started with the option \u003ccode class=\"literal\"\u003e--stream\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-PSQLRC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePSQLRC\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAlternative location of the user's \u003ccode class=\"filename\"\u003e.psqlrc\u003c/code\u003e file. Tilde (\u003ccode class=\"literal\"\u003e~\u003c/code\u003e) expansion is performed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-SHELL\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003eSHELL\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCommand executed by the \u003ccode class=\"command\"\u003e\\!\u003c/code\u003e command.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-ENVIRONMENT-TMPDIR\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003eTMPDIR\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDirectory for storing temporary files. The default is \u003ccode class=\"filename\"\u003e/tmp\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThis utility, like most other \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e utilities, also uses the environment variables supported by \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e (see \u003ca class=\"xref\" href=\"/docs/18/libpq-envars.html\" title=\"32.15. Environment Variables\"\u003eSection 32.15\u003c/a\u003e).\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.21.10\"\u003e\n\u003ch2\u003eFiles\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt id=\"APP-PSQL-FILES-PSQLRC\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"filename\"\u003epsqlrc\u003c/code\u003e and \u003ccode class=\"filename\"\u003e~/.psqlrc\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUnless it is passed an \u003ccode class=\"option\"\u003e-X\u003c/code\u003e option, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e attempts to read and execute commands from the system-wide startup file (\u003ccode class=\"filename\"\u003epsqlrc\u003c/code\u003e) and then the user's personal startup file (\u003ccode class=\"filename\"\u003e~/.psqlrc\u003c/code\u003e), after connecting to the database but before accepting normal commands. These files can be used to set up the client and/or the server to taste, typically with \u003ccode class=\"command\"\u003e\\set\u003c/code\u003e and \u003ccode class=\"command\"\u003eSET\u003c/code\u003e commands.\u003c/p\u003e\n\u003cp\u003eThe system-wide startup file is named \u003ccode class=\"filename\"\u003epsqlrc\u003c/code\u003e. By default it is sought in the installation's \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003esystem configuration\u003c/span\u003e”\u003c/span\u003e directory, which is most reliably identified by running \u003ccode class=\"literal\"\u003epg_config --sysconfdir\u003c/code\u003e. Typically this directory will be \u003ccode class=\"filename\"\u003e../etc/\u003c/code\u003e relative to the directory containing the \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e executables. The directory to look in can be set explicitly via the \u003ccode class=\"envar\"\u003ePGSYSCONFDIR\u003c/code\u003e environment variable.\u003c/p\u003e\n\u003cp\u003eThe user's personal startup file is named \u003ccode class=\"filename\"\u003e.psqlrc\u003c/code\u003e and is sought in the invoking user's home directory. On Windows the personal startup file is instead named \u003ccode class=\"filename\"\u003e%APPDATA%\\postgresql\\psqlrc.conf\u003c/code\u003e. In either case, this default file path can be overridden by setting the \u003ccode class=\"envar\"\u003ePSQLRC\u003c/code\u003e environment variable.\u003c/p\u003e\n\u003cp\u003eBoth the system-wide startup file and the user's personal startup file can be made \u003cspan class=\"application\"\u003epsql\u003c/span\u003e-version-specific by appending a dash and the \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e major or minor release identifier to the file name, for example \u003ccode class=\"filename\"\u003e~/.psqlrc-18\u003c/code\u003e or \u003ccode class=\"filename\"\u003e~/.psqlrc-18.6\u003c/code\u003e. The most specific version-matching file will be read in preference to a non-version-specific file. These version suffixes are added after determining the file path as explained above.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt id=\"APP-PSQL-FILES-PSQL-HISTORY\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"filename\"\u003e.psql_history\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe command-line history is stored in the file \u003ccode class=\"filename\"\u003e~/.psql_history\u003c/code\u003e, or \u003ccode class=\"filename\"\u003e%APPDATA%\\postgresql\\psql_history\u003c/code\u003e on Windows.\u003c/p\u003e\n\u003cp\u003eThe location of the history file can be set explicitly via the \u003ccode class=\"varname\"\u003eHISTFILE\u003c/code\u003e \u003cspan class=\"application\"\u003epsql\u003c/span\u003e variable or the \u003ccode class=\"envar\"\u003ePSQL_HISTORY\u003c/code\u003e environment variable.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.21.11\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e works best with servers of the same or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than \u003cspan class=\"application\"\u003epsql\u003c/span\u003e itself. However, backslash commands of the \u003ccode class=\"literal\"\u003e\\d\u003c/code\u003e family should work with servers of versions back to 9.2, though not necessarily with servers newer than \u003cspan class=\"application\"\u003epsql\u003c/span\u003e itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot be guaranteed in all cases.\u003c/p\u003e\n\u003cp\u003eIf you want to use \u003cspan class=\"application\"\u003epsql\u003c/span\u003e to connect to several servers of different major versions, it is recommended that you use the newest version of \u003cspan class=\"application\"\u003epsql\u003c/span\u003e. Alternatively, you can keep around a copy of \u003cspan class=\"application\"\u003epsql\u003c/span\u003e from each major version and be sure to use the version that matches the respective server. But in practice, this additional complication should not be necessary.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eBefore \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 9.6, the \u003ccode class=\"option\"\u003e-c\u003c/code\u003e option implied \u003ccode class=\"option\"\u003e-X\u003c/code\u003e (\u003ccode class=\"option\"\u003e--no-psqlrc\u003c/code\u003e); this is no longer the case.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eBefore \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 8.4, \u003cspan class=\"application\"\u003epsql\u003c/span\u003e allowed the first argument of a single-letter backslash command to start directly after the command, without intervening whitespace. Now, some whitespace is required.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.21.12\"\u003e\n\u003ch2\u003eNotes for Windows Users\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e is built as a \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003econsole application\u003c/span\u003e”\u003c/span\u003e. Since the Windows console windows use a different encoding than the rest of the system, you must take special care when using 8-bit characters within \u003cspan class=\"application\"\u003epsql\u003c/span\u003e. If \u003cspan class=\"application\"\u003epsql\u003c/span\u003e detects a problematic console code page, it will warn you at startup. To change the console code page, two things are necessary:\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eSet the code page by entering \u003cstrong class=\"userinput\"\u003e\u003ccode\u003ecmd.exe /c chcp 1252\u003c/code\u003e\u003c/strong\u003e. (1252 is a code page that is appropriate for German; replace it with your value.) If you are using Cygwin, you can put this command in \u003ccode class=\"filename\"\u003e/etc/profile\u003c/code\u003e.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eSet the console font to \u003ccode class=\"literal\"\u003eLucida Console\u003c/code\u003e, because the raster font does not work with the ANSI code page.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"APP-PSQL-EXAMPLES\"\u003e\n\u003ch2\u003eExamples\u003c/h2\u003e\n\u003cp\u003eThe first example shows how to spread a command over several lines of input. Notice the changing prompt:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eCREATE TABLE my_table (\u003c/code\u003e\u003c/strong\u003e\ntestdb(\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e first integer not null default 0,\u003c/code\u003e\u003c/strong\u003e\ntestdb(\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e second text)\u003c/code\u003e\u003c/strong\u003e\ntestdb-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e;\u003c/code\u003e\u003c/strong\u003e\nCREATE TABLE\n\u003c/pre\u003e\n\u003cp\u003eNow look at the table definition again:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\d my_table\u003c/code\u003e\u003c/strong\u003e\n              Table \"public.my_table\"\n Column |  Type   | Collation | Nullable | Default\n--------+---------+-----------+----------+---------\n first  | integer |           | not null | 0\n second | text    |           |          |\n\u003c/pre\u003e\n\u003cp\u003eNow we change the prompt to something more interesting:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\set PROMPT1 '%n@%m %~%R%# '\u003c/code\u003e\u003c/strong\u003e\npeter@localhost testdb=\u0026gt;\n\u003c/pre\u003e\n\u003cp\u003eLet's assume you have filled the table with data and want to take a look at it:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003epeter@localhost testdb=\u0026gt; SELECT * FROM my_table;\n first | second\n-------+--------\n     1 | one\n     2 | two\n     3 | three\n     4 | four\n(4 rows)\n\u003c/pre\u003e\n\u003cp\u003eYou can display tables in different ways by using the \u003ccode class=\"command\"\u003e\\pset\u003c/code\u003e command:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003epeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\pset border 2\u003c/code\u003e\u003c/strong\u003e\nBorder style is 2.\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT * FROM my_table;\u003c/code\u003e\u003c/strong\u003e\n+-------+--------+\n| first | second |\n+-------+--------+\n|     1 | one    |\n|     2 | two    |\n|     3 | three  |\n|     4 | four   |\n+-------+--------+\n(4 rows)\n\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\pset border 0\u003c/code\u003e\u003c/strong\u003e\nBorder style is 0.\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT * FROM my_table;\u003c/code\u003e\u003c/strong\u003e\nfirst second\n----- ------\n    1 one\n    2 two\n    3 three\n    4 four\n(4 rows)\n\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\pset border 1\u003c/code\u003e\u003c/strong\u003e\nBorder style is 1.\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\pset format csv\u003c/code\u003e\u003c/strong\u003e\nOutput format is csv.\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\pset tuples_only\u003c/code\u003e\u003c/strong\u003e\nTuples only is on.\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT second, first FROM my_table;\u003c/code\u003e\u003c/strong\u003e\none,1\ntwo,2\nthree,3\nfour,4\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\pset format unaligned\u003c/code\u003e\u003c/strong\u003e\nOutput format is unaligned.\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\pset fieldsep '\\t'\u003c/code\u003e\u003c/strong\u003e\nField separator is \"    \".\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT second, first FROM my_table;\u003c/code\u003e\u003c/strong\u003e\none     1\ntwo     2\nthree   3\nfour    4\n\u003c/pre\u003e\n\u003cp\u003eAlternatively, use the short commands:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003epeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\a \\t \\x\u003c/code\u003e\u003c/strong\u003e\nOutput format is aligned.\nTuples only is off.\nExpanded display is on.\npeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT * FROM my_table;\u003c/code\u003e\u003c/strong\u003e\n-[ RECORD 1 ]-\nfirst  | 1\nsecond | one\n-[ RECORD 2 ]-\nfirst  | 2\nsecond | two\n-[ RECORD 3 ]-\nfirst  | 3\nsecond | three\n-[ RECORD 4 ]-\nfirst  | 4\nsecond | four\n\u003c/pre\u003e\n\u003cp\u003eAlso, these output format options can be set for just one query by using \u003ccode class=\"literal\"\u003e\\g\u003c/code\u003e:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003epeter@localhost testdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT * FROM my_table\u003c/code\u003e\u003c/strong\u003e\npeter@localhost testdb-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\g (format=aligned tuples_only=off expanded=on)\u003c/code\u003e\u003c/strong\u003e\n-[ RECORD 1 ]-\nfirst  | 1\nsecond | one\n-[ RECORD 2 ]-\nfirst  | 2\nsecond | two\n-[ RECORD 3 ]-\nfirst  | 3\nsecond | three\n-[ RECORD 4 ]-\nfirst  | 4\nsecond | four\n\u003c/pre\u003e\n\u003cp\u003eHere is an example of using the \u003ccode class=\"command\"\u003e\\df\u003c/code\u003e command to find only functions with names matching \u003ccode class=\"literal\"\u003eint*pl\u003c/code\u003e and whose second argument is of type \u003ccode class=\"type\"\u003ebigint\u003c/code\u003e:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\df int*pl * bigint\u003c/code\u003e\u003c/strong\u003e\n                          List of functions\n   Schema   |  Name   | Result data type | Argument data types | Type\n------------+---------+------------------+---------------------+------\n pg_catalog | int28pl | bigint           | smallint, bigint    | func\n pg_catalog | int48pl | bigint           | integer, bigint     | func\n pg_catalog | int8pl  | bigint           | bigint, bigint      | func\n(3 rows)\n\u003c/pre\u003e\n\u003cp\u003eHere, the \u003ccode class=\"literal\"\u003e+\u003c/code\u003e option is used to display additional information about one of these functions, and \u003ccode class=\"literal\"\u003ex\u003c/code\u003e is used to display the results in expanded mode:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\df+x int*pl integer bigint\u003c/code\u003e\u003c/strong\u003e\nList of functions\n-[ RECORD 1 ]-------+-----------------------------\nSchema              | pg_catalog\nName                | int48pl\nResult data type    | bigint\nArgument data types | integer, bigint\nType                | func\nVolatility          | immutable\nParallel            | safe\nOwner               | postgres\nSecurity            | invoker\nLeakproof?          | no\nAccess privileges   |\nLanguage            | internal\nInternal name       | int48pl\nDescription         | implementation of + operator\n\u003c/pre\u003e\n\u003cp\u003eWhen suitable, query results can be shown in a crosstab representation with the \u003ccode class=\"command\"\u003e\\crosstabview\u003c/code\u003e command:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT first, second, first \u0026gt; 2 AS gt2 FROM my_table;\u003c/code\u003e\u003c/strong\u003e\n first | second | gt2\n-------+--------+-----\n     1 | one    | f\n     2 | two    | f\n     3 | three  | t\n     4 | four   | t\n(4 rows)\n\ntestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\crosstabview first second\u003c/code\u003e\u003c/strong\u003e\n first | one | two | three | four\n-------+-----+-----+-------+------\n     1 | f   |     |       |\n     2 |     | f   |       |\n     3 |     |     | t     |\n     4 |     |     |       | t\n(4 rows)\n\u003c/pre\u003e\n\u003cp\u003eThis second example shows a multiplication table with rows sorted in reverse numerical order and columns with an independent, ascending numerical order.\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003etestdb=\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eSELECT t1.first as \"A\", t2.first+100 AS \"B\", t1.first*(t2.first+100) as \"AxB\",\u003c/code\u003e\u003c/strong\u003e\ntestdb-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003erow_number() over(order by t2.first) AS ord\u003c/code\u003e\u003c/strong\u003e\ntestdb-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eFROM my_table t1 CROSS JOIN my_table t2 ORDER BY 1 DESC\u003c/code\u003e\u003c/strong\u003e\ntestdb-\u0026gt; \u003cstrong class=\"userinput\"\u003e\u003ccode\u003e\\crosstabview \"A\" \"B\" \"AxB\" ord\u003c/code\u003e\u003c/strong\u003e\n A | 101 | 102 | 103 | 104\n---+-----+-----+-----+-----\n 4 | 404 | 408 | 412 | 416\n 3 | 303 | 306 | 309 | 312\n 2 | 202 | 204 | 206 | 208\n 1 | 101 | 102 | 103 | 104\n(4 rows)\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","related":[{"label":"psql meta-commands","url":"/wiki/psql/?v=18"},{"label":"libpq connection parameters","url":"/wiki/conn/?v=18"}],"sections":[],"tables":[{"columns":[{"key":"signature","label":"Option and arguments"},{"key":"summary","label":"Description"}],"key":"options","rows":[{"signature":{"text":"-a --echo-all","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-ECHO-ALL"},"summary":"Print all nonempty input lines to standard output as they are read. (This does not apply to lines read interactively.) This is equivalent to setting the variable ECHO to all ."},{"signature":{"text":"-A --no-align","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-NO-ALIGN"},"summary":"Switches to unaligned output mode. (The default output mode is aligned .) This is equivalent to \\pset format unaligned ."},{"signature":{"text":"-b --echo-errors","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-ECHO-ERRORS"},"summary":"Print failed SQL commands to standard error output. This is equivalent to setting the variable ECHO to errors ."},{"signature":{"text":"-c command --command= command","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-COMMAND"},"summary":"Specifies that psql is to execute the given command string, command . This option can be repeated and combined in any order with the -f option. When either -c or -f is specified, psql does not read commands from standard input; instead it terminates after processing all the -c and -f options in sequence."},{"signature":{"text":"--csv","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-CSV"},"summary":"Switches to CSV (Comma-Separated Values) output mode. This is equivalent to \\pset format csv ."},{"signature":{"text":"-d dbname --dbname= dbname","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-DBNAME"},"summary":"Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."},{"signature":{"text":"-e --echo-queries","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-ECHO-QUERIES"},"summary":"Copy all SQL commands sent to the server to standard output as well. This is equivalent to setting the variable ECHO to queries ."},{"signature":{"text":"-E --echo-hidden","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-ECHO-HIDDEN"},"summary":"Echo the actual queries generated by \\d and other backslash commands. You can use this to study psql 's internal operations. This is equivalent to setting the variable ECHO_HIDDEN to on ."},{"signature":{"text":"-f filename --file= filename","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-FILE"},"summary":"Read commands from the file filename , rather than standard input. This option can be repeated and combined in any order with the -c option. When either -c or -f is specified, psql does not read commands from standard input; instead it terminates after processing all the -c and -f options in sequence. Except for that, this option is largely equivalent to the meta-command \\i ."},{"signature":{"text":"-F separator --field-separator= separator","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-FIELD-SEPARATOR"},"summary":"Use separator as the field separator for unaligned output. This is equivalent to \\pset fieldsep or \\f ."},{"signature":{"text":"-h hostname --host= hostname","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-FIELD-HOST"},"summary":"Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix-domain socket."},{"signature":{"text":"-H --html","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-HTML"},"summary":"Switches to HTML output mode. This is equivalent to \\pset format html or the \\H command."},{"signature":{"text":"-l --list","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-LIST"},"summary":"List all available databases, then exit. Other non-connection options are ignored. This is similar to the meta-command \\list ."},{"signature":{"text":"-L filename --log-file= filename","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-LOG-FILE"},"summary":"Write all query output into file filename , in addition to the normal output destination."},{"signature":{"text":"-n --no-readline","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-NO-READLINE"},"summary":"Do not use Readline for line editing and do not use the command history (see the section called “Command-Line Editing” below)."},{"signature":{"text":"-o filename --output= filename","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-OUTPUT"},"summary":"Put all query output into file filename . This is equivalent to the command \\o ."},{"signature":{"text":"-p port --port= port","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-PORT"},"summary":"Specifies the TCP port or the local Unix-domain socket file extension on which the server is listening for connections. Defaults to the value of the PGPORT environment variable or, if not set, to the port specified at compile time, usually 5432."},{"signature":{"text":"-P assignment --pset= assignment","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-PSET"},"summary":"Specifies printing options, in the style of \\pset . Note that here you have to separate name and value with an equal sign instead of a space. For example, to set the output format to LaTeX , you could write -P format=latex ."},{"signature":{"text":"-q --quiet","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-QUIET"},"summary":"Specifies that psql should do its work quietly. By default, it prints welcome messages and various informational output. If this option is used, none of this happens. This is useful with the -c option. This is equivalent to setting the variable QUIET to on ."},{"signature":{"text":"-R separator --record-separator= separator","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-RECORD-SEPARATOR"},"summary":"Use separator as the record separator for unaligned output. This is equivalent to \\pset recordsep ."},{"signature":{"text":"-s --single-step","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-SINGLE-STEP"},"summary":"Run in single-step mode. That means the user is prompted before each command is sent to the server, with the option to cancel execution as well. Use this to debug scripts."},{"signature":{"text":"-S --single-line","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-SINGLE-LINE"},"summary":"Runs in single-line mode where a newline terminates an SQL command, as a semicolon does."},{"signature":{"text":"-t --tuples-only","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-TUPLES-ONLY"},"summary":"Turn off printing of column names and result row count footers, etc. This is equivalent to \\t or \\pset tuples_only ."},{"signature":{"text":"-T table_options --table-attr= table_options","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-TABLE-ATTR"},"summary":"Specifies options to be placed within the HTML table tag. See \\pset tableattr for details."},{"signature":{"text":"-U username --username= username","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-USERNAME"},"summary":"Connect to the database as the user username instead of the default. (You must have permission to do so, of course.)"},{"signature":{"text":"-v assignment --set= assignment --variable= assignment","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-VARIABLE"},"summary":"Perform a variable assignment, like the \\set meta-command. Note that you must separate name and value, if any, by an equal sign on the command line. To unset a variable, leave off the equal sign. To set a variable with an empty value, use the equal sign but leave off the value. These assignments are done during command line processing, so variables that reflect connection state will get overwritten later."},{"signature":{"text":"-V --version","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-VERSION"},"summary":"Print the psql version and exit."},{"signature":{"text":"-w --no-password","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-NO-PASSWORD"},"summary":"Never issue a password prompt. If the server requires password authentication and a password is not available from other sources such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password."},{"signature":{"text":"-W --password","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-PASSWORD"},"summary":"Force psql to prompt for a password before connecting to a database, even if the password will not be used."},{"signature":{"text":"-x --expanded","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-EXPANDED"},"summary":"Turn on the expanded table formatting mode. This is equivalent to \\x or \\pset expanded ."},{"signature":{"text":"-X --no-psqlrc","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-NO-PSQLRC"},"summary":"Do not read the start-up file (neither the system-wide psqlrc file nor the user's ~/.psqlrc file)."},{"signature":{"text":"-z --field-separator-zero","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-FIELD-SEPARATOR-ZERO"},"summary":"Set the field separator for unaligned output to a zero byte. This is equivalent to \\pset fieldsep_zero ."},{"signature":{"text":"-0 --record-separator-zero","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-RECORD-SEPARATOR-ZERO"},"summary":"Set the record separator for unaligned output to a zero byte. This is useful for interfacing, for example, with xargs -0 . This is equivalent to \\pset recordsep_zero ."},{"signature":{"text":"-1 --single-transaction","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-SINGLE-TRANSACTION"},"summary":"This option can only be used in combination with one or more -c and/or -f options. It causes psql to issue a BEGIN command before the first such option and a COMMIT command after the last one, thereby wrapping all the commands into a single transaction. If any of the commands fails and the variable ON_ERROR_STOP was set, a ROLLBACK command is sent instead. This ensures that either all the commands complete successfully, or no changes are applied."},{"signature":{"text":"-? --help[= topic ]","url":"/docs/18/app-psql.html#APP-PSQL-OPTION-HELP"},"summary":"Show help about psql and exit. The optional topic parameter (defaulting to options ) 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."}],"title":"Documented options"},{"columns":[{"key":"name","label":"Variable"},{"key":"description","label":"Meaning"}],"key":"environment","rows":[{"description":"If \\pset columns is zero, controls the width for the wrapped format and width for determining if wide output requires the pager or should be switched to the vertical format in expanded auto mode.","name":"COLUMNS"},{"description":"Default connection parameters (see Section 32.15 ).","name":"PGDATABASE PGHOST PGPORT PGUSER"},{"description":"Specifies whether to use color in diagnostic messages. Possible values are always , auto and never .","name":"PG_COLOR"},{"description":"Editor used by the \\e , \\ef , and \\ev commands. These variables are examined in the order listed; the first that is set is used. If none of them is set, the default is to use vi on Unix systems or notepad.exe on Windows systems.","name":"PSQL_EDITOR EDITOR VISUAL"},{"description":"When \\e , \\ef , or \\ev is used with a line number argument, this variable specifies the command-line argument used to pass the starting line number to the user's editor. For editors such as Emacs or vi , this is a plus sign. Include a trailing space in the value of the variable if there needs to be space between the option name and the line number. Examples: PSQL_EDITOR_LINENUMBER_ARG='+' PSQL_EDITOR_LINENUMBER_ARG='--line ' The default is + on Unix systems (corresponding to the default editor vi , and useful for many other common editors); but there is no default on Windows systems.","name":"PSQL_EDITOR_LINENUMBER_ARG"},{"description":"Alternative location for the command history file. Tilde ( ~ ) expansion is performed.","name":"PSQL_HISTORY"},{"description":"If a query's results do not fit on the screen, they are piped through this command. Typical values are more or less . Use of the pager can be disabled by setting PSQL_PAGER or PAGER to an empty string, or by adjusting the pager-related options of the \\pset command. These variables are examined in the order listed; the first that is set is used. If neither of them is set, the default is to use more on most platforms, but less on Cygwin.","name":"PSQL_PAGER PAGER"},{"description":"When a query is executed repeatedly with the \\watch command, a pager is not used by default. This behavior can be changed by setting PSQL_WATCH_PAGER to a pager command, on Unix systems. The pspg pager (not part of PostgreSQL but available in many open source software distributions) can display the output of \\watch if started with the option --stream .","name":"PSQL_WATCH_PAGER"},{"description":"Alternative location of the user's .psqlrc file. Tilde ( ~ ) expansion is performed.","name":"PSQLRC"},{"description":"Command executed by the \\! command.","name":"SHELL"},{"description":"Directory for storing temporary files. The default is /tmp .","name":"TMPDIR"}],"title":"Environment variables"}]}},"RequestedLocale":"zh-Hans","Fallback":true,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
