I have a CSV file with 10 columns. After creating a PostgreSQL table with 4 columns, I want to copy some of 10 columns into the table.
the columns of my CSV table ar
If the number of imported rows is not important for you as result, you could also:
create two tables:
then create:
a trigger function, where you insert the desired columns into t2 instead and return NULL to prevent this row being inserted in t1
a trigger for t1 (BEFORE INSERT FOR EACH ROW) that calls this function.
Especially with larger csv files BEFORE INSERT triggers are also useful to filter out rows with certain properties beforehand, and you can do type conversions as well.