postgres - where in (list) - column does not exist

后端 未结 2 2003
梦毁少年i
梦毁少年i 2020-12-07 05:58

I\'m coming from SQL Server and I was suprised to see that the following query does not work:

DELETE FROM user_job_titles WHERE id IN (
\"c836d018-1d12-4507-         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-07 06:01

    You need to quote string literals with '

    DELETE FROM user_job_titles 
    WHERE id IN (
    'c836d018-1d12-4507-a268-a4d80d6d3f54',
    'd0961a90-7d31-4c4c-9c1b-671115e3d833',
    '62dda420-6e62-4017-b41d-205c0aa82ead'
    );
    

    I'm coming from SQL Server and I was suprised to see that the following query does not work

    Then you have SET QUOTED_IDENTIFIER AS OFF. By default it is ON.

    When SET QUOTED_IDENTIFIER is ON, all strings delimited by double quotation marks are interpreted as object identifiers.

    Check:

    SET QUOTED_IDENTIFIER OFF;
    SELECT "A"
    
    
    -- The same behaviour as in Postgresql
    SET QUOTED_IDENTIFIER ON;
    SELECT "A"
    -- Invalid column name 'A'.
    

    LiveDemo

提交回复
热议问题