Total Pageviews

2018/07/09

[PostgreSQL] How to insert data with new line character?

Problem
I have a table which name Test
The content column will have new line characters, I try to use \n to insert but in vain.
1
2
   insert into test (project_id, name, content) 
   values(5, 'test', 'aaa\nbbb');

How-To
I should use chr(10) instead of \n. Therefore, the SQL statement will be updated as bellows:
1
2
   insert into test (project_id, name, content) 
   values(5, 'test', 'aaa' || chr(10) || 'bbb');


No comments: