PostgreSQL column 'foo' does not exist

前端 未结 10 2141
盖世英雄少女心
盖世英雄少女心 2020-12-05 12:32

I have a table that has 20 integer columns and 1 text column named \'foo\'

If I run query:

SELECT * from table_name where foo is NULL
10条回答
  •  执念已碎
    2020-12-05 13:23

    If for some reason you have created a mixed-case or upper-case column name, you need to quote it, or get this error:

    test=> create table moo("FOO" int);
    CREATE TABLE
    test=> select * from moo;
     FOO 
    -----
    (0 rows)
    test=> select "foo" from moo;
    ERROR:  column "foo" does not exist
    LINE 1: select "foo" from moo;
                   ^
    test=> _
    

    Note how the error message gives the case in quotes.

提交回复
热议问题