psql列不存在,但它确实存在
我试图从psql命令行中使用postgresql数据库中的原始SQL在数据表中选择一列。我收到一条错误消息,说该列不存在。然后它提示我使用select语句中引用的确切列。以下是查询:psql列不存在,但它确实存在,sql,postgresql,Sql,Postgresql,我试图从psql命令行中使用postgresql数据库中的原始SQL在数据表中选择一列。我收到一条错误消息,说该列不存在。然后它提示我使用select语句中引用的确切列。以下是查询: SELECT insider_app_ownershipdocument.transactionDate FROM insider_app_ownershipdocument; 以下是错误消息: ERROR: column insider_app_ownershipdocument.transactiondat
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;
大写-transactiondate vs transactiondate?如果你不给insider_app_ownershipdocument打电话,我就试过了。transactiondate只是transactiondate发生了什么?你是说在创建表时,他们将列名放在引号transactiondate中,这迫使他们现在每次都在列名上使用引号?我理解对了吗?如果是这样,他们可能更愿意将该列重命名为transactiondate。不,不完全是这样。如果选择了区分大小写的名称,则必须始终引用该名称。这不是很舒服,所以我会避免使用区分大小写的名称。但这是品味的问题。