Defining multi-line strings in psql

懵懂的女人 提交于 2020-08-24 05:58:56

问题


I would like to paste

  123
  456
  789

into psql and to store multi-line string in some variable (ie. :str) for later use.

Is that possible? Now I'm getting unterminated quoted string error.


回答1:


A little clunky, but in version 9.3 and up, you can do it with \gset in conjunction with a dollar-quoted literal:

SELECT
$$123
456
789$$ AS str \gset


来源:https://stackoverflow.com/questions/31454108/defining-multi-line-strings-in-psql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!