what's the escape sequence for hyphen (-) in PostgreSQL

你离开我真会死。 提交于 2019-11-29 10:34:32

问题


I'm trying to rename a database to a name with a hyphen (-).

ALTER DATABASE one RENAME TO one-two;

And psql returns an error:

ERROR:  syntax error at or near "-"

What should I use as an escape sequence for "-" character or what's the way to do the above?

Note: I've tried the '\-' and didn't work as well.

Thanks.


回答1:


Double quotes should do it. But you'll have to always use the quoted-identifier everywhere you reference the database.

ALTER DATABASE one RENAME TO "one-two";


来源:https://stackoverflow.com/questions/3942759/whats-the-escape-sequence-for-hyphen-in-postgresql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!