I have the following table :
persons(id,id_tech,name,nationality,id_list)
And a CSV file containing the datas for the column id_tech,name and nationality.
Importing the data like so is working :
\copy persons(id_tech,name,nationality) FROM '/path/to/file.csv' DELIMITER ',' CSV
The id_list value is not in the CSV file because the file has to be imported on many servers where the value of this id can be different.
Is there a way to import the CSV file while providing an additional value for a specific column ? I can't find anything relevant on the documentation.
Edit--
Note that all my command will be perform with pqxx in C++ (multi plateform). I'm trying to avoid editing the file because of it's size.
Edit 2 --
I'm considering the follwing approch :
- Create a temp table with a correct default value for the field i need
- Import File into this temp table
- Copy tmp to fina l table
- Remove temp table
But i'm unsure of the performance. Biggest import can be close to a 500K lines.
Thanks