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
A seasoned Senior Solutions Architect with 20 years of experience in technology design and implementation. Renowned for innovative solutions and strategic insights, he excels in driving complex projects to success. Outside work, he is a passionate fisherman and fish keeper, specializing in planted tanks.
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…
Thanks a ton – this was bothering me for the last hour.
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 )
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
Thanks a bunch, I was having the exact same error.
Same problem here, thanks.
Is there any workaround to solve this error.?
@trasna – Yes, did you read the article? You have to use single quotes instead of double quotes.
Thank you very much!!
Muchas Gracias!!
Had this problem too, thanks!
You are a life saver! OMG! How odd this can be? Thanks a lot!! 🙂
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
Ah, thank you! I’m up at 12.42am because of this. FFS >:(
Thanks a lot for sharing this.
What a stupid error!
Thanks a lot ! Very helpful, unlike the error message 🙂
Thank you!
This saved me a ton of time. Thanks!
Thanks! You’re still saving desperate devs all these years later!
Same here!!
That solution helped after a long time of frustration..
Thanks!
Damn, you saved my day! Very stupid of PostgreSQL!!
Wow! This just saved my ass on amazon redshift!
Thanks! You’re still saving desperate devs all these years later!
Thank you, same issue as everyone else.
Does anybody know how to fix this error if you are importing an excel file?