Thread: Drop Database
I can not find an explanation to help me understand why
mydb=# drop database November;
fails, while
[Forest-Fellings-Computer:~] dropdb -i -e November
succeeds.
Will appreciate any help to point me to an understanding of this.
Mac OS 10.2.2; PostgreSQL 7.2.3
Learning SQL with "Practical PostgreSQL" by Worsley & Drake, "PostgreSQL Essential Reference" by Barry Stinson, "SQL for Smarties" by Joe Celko and the docs downloaded from http://www.postgresql.org. Can not find an answer in any of these books.
Complete shell listing follows.
mydb=# \l
List of databases
Name | Owner | Encoding
-----------+----------+----------
November | fwf | UNICODE
booktown | fwf | UNICODE
homepage | mitch | UNICODE
hospice | fwf | UNICODE
mydb | fwf | UNICODE
template0 | postgres | UNICODE
template1 | postgres | UNICODE
(7 rows)
List of databases
Name | Owner | Encoding
-----------+----------+----------
November | fwf | UNICODE
booktown | fwf | UNICODE
homepage | mitch | UNICODE
hospice | fwf | UNICODE
mydb | fwf | UNICODE
template0 | postgres | UNICODE
template1 | postgres | UNICODE
(7 rows)
mydb=# drop database November;
ERROR: DROP DATABASE: database "november" does not exist
mydb=# \q
ERROR: DROP DATABASE: database "november" does not exist
mydb=# \q
[Forest-Fellings-Computer:~] fwf% dropdb -i -e November
Database "November" will be permanently deleted.
Are you sure? (y/n) y
DROP DATABASE "November"
DROP DATABASE
Database "November" will be permanently deleted.
Are you sure? (y/n) y
DROP DATABASE "November"
DROP DATABASE
[Forest-Fellings-Computer:~] fwf%
Forest W Felling <res08i7v@verizon.net> writes: > I can not find an explanation to help me understand why > mydb=# drop database November; > fails, while > [Forest-Fellings-Computer:~] dropdb -i -e November > succeeds. In the SQL command, you need drop database "November"; See the User's Guide's discussion of identifiers, particularly case-folding and quoting. Our command-line tools generally double-quote whatever they find on their command lines, so that what dropdb sent to the server was in fact DROP DATABASE "November". This makes their behavior a little inconsistent compared to raw SQL, but the other way proved too unwieldy because of shell quoting rules. If dropdb did not supply double quotes then you'd have had to type something like dropdb '"November"' which is awfully tedious. regards, tom lane