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

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.



Solution 1:[1]

Mix double quotes and single quotes as such:

psql --command='create database "db-name-with-dashes"'

Solution 2:[2]

Backticks ` is the quoted identifier used to reference the database:

ALTER DATABASE one RENAME TO `one-two`;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 agent_smith
Solution 2