delete “column does not exist”

隐身守侯 提交于 2019-11-26 11:39:55

问题


I\'m trying to execute a very simple delete query in Postgres

Query:

delete from \"Tasks\" where id = \"fc1f56b5-ff41-43ed-b27c-39eac9354323\";

Result:

ERROR:  column \"fc1f56b5-ff41-43ed-b27c-39eac9354323\" does not exist
LINE 1: delete from \"Tasks\" where id = \"fc1f56b5-ff41-43ed-...

I have a simple table with a record where the id is that value. Why does it thing that \"fc1f56b5-ff41-43ed-b27c-39eac9354323\" is the column name?


回答1:


The problem is that you are using double quotes (") and single quotes (') interchangeably. SQL treats what's inside double quotes "" as an identifier (i.e., table name, proc name, column name, etc.), character constants need to be enclosed in single quotes

You can say:

delete from "Tasks" where id = 'fc1f56b5-ff41-43ed-b27c-39eac9354323'


来源:https://stackoverflow.com/questions/52596779/delete-column-does-not-exist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!