Escape all single quotes in postgresql

送分小仙女□ 提交于 2019-12-02 02:25:47

问题


Instead of escaping each ' in text, is there any way to escape them all at once, something like this:

insert into table1(data) values(@'it's a string, it's got some single quotes')

回答1:


insert into table1(data) values
($$it's a string, it's got some single quotes$$)

Dollar quoting

A dollar-quoted string constant consists of a dollar sign ($), an optional "tag" of zero or more characters, another dollar sign, an arbitrary sequence of characters that makes up the string content, a dollar sign, the same tag that began this dollar quote, and a dollar sign



来源:https://stackoverflow.com/questions/39107715/escape-all-single-quotes-in-postgresql

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