- class="parameter">command. 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.
+ Sends the current query buffer to the server for execution.
+ If an 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.
- A bare \g is essentially equivalent to a semicolon.
+ If the current query buffer is empty, the most recently sent query is
+ re-executed instead. Except for that behavior, \g
+ without an argument is essentially equivalent to a semicolon.
A \g with argument is a one-shot
alternative to the \o command.
- Sends the current query input buffer to the server, then treats
+ Sends the current query buffer to the server, then treats
each column of each row of the query's output (if any) as a SQL
statement to be executed. For example, to create an index on each
column of my_table>:
timing, and other query execution features apply to each generated
query as well.
+ If the current query buffer is empty, the most recently sent query
+ is re-executed instead.
+
- Sends the current query input buffer to the server and stores the
+ Sends the current query buffer to the server and stores the
query's output into
psql> variables (see
linkend="APP-PSQL-variables" endterm="APP-PSQL-variables-title">).
The query to be executed must return exactly one row. Each column of
If the query fails or does not return one row,
no variables are changed.
+ If the current query buffer is empty, the most recently sent query
+ is re-executed instead.
+
Print the current query buffer to the standard output.
+ If the current query buffer is empty, the most recently executed query
+ is printed instead.
\w or \write |>command
-
Outputs the current query buffer to the file
+
Writes the current query buffer to the file
class="parameter">filename or pipes it to the shell
command command.
+ If the current query buffer is empty, the most recently executed query
+ is written instead.
displayed with a header that includes the \pset title>
string (if any), the time as of query start, and the delay interval.
+ If the current query buffer is empty, the most recently sent query
+ is re-executed instead.
+