在 psql 中使用 \o 时如何指定 csv 分隔符?

How to specify csv delimiter when using \o in psql?

我正在使用

\o /some/file/path/output.csv

如何指定分隔符?它似乎默认为管道 | 但我的数据包含该字符因此破坏了 csv 输出。

您可以设置字段分隔符...

\pset fieldsep ','

fieldsep

Specifies the field separator to be used in unaligned output format. That way one can create, for example, tab- or comma-separated output, which other programs might prefer. To set a tab as field separator, type \pset fieldsep '\t'. The default field separator is '|' (a vertical bar).

https://www.postgresql.org/docs/current/app-psql.html