PostgreSQL newline character

Viewed 107527

How to use newline character in PostgreSQL?

This is an incorrect script from my experiment:

select 'test line 1'||'\n'||'test line 2';

I want the sql editor display this result from my script above:

test line 1
test line 2

But unfortunately I just get this result from my script when I run it in sql editor:

test line 1 test line 2
2 Answers

If you want to search if a jsonb contains \n this works

SELECT * FROM table
WHERE column ~ '^.*\\n.*$'
Related