0

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

Muck
  • 3
  • 2

1 Answers1

3

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).

GMB
  • 216,147
  • 25
  • 84
  • 135
  • The thing is... the update is sooooo finicky. Like okay, I will use single quotes for when I want to set a value in a column, but oh, you want to select a table with a weird name? Great, then use double quotes! Which means I have to use `format()` to format the string properly! – Shmack Feb 02 '22 at 19:54