PostgreSQL sql 命令错误列 'does not exist'

PostgreSQL sql command error column 'does not exist'

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...

请问,我已经有专栏"transdate",为什么说不存在?

您的专栏名为 "TransDate" 而不是 transdate。您使用双引号为列名称创建了 table,这使它们区分大小写并且您必须使用双引号 all the time:

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

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

一般来说,最好永远不要使用双引号——它会给你带来很多长运行的麻烦。