1

I want to populate one column in a postgres table from a CSV file.

I am trying this command in postgres 9.5.5 -

\copy myschema.items(name) from items.csv;

and get this error -

ERROR: null value in column "item_code" violates not-null constraint DETAIL: Failing row contains..... CONTEXT: COPY items, line 1: "some value"

Is postgres trying to populate all columns from the CSV and complains because it does not find ones with non null constraints in the CSV? How do I tell postgres not to worry about other columns and instead just copy the name column stated in the command into the table?

1 Answer 1

2

Two errors there:

  • Put the file name in single quotes.

  • Add (FORMAT 'csv')

Sign up to request clarification or add additional context in comments.

Comments

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.