如何转义vertica(vsql)中字符串中的引号?
因此,我需要将一些值插入到 vertica 数据库中(通过 vsql),其中可能包含引号和各种特殊字符。但vertica似乎不理解字符转义。例如:
rpt=> select "asdasda\"asdasdad" from some_table limit 1;
rpt"> ";
ERROR: syntax error at or near "" from some_table limit 1;
"" at character 26
LINE 1: select "asdasda\"asdasdad" from some_table limit 1;
这不是插入语句,但你应该明白了。
So I need to insert some values into a vertica database (via vsql), which may contain quotes and all sorts of special characters. But vertica does not seem to understand character escaping. For example:
rpt=> select "asdasda\"asdasdad" from some_table limit 1;
rpt"> ";
ERROR: syntax error at or near "" from some_table limit 1;
"" at character 26
LINE 1: select "asdasda\"asdasdad" from some_table limit 1;
This is not the insert statement, but you should get the idea.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,首先我应该使用单引号。转义序列曾经在早期版本中工作(我相信在 4.0 之前),但现在默认情况下它们是关闭的。如果您不想调整数据库配置参数,您有两个选择。
使用 E' 语法:
或者将需要转义的引号加倍:
Well, first off I should have used single quotes. Escape sequences used to work in earlier versions (before 4.0 I believe), but now they are off by default. If you do not want to tweak database config parameters you have two options.
Use E' syntax:
Or double the quotes that need to be escaped: