\g
Sends the current query buffer to the server for execution.
Reading PG 18·Select a recorded version
- Client
- psql 18.7
- Case-sensitive spelling
- \g
- command
- \g
- manual path
- app-psql.html#APP-PSQL-META-COMMAND-G
- modifiers
- Unknown
- signature
- \g [ ( option = value [...]) ] [ filename ] \g [ ( option = value [...]) ] [ | command ]
- spellings
- \g
Definition PG 18
\g [ (option=value[...]) ] [filename]\g [ (option=value[...]) ] [ |command]Sends the current query buffer to the server for execution.
If parentheses appear after
\g, they surround a space-separated list ofoption=valueformatting-option clauses, which are interpreted in the same way as\psetoptionvaluecommands, but take effect only for the duration of this query. In this list, spaces are not allowed around=signs, but are required between option clauses. If=valueis omitted, the namedoptionis changed in the same way as for\psetoptionwith no explicitvalue.If a
filenameor|commandargument 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.If the current query buffer is empty, the most recently sent query is re-executed instead. Except for that behavior,
\gwithout any arguments is essentially equivalent to a semicolon. With arguments,\gprovides a “one-shot” alternative to the\ocommand, and additionally allows one-shot adjustments of the output formatting options normally set by\pset.When the last argument begins with
|, the entire remainder of the line is taken to be thecommandto execute, and neither variable interpolation nor backquote expansion are performed in it. The rest of the line is simply passed literally to the shell.
Exact case-sensitive spellings
\g
Spellings in this manual definition
| Command | Documented suffix modifiers |
|---|---|
| \g | None listed in this signature |
Compare versions
Complete source facts
documentation revision
{"inputs":[{"file":"app-psql.html","kind":"same-version-reviewed-manual","locale":"en","sha256":"af50448485df02bdef2b72b8347192ba029c7082b8d0392ecb17db44ad533aaf","version":"18.7"},{"file":"app-psql.html","kind":"same-version-reviewed-manual","locale":"zh-Hans","sha256":"cb475c53a16d9e06358f5e6c9c5649645db92568cfd319f230c62c9f57ae090b","version":"18.7"}],"release":"18.7","runtime_remeasured":false,"source_revision":"pgdoc:b9f0e7232f60f380d642ac9b99226606c254b552"}Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · 1b2d62b4845aa46374f2cb680f95d3392322cc8128646992ae4e18d0e7084915
Text language: en · 1b2d62b4845aa46374f2cb680f95d3392322cc8128646992ae4e18d0e7084915