Search code examples
postgresqlquoted-identifier

cannot drop database in postgres using terminal


I created a database with the name "femme-myp " in postgres. There was no problem while creation or while using tables in python Django. but when i try to drop the database in terminal it says there is an error in the name and it points at the "-" in the name.Is there any way I can drop that database?

ERROR:  syntax error at or near "-"
LINE 1: DROP DATABASE femme-myp;
                           ^

Solution

  • try with quotes in the database name:

    DROP DATABASE "femme-myp";
    

    All identifiers that don't start with a letter and contain characters other than letters, digits and the underscore _ must be quoted.