在PostgreSQL中转义所有单引号 [英] Escape all single quotes in postgresql

查看:1335
本文介绍了在PostgreSQL中转义所有单引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以一次将它们全部转义,而不是在文本中转义每个',就像这样:

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')


推荐答案

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

美元报价


用美元引号括起来的字符串常量由一个美元符号($),一个零个或多个字符的可选标记,另一个美元符号,构成字符串内容的任意字符序列组成,一个美元符号,与该美元报价相同的标签和一个美元符号

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

这篇关于在PostgreSQL中转义所有单引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆