gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 10:36:53 25 4
gpt4 key购买 nike

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。您使用双引号作为列名称创建了表,这使得它们区分大小写,并且您必须始终使用双引号:

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

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

关于insert - PostgreSQL sql命令错误列 'does not exist',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28849141/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com