Reputation: 8360
I'm trying to import a big CSV file like below:
psql -U postgres -d opendata -c " \
COPY foos \
FROM '/tmp/foos.csv' \
DELIMITER '|' \
CSV \
HEADER"
But it doesn't contain the first id
column of my table.
How should I better deal with it ?
Is there an option to autofill this column ? Should add add the id at the beginning of each line of my file ?
Upvotes: 0
Views: 1171
Reputation: 46239
We can try to declare clear columns name without id
primary key by COPY
command
For COPY FROM, each field in the file is inserted, in order, into the specified column. Table columns not specified in the COPY FROM column list will receive their default values.
COPY foos ( column_name [, ...])
Upvotes: 1