char - Insert line break in postgresql when updating text field -
char - Insert line break in postgresql when updating text field -
i trying update text field in table of postgresql database.
update public.table set long_text = 'first line' + char(10) + 'second line.' id = 19;
my intended result cell this:
first line sec linethe above syntax returns error.
you want chr(10)
instead of char(10)
.
be careful this, because might wrong newline. "right" newline depends on client consumes it. macs, windows, , linux utilize different newlines. browser expect <br />
.
it might safest write update postgresql 9.1+. read docs linked below.
update public.table set long_text = e'first line\nsecond line.' id = 19;
the default value of 'standard_conforming_strings' 'on' in 9.1+.
show standard_conforming_strings;
postgresql char sql-update
Comments
Post a Comment