Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to insert multiline text into a column of the PostgreSQL table?

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading