I’m looking for a way to insert a multiline text into PostgreSQL table (column).
Screenshot of the insert query
Suppose I have a table ‘problem’ within the data.sql file, and I want to insert a multiline text into DETAILS column.
What should I do?
>Solution :
You can use String Constants With C-Style Escapes by adding an E before the text constant, then an \n wherever you want a newline: demo
create table test(id serial primary key, a text);
insert into test (a) values (E'line1\nline2\nline3') returning *;
| id | a |
|---|---|
| 1 | line1 line2 line3 |