代码之家  ›  专栏  ›  技术社区  ›  Paul

PostgreSQL 9.5.4中的奇怪案例转换[副本]

  •  0
  • Paul  · 技术社区  · 7 年前
    SELECT AVG(MY_AE_Actual) FROM MY_Data_Details
    

    导致错误:

    错误:“我的\ae \u实际值”列不存在 第1行:从“我的数据”详细信息中选择“平均值”(“我的实际值”)。 ^ 提示:也许您是想引用“我的数据详细信息,我的实际信息”一栏。 **********费勒**********

    错误:“我的\ae \u实际值”列不存在 SQL状态:42703 辛维斯:也许你是想引用“我的数据,我的实际”一栏。 齐琴:12

    更新

    这很奇怪。我现在用下表在PostgreSQL 10中进行了测试:

    CREATE TABLE public.testable
    (
        id integer NOT NULL DEFAULT nextval('testable_id_seq'::regclass),
        string_data1 character varying(255) COLLATE pg_catalog."default",
        "String_Data2" character varying(255) COLLATE pg_catalog."default",
        "string_Data3" character varying(255) COLLATE pg_catalog."default",
        "String_data4" character varying(255) COLLATE pg_catalog."default",
        CONSTRAINT testable_pkey PRIMARY KEY (id)
    )
    

    select string_data1 from testable -成功
    select String_data1 from testable -成功
    select string_Data1 from testable -成功
    select String_Data1 from testable -成功
    select "string_data1" from testable -成功
    select "String_data1" from testable -失败
    select "string_Data1" from testable -失败
    select "String_Data1" from testable -失败
    select string_data2 from testable -失败
    select String_data2 from testable -失败
    select string_Data2 from testable -失败
    select String_Data2 from testable -失败
    select "string_data2" from testable -失败
    select "String_data2" from testable -失败
    select "string_Data2" from testable -失败
    select "String_Data2" from testable -成功

    事实证明,不加引号的PostgreSQL不是“不区分大小写”,而是“小写”,根本没有意义。

    1 回复  |  直到 7 年前
        1
  •  1
  •   Paul    7 年前

    ThisFieldName == thisfieldname
    

    但是:

    "ThisFieldName"  <> ThisFieldName
    "ThisFieldName"  <> thisfieldname
    

    "ThisFieldName" 你同样需要参考它。

    MY_AE_Actual 但是PostgreSQL告诉你 my_ae_actual

    _

    推荐文章