Let's say I have a table like this following:
CREATE TABLE table_a
(
cola text,
colb text,
colc text,
cold text,
cole text
)
Currently, I am loading the table with the following:
\copy table_a from PATH/TO/CSV/CSV_FILE.csv DELIMITER ',' CSV HEADER;
where CSV_FILE.csv also has all 5 columns: cola, colb, colc, cold, cole.
But what if I have CSV_FILE_2.csv that only has cola, colb, colc?
I want to be able to do something like:
\copy table_a from PATH/TO/CSV/CSV_FILE_2.csv DELIMITER ',' CSV HEADER;
to insert new rows from CSV_FILE_2.csv but leaves cold and cole null.
But when I try to do the above, I get a
ERROR: missing data for column "cold"
Is there an efficient way to use the copy command to just add the new rows from CSV_FILE_2.csv?
One workaround I thought of is insert the rows into a temporary table, insert the rows from the temporary table into table_a and then delete the temporary table, but that seems cumbersome.