Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 170
  • Last Modified:

Unable to import to tables in postgresql

I had this question after viewing postgresql problem - script to create tables does not run.

I created the tables and then attempted to import the attached file.  (Note: please rename the file to delete the .pdf)

No luck.

an error window opens:

ERROR: value too long for type character varying(15)
CONTEXT: COPY address_alias, line 1, column address_alias_pid: "ADDRESS_ALIAS_PID"

I am unable to resolve this problem.
ACT_ADDRESS_ALIAS_psv.psv.pdf
0
gregfthompson
Asked:
gregfthompson
  • 3
  • 2
  • 2
1 Solution
 
Terry WoodsIT GuruCommented:
Without checking the previous question, have you tried deleting the first line of the file? If it was trying to load the header as an actual record, it would explain the error.
0
 
Terry WoodsIT GuruCommented:
It looks like the COPY command has an option HEADER that you can add to ignore the first line as a header. That would achieve the same end without changing the file contents.
0
 
gregfthompsonAuthor Commented:
Thanks I tried that but it would not accept the tick in the box.
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
Pawan KumarDatabase ExpertCommented:
Can you post the command you are using to import the file. What kind of file you are importing.

I have updated the pdf file to export. Here you can use attached or you can ignore the first row of the pdf file you have attached.

Your column size is of 15 and in the headertext is way long that why we have this error.  

If you want to export the file with header only then use CSV Header option to ignore the first row.

Command -

COPY TableName (col1,col2...) FROM 'Pawan.csv' CSV HEADER;

Open in new window

UpdatedFile.pdf
0
 
gregfthompsonAuthor Commented:
I renamed the file extension to .csv and it imported (with the header ticked).

Thanks heaps.
0
 
Pawan KumarDatabase ExpertCommented:
Great to hear that it worked. !! Excellent.
0
 
gregfthompsonAuthor Commented:
Thank you. Great assistance.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now