3

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.

  • You need to double-quote the name: DROP DATABASE "RoutingApp_development" ; – ypercubeᵀᴹ Jul 27 '17 at 23:13
4

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";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.