2

I have a csv file :

SrNo,TradeDate,TradeTime,SettlementNo
1,25-Apr-17,14:48:19,NSE-N-2017077
2,05-May-17,09:33:28,NSE-N-2017084

I am trying to upload this file using the command:

copy public.shares(SrNo,TradeDate,TradeTime,SettlementNo) from 'C:/Users/Dell/Downloads/report_jul2018.csv' with csv header;

It is giving the error:

ERROR: column "srno" of relation "shares" does not exist SQL state: 42703

Any solution?

11
  • 1
    What columns does shares have? perhaps you need to say "SrNo"? Commented Jul 14, 2018 at 10:31
  • I have added the file header and the query above. I am running the same query. Commented Jul 14, 2018 at 10:33
  • yeah, but how is the table defined? that error message says that srno is not the name of one of it's columns. Commented Jul 14, 2018 at 10:34
  • i have just created the table...i have not added the columns. Shoudn't the columns get defined from the csv header? Commented Jul 14, 2018 at 10:39
  • 1
    Possible duplicate of Can I automatically create a table in PostgreSQL from a csv file with headers? Commented Jul 14, 2018 at 11:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.