3

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?

Catfish
  • 18,876
  • 54
  • 209
  • 353

1 Answers1

18

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'
JustAPup
  • 1,720
  • 12
  • 19
  • There is no such thing as `set quoted_identifier` "in SQL" or Postgres –  Oct 01 '18 at 18:53
  • Thanks for the edit. On my MSSQL, if I set quoted_identifier to OFF, I can then do this: SELECT * FROM table WHERE id= "someValue" – JustAPup Oct 01 '18 at 19:01
  • 1
    Well, that is something specific to Microsoft SQL Server - that is neither "SQL" nor is it valid for Postgres –  Oct 01 '18 at 19:15
  • The best answer that I needed. Thx a lot @JustAPup – Mo1 Aug 03 '21 at 15:32