PostgreSQL Error – Database Does Not Exist

postgresql

I created a Ruby on Rails application just for demonstration to a colleague and then deleted the application, but I did not delete the database which was also created using Postgresql.

I go into posgresql like so:

psql postgres

postgres=# \l
                                            List of databases
                 Name                 | Owner  | Encoding |   Collate   |    Ctype    | Access privileges
--------------------------------------+--------+----------+-------------+-------------+-------------------
 GenerateApp_development              | danale | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 GenerateApp_test                     | danale | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 GeneratorApp_development             | danale | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 GeneratorApp_test                    | danale | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 Overtime_development                 | danale | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 Overtime_test                        | danale | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 RoutingApp_development               | danale | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 RoutingApp_test                      | danale | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 dancortesPortfolio_development       | danale | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 dancortesPortfolio_test              | danale | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 freelance_camp_documents_development | danale | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 freelance_camp_documents_test        | danale | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 freelance_camp_proposal_development  | danale | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 freelance_camp_proposal_test         | danale | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 postgres                             | danale | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 template0                            | danale | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/danale        +
                                      |        |          |             |             | danale=CTc/danale
 template1                            | danale | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/danale        +
                                      |        |          |             |             | danale=CTc/danale
(17 rows)

I want to delete the ones that say RoutingApp_development and test.

postgres=# DROP DATABASE RoutingApp_development;
ERROR:  database "routingapp_development" does not exist

I get that error above. I have tried to search for why this is happening online and I have been unsuccessful in finding the answer, please help.

Best Answer

You need to double quote the name. In PostgreSQL we never double quote names. If you follow the convention, PostgreSQL will convert the unquoted identifier to lower case. In your case, that which created the db used double quotes.

Now you have a capital letter in the identifier.

From now on you have to double quote the identifier.

Not,

postgres=# DROP DATABASE RoutingApp_development;

But,

postgres=# DROP DATABASE "RoutingApp_development";