Search code examples
postgres-xldrop-database

Drop database which has a "minus" in its name in Postgres


I've this database named a-b in postgres and I'm unable to delete it using this query drop database "a-b";. The double quotes were supposed to work but sadly, they didn't. I'm using Postgres-XL r1.3.

The error message I receive is:

ERROR: syntax error at or near "-"


Solution

  • You could try renaming it first perhaps? ALTER DATABASE "a-b" RENAME TO adashb; Then follow up with a DROP DATABASE adashb;