Use Case:
I've copied specified columns from table to csv file using COPY TO command. CSV looks like this:
id,name
1,For data test
Later I've tried to import data from this csv file to table using COPY FROM command and I've received an error, because csv file contains not the entire table, but specific columns only. Error is:
null value in column "[column_name]" violates not-null constraint
DETAIL: Failing row contains (1, null, For data test, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null).
CONTEXT: COPY [table_name], line 2: "1,For data test"
Question:
Is it possible to insert only specified columns from file without touching other columns, i.e. leaving other columns to their current values? I haven't found any information about this in Postgres documentation.