How to add a line break to PostgreSQL?


You have to insert some data into your PostgreSQL table that has line break. As a result, the cell will look like this:


First line

Second line

To use "escape sequences" in a string literal you need to use an "extended" constant. You can specify the escape character by prefixing the letter E:


UPDATE posts SET body = E'First Line\nSecond line.' WHERE id = 2701;


Ae83459b 2c1e 4725 addb c51a7eb83537 rectangle 400 x
Arina
Shmeleva

Backend Developer at JetRockets