Error: Column does not exist in postgresql for update [duplicate]

假装没事ソ 提交于 2021-02-13 05:48:27

问题


I am trying to insert a line of text into a column where that column is null. Error listed below. Any help is greatly appreciated

UPDATE public.meditech_ar_test4
SET filename = "text"
WHERE filename is null;

ERROR: column "text" does not exist: I am aware that column does not exist, I want to insert it into the field


回答1:


In Postgres, double quote stand for identifiers (such as table or column names). Here, you actually want a string literal, so you need single quotes:

UPDATE public.meditech_ar_test4
SET filename = 'text'
WHERE filename is null;

Some databases (namely, MySQL), tolerate double quotes for string literals, while using other characters for identifiers (in MySQL: backticks). However in that regard Postgres follows the rules of standard SQL, which defines double quotes for identifiers. You should just take the habit of always using single quotes for string literals (most databases do support that).



来源:https://stackoverflow.com/questions/61352880/error-column-does-not-exist-in-postgresql-for-update

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