PG COPY error: 'invalid input syntax for integer' when importing quoted CSV file without any integers

Try specifying the columns . . . without the primary key:

COPY customer_ (first_name_ text, last_name_ text, phone_ text, email_ text)
FROM '/home/parallels/Downloads/customer_.csv'
CSV 
HEADER
;

Without the column list, it is looking for a value for id_.

The import data file’s first row of column names are not used for mapping to the table columns. The HEADER flag merely tells Postgres to skip over that first line, as documented:

HEADER

Specifies that… on input, the first line is ignored. …


COPY table_name FROM 'C:\path\file.csv' DELIMITERS ',' CSV header;

Tags:

Csv

Postgresql