postgresql 在用户名中转义破折号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2293595/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-20 00:02:18  来源:igfitidea点击:

escaping dash in username

databasepostgresql

提问by gavz

I'm having difficulty modifying a postgres user that contains a dash in its name - I've run into this problem several times, but can never find the answer (no matter how much googling I do!).

我在修改名称中包含破折号的 postgres 用户时遇到了困难 - 我已经多次遇到这个问题,但永远找不到答案(无论我做了多少谷歌搜索!)。

osm=# grant all on osm_polygon_view to www-data;

ERROR: syntax error at or near "-"

LINE 1: grant all on osm_polygon_view to www-data;

                                       ^

osm=# 将 osm_polygon_view 上的所有内容授予 www-data;

错误:“-”处或附近的语法错误

第 1 行:将 osm_polygon_view 上的所有内容都授予 www-data;

                                       ^

I have tried just about every permutation of escape characters and quotes, and still can't get this to work. I have also encountered this when trying to change www-data password.

我已经尝试了几乎所有转义字符和引号的排列,但仍然无法使其正常工作。我在尝试更改 www-data 密码时也遇到过这种情况。

回答by gavz

Double quotes is what you should use - not single quotes.

双引号是您应该使用的 - 而不是单引号。

grant all on osm_polygon_view to "www-data";

将 osm_polygon_view 上的所有内容都授予“www-data”;