↑↓ select↵ open⌫ change scopeOpen full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / psql Commands

\o

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

Reading PG 18·Select a recorded version

Client
psql 18.7
Case-sensitive spelling
\o
command
\o
manual path
app-psql.html#APP-PSQL-META-COMMAND-OUT
modifiers
Unknown
signature
\o or \out [ filename ] \o or \out [ | command ]
spellings
\o, \out

Definition PG 18

\o or \out [ filename ]
\o or \out [ |command ]

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

If the argument begins with |, then the entire remainder of the line is taken to be the command 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.

“Query results” 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 \d); but not error messages.

Tip

To intersperse text output in between query results, use \qecho.

Exact case-sensitive spellings

  • \o
  • \out

Spellings in this manual definition

CommandDocumented suffix modifiers
\oNone listed in this signature
\outNone 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