2

I have a csv file with headers. 4 columns.

I need the first 3 columns in table A, and the last column in table B.

Table A has an ID, which should be set by default (not from columns).

Here's what I've tried:

COPY a FROM '/home/bijan/Downloads/test_events.csv' WITH CSV HEADERS

The (first) problem I run into with this is it's not setting the default value for the ID of the table 'A', instead it thinks the first column of the CSV is the first column in the table (which should be default).

Thank you for your time. :)

1 Answer 1

5

You're probably best off loading it into a temporary table and then sending that one to the two different other tables - you cannot load into two tables in one operation.

You can, however, control which columns the data goes into (thus skipping the id column), with something like

COPY a(col2,col3,col4) FROM '/home/bijan/Downloads/test_events.csv' WITH CSV HEADERS

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.