I just started to use PostgreSQL
in my project, but i've this error when retrieving data from table. Is someone have suggestions for this problem?

- 195,425
- 15
- 312
- 343

- 43
- 9
-
Please share the code. – mjwills Jul 26 '20 at 02:11
-
Does that AssetTransactions table exist? Have you read https://dba.stackexchange.com/questions/101570/error-42p01-relation-does-not-exist ? – mjwills Jul 26 '20 at 02:11
-
Please share the `CREATE TABLE` script for `AssetTransactions`. – mjwills Jul 26 '20 at 02:11
4 Answers
It seems table name and column names are in CamelCase
.
PostgreSQL treat all the statements in lower case generally, As you can see the error where table name is shown in lower case.
So if above is the case then cover all such table name and column names with ""
. so your query should be:
select "Id", "AccountID", "IsPurchase", "Stock_Symbol","Stock_PricePerShare","Shares","DateProcessed" from "AssetTransactions"
Please note that if any column name is in smallcase then no need to cover in ""
.
If your schema is other than public
then your table name should be like "schema_name"."table_name"

- 5,876
- 3
- 16
- 32
-
-
its a good practice to use small case names always to avoid such problems. – Akhilesh Mishra Jul 26 '20 at 03:32
AssetTransactions
table does not exist, or it may not be present in the current default schema
.
Use query with schema SELECT * FROM public.AssetTransactions

- 8,280
- 11
- 53
- 103
-
well, ive trying that script but its not worked. but thank for giving me a suggestion for the problem haha – lemonsprite Jul 26 '20 at 03:32
The database query is on an undefined table. This error occurs due to improper database setup, unidentified table name, and so on.
For instance, the customer query on table name ‘pgtable‘ like:
SELECT * FROM pgtable
This query is totally correct in case of a public schema. But, for a non-public schema ‘xx’ the query must be:
SELECT * FROM "xx"."pgtable"
so first check that you have proper database setup, then check that you didnt quote any identifiers because then you'll have to use it as how u quoted it, then check your schema

- 21
- 5
I had a similar problem The problem is solved if the table names are in lower case Make sure all words are in lower case

- 1