HiveBrain v1.2.0
Get Started
← Back to all entries
debugsqlMajor

ERROR: database "dbname" does not exist

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
dbnameerrorexistdatabasedoesnot

Problem

According to the documentation, so long as I'm not connected to a database, I can either delete a database in the console using:

DROP DATABASE dbname;


Or I can drop it using the wrapper tool dropdb.

Both give me an error saying the database doesn't exist, yet when in the console and typing the command \l, I get a list of databases including the one I want to delete.

List of databases
           Name            |   Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
---------------------------+-----------+----------+-------------+-------------+-----------------------
 Blog_development          | myusername | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 Blog_test                 | myusername | UTF8     | en_US.UTF-8 | en_US.UTF-8 |


The database name is Blog_development (and the one below it). I was playing with rails and trying to learn from the online documentation. I wanted to start over and delete everything.

When trying to delete it however, it says it doesn't exist. I'm brand new to PostgreSQL so I'm a bit lost, nothing in the documentation about this error other than it popping up when it doesn't exist. Of course it exists, it's right there.

Solution

Your database was created using double quotes so its name is now case-sensitive. Therefore, you now need to always use double quotes when referring to it:

drop database "Blog_test";


More details about quoted identifiers (a database name is an identifier just like a column or table name) can be found in the manual:
http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

Code Snippets

drop database "Blog_test";

Context

StackExchange Database Administrators Q#31059, answer score: 43

Revisions (0)

No revisions yet.