Postgresql:带有“\”的用户角色名义上
我在创建角色时犯了一个错字。现在我被“\ruser”困住了,我不知道如何正确地放弃这个角色。以任何方式转义反斜杠都不起作用,使用 unicode 格式不起作用(删除角色 U&'%0Dmyuser';)或任何类型的字符串标记(",',`)都不起作用。有什么想法吗?
server=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
\rmyuser | Superuser, Create role, Create DB | {}
myuser | Superuser, Create role, Create DB | {}
I made a typo while creating a role. Now I'm stuck with "\ruser" and I have no clue how to properly drop that role. Escaping the backslash in any kind of way doesn't work, using unicode formating doesnt work (drop role U&'%0Dmyuser';) or any kind of string markings (",',`) won't work. Any ideas?
server=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
\rmyuser | Superuser, Create role, Create DB | {}
myuser | Superuser, Create role, Create DB | {}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需用双引号转义标识符:
如果
\r
不是反斜杠和r
,而是“回车符”的转义版本,最简单的方法可能是使用动态 SQL、扩展字符串文字语法和format
函数:Simply escape the identifier with double quotes:
In the case that
\r
is not a backslash and anr
, but an escaped version of "carriage return", the simplest way may be to use dynamic SQL, the extended string literal syntax and theformat
function: