PostgreSQL - 如何在用户名中删除使用hypen的用户

Nik*_*ola 2 postgresql

DROP USER username如果用户名包含超量( - ),我似乎无法执行,例如user-name.

我试着直截了当DROP USER user-name,DROP USER 'user-name'但是我得到了:ERROR: syntax error at or near "'user-name'".

我猜我需要使用某种逃避或其他东西,但找不到它,所以请帮忙.

a_h*_*ame 5

标识符需要使用双引号引用,单引号用于字符串文字:

DROP USER "user-name";
Run Code Online (Sandbox Code Playgroud)

手册中的更多细节:http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS