问题
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