Postgres – Column “name” Does Not Exist

I don’t use Postgres very often, as I prefer MySQL, however a project I took over was built off Postgres and I find myself running into silly little road blocks. Today I encountered one that made me want to slap the developer when I finally realized what was going on. I created a simple insert query and tried to run it, and was presented with this error:

ERROR: column "-12.0" does not exist

The query I was trying to run was this:

INSERT INTO timezones (gmt_offset, "description")
VALUES
("-12.0","(GMT -12:00) Eniwetok, Kwajalein"),
("-11.0","(GMT -11:00) Midway Island, Samoa"),
("-10.0","(GMT -10:00) Hawaii"),
("-9.0","(GMT -9:00) Alaska"),
("-8.0","(GMT -8:00) Pacific Time (US & Canada)"),
("-7.0","(GMT -7:00) Mountain Time (US & Canada)"),
("-6.0","(GMT -6:00) Central Time (US & Canada), Mexico City"),
("-5.0","(GMT -5:00) Eastern Time (US & Canada), Bogota, Lima"),
("-4.0","(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz"),
("-3.5","(GMT -3:30) Newfoundland"),
("-3.0","(GMT -3:00) Brazil, Buenos Aires, Georgetown"),
("-2.0","(GMT -2:00) Mid-Atlantic"),
("-1.0","(GMT -1:00 hour) Azores, Cape Verde Islands"),
("0.0","(GMT) Western Europe Time, London, Lisbon, Casablanca"),
("1.0","(GMT +1:00 hour) Brussels, Copenhagen, Madrid, Paris"),
("2.0","(GMT +2:00) Kaliningrad, South Africa"),
("3.0","(GMT +3:00) Baghdad, Riyadh, Moscow, St. Petersburg"),
("3.5","(GMT +3:30) Tehran"),
("4.0","(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi"),
("4.5","(GMT +4:30) Kabul"),
("5.0","(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent"),
("5.5","(GMT +5:30) Bombay, Calcutta, Madras, New Delhi"),
("5.75","(GMT +5:45) Kathmandu"),
("6.0","(GMT +6:00) Almaty, Dhaka, Colombo"),
("7.0","(GMT +7:00) Bangkok, Hanoi, Jakarta"),
("8.0","(GMT +8:00) Beijing, Perth, Singapore, Hong Kong"),
("9.0","(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk"),
("9.5","(GMT +9:30) Adelaide, Darwin"),
("10.0","(GMT +10:00) Eastern Australia, Guam, Vladivostok"),
("11.0","(GMT +11:00) Magadan, Solomon Islands, New Caledonia"),
("12.0","(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka");

I found this to be very odd, as I’ve written queries just like that countless times.  So I tried tweaking the column types, I tried both text and numeric but just wasn’t getting anywhere.  Eventually, just on a whim, I replaced the double quotes with single quotes and it took the query.  For some reason Postgres interprets the query in a completely different way if you use double quotes.  How odd :S


Tags: , , ,

  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS

22 Responses to “Postgres – Column “name” Does Not Exist”

  1. Lee says:

    What a godsend — I’m in the exact situatino you describe, and the quotes were the problem for me. The error message I was getting said a column did not exist, and quoted the name of that column as a string value I’d passed in …!
    I really miss MySQL…

  2. Jacob says:

    Thanks a ton – this was bothering me for the last hour.

  3. xia says:

    I got the same error too,but if I tried to add another table , it is right .
    maybe it is a bug of postgresql。

    If I add an column in my first table in my database in postgresql, error message is : column not found ;if I delete all columns ,error message is : syntax error at or near “FROM” (what I do is just execute a sql statement:select * from )

  4. Avukonke Peter says:

    I got the same error and was wondering what the F*&k is going on. Are you serious, lack of double qoute support, now that already put’s me off postgres. MySQL is king

  5. Fa says:

    Thanks a bunch, I was having the exact same error.

  6. Matheus Aguiar says:

    Same problem here, thanks.

  7. trasna says:

    Is there any workaround to solve this error.?

  8. FettesPS says:

    @trasna – Yes, did you read the article? You have to use single quotes instead of double quotes.

  9. xr09 says:

    Thank you very much!!
    Muchas Gracias!!

  10. vkozyrev says:

    Had this problem too, thanks!

  11. Nishanth says:

    You are a life saver! OMG! How odd this can be? Thanks a lot!! 🙂

  12. coronel morris says:

    OMG THAT’S EXACTLY MY PROBLEM, how I hate SQL, the error handling is just a joke
    THANK YOU SO MUCH you just saved my nerves from wrecking

  13. Lloyd says:

    Ah, thank you! I’m up at 12.42am because of this. FFS >:(

  14. Sam says:

    Thanks a lot for sharing this.
    What a stupid error!

  15. Sylvain says:

    Thanks a lot ! Very helpful, unlike the error message 🙂

  16. -- says:

    Thank you!

  17. Joey says:

    This saved me a ton of time. Thanks!

  18. Michael says:

    Thanks! You’re still saving desperate devs all these years later!

  19. Lutzel says:

    Same here!!
    That solution helped after a long time of frustration..

    Thanks!

  20. Damn, you saved my day! Very stupid of PostgreSQL!!

  21. Anonoz says:

    Wow! This just saved my ass on amazon redshift!

  22. yy4410???? says:

    Thanks! You’re still saving desperate devs all these years later!

Leave a Reply