PostgreSQL sql命令错误列'不存在'

Joe*_*Lin 5 insert

dxdb=> \d dxtest_loadprofiletosale
                            Table "public.dxtest_loadprofiletosale"
   Column    |   Type   |                               Modifiers                               
-------------+----------+-----------------------------------------------------------------------
 id          | integer  | not null default nextval('dxtest_loadprofiletosale_id_seq'::regclass)
 TransDate   | date     | 
 IssueDate   | date     | 
 CustomerNum | smallint | not null
Indexes:
    "dxtest_loadprofiletosale_pkey" PRIMARY KEY, btree (id)

dxdb=> INSERT INTO dxtest_loadprofiletosale(id, TransDate, IssueDate, CustomerNum) VALUES(1, '2015-03-04','2015-01-01',01);
ERROR:  column "transdate" of relation "dxtest_loadprofiletosale" does not exist
LINE 1: INSERT INTO dxtest_loadprofiletosale(id, TransDate, IssueDat...
Run Code Online (Sandbox Code Playgroud)

对不起,我已经有了专栏"transdate",为什么它说不存在?

a_h*_*ame 8

您的列"TransDate"不是transdate.您使用列引号的双引号创建了表,这使它们区分大小写,并且您必须始终使用双引号:

INSERT INTO dxtest_loadprofiletosale
  (id, "TransDate", "IssueDate", "CustomerNum") 
VALUES
  (1, '2015-03-04','2015-01-01',01);
Run Code Online (Sandbox Code Playgroud)

有关SQL标识符的更多详细信息,请参见手册:http:
//www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

一般来说,最好永远不要使用双引号 - 从长远来看,它会给你带来更少的麻烦.