Insert line break in postgresql when updating text field

前端 未结 4 2026
小鲜肉
小鲜肉 2020-12-29 18:13

I am trying to update a text field in a table of my postgresql database.

UPDATE public.table SET long_text = \'First Line\' + CHAR(10) + \'Second line.\' WHE         


        
4条回答
  •  醉话见心
    2020-12-29 18:29

    PostgreSQL:

    varchar + varchar = ERROR. \ r and \ n is not anywhere that works, for greater compatibility use:

    Corret:

    UPDATE public.table SET 
       long_text = concat('First Line',CHR(13),CHR(10),'Second line.')
    WHERE id = 19;
    

提交回复
热议问题