Pgsql Stop Spliting Values in Mulitple Lines

建议点击 查看原文 查看最新内容。

原文链接: https://typonotes.com/posts/2023/07/13/pgsql-stop-spliting-values-in-mulitple-lines/

psql doesn’t split your string in multiple lines.

It’s the string that contains new-line characters (ASCII 10), and psql displays them accurately. The + at the end of every line is psql’s way of telling you that the value is continued in the next line.

You can use the unaligned mode (psql option -A) to get rid of the +, but the output format is less attractive then.

You can get rid of the newlines in a string with

1
2
3
4
5
SELECT translate(..., E'\n', '');

# or

SELECT REPLACE(..., E'\n', '');

decode will be able to handle such a string.