gpt4 book ai didi

sql - psql 列不存在但确实存在

转载 作者:行者123 更新时间:2023-11-29 12:40:33 25 4
gpt4 key购买 nike

我正在尝试从 psql 命令行使用 postgresql 数据库中的原始 SQL 在我的数据表中选择一个列。我收到一条错误消息,指出该列不存在。然后它提示我使用我在 select 语句中引用的确切列。这是查询:

SELECT insider_app_ownershipdocument.transactionDate FROM insider_app_ownershipdocument;

这是错误信息:

ERROR:  column insider_app_ownershipdocument.transactiondate does not exist
SELECT insider_app_ownershipdocument.transactionDate FROM in...
HINT: Perhaps you meant to reference the column "insider_app_ownershipdocument.transactionDate".

我不知道为什么这不起作用。

最佳答案

(Postgres) SQL 会自动将名称转换为小写,尽管它支持区分大小写的名称。所以

SELECT insider_app_ownershipdocument.transactionDate FROM insider_app_ownershipdocument;

将等同于:

SELECT insider_app_ownershipdocument.transactiondate FROM insider_app_ownershipdocument;

您应该用双引号保护列名以避免这种影响:

SELECT insider_app_ownershipdocument."transactionDate" FROM insider_app_ownershipdocument;

关于sql - psql 列不存在但确实存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52656890/

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