简体   繁体   中英

psql column doesn't exist but it does

I am trying to select a single column in my data table using raw SQL in a postgresql database from the psql command line. I am getting an error message that says the column does not exist. Then it gives me a hint to use the exact column that I referenced in the select statement. Here is the query:

SELECT insider_app_ownershipdocument.transactionDate FROM insider_app_ownershipdocument;

Here is the error message:

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

I have no idea why this is not working.

(Postgres) SQL converts names automatically to lower case although it support case-sensitive names. So

SELECT insider_app_ownershipdocument.transactionDate FROM insider_app_ownershipdocument;

will be aquivalent to:

SELECT insider_app_ownershipdocument.transactiondate FROM insider_app_ownershipdocument;

You should protect the column name with double quotes to avoid this effect:

SELECT insider_app_ownershipdocument."transactionDate" FROM insider_app_ownershipdocument;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM