What the error means
PostgreSQL validates every value against its column type before storing it. invalid input syntax for type bigint: "1,250" means a value arrived for a bigint column that cannot be read as a 64-bit integer, and the message quotes the offending text. It appears during INSERT, COPY, and UPDATE, and it stops the whole statement — one bad row fails the batch.
In the example, three different values would each trigger it depending on how the columns were typed: 02134 if zip is numeric (it parses, but the leading zero is lost, which is a different bug), 1,250 because of the thousands separator, and the empty amount on row two, because an empty string is not a number.
Why it happens
- Codes typed as numbers. Postal codes, phone numbers, account numbers, and SKUs look numeric but are identifiers. Storing them as bigint drops leading zeros and rejects any that contain a letter or a dash.
- Formatted numbers: thousands separators (
1,250), currency symbols ($40), units (12kg), or a trailing percent sign. - Empty cells. A CSV cell with nothing in it is an empty string, and
''is not a valid bigint. It needs to becomeNULL. - Decimal values in an integer column:
18.25fails for bigint; it needsnumericordouble precision. - Whitespace or a BOM attached to the first value of the file.
How to fix it
- Paste the CSV into the converter above. It infers a type per column from every row, not just the first, and it deliberately keeps leading-zero values as text rather than guessing they are numbers.
- Review the generated
CREATE TABLE. If a column that should be numeric came out as text, one of its values is not a clean number — find it and fix the data, or accept text if it is really a code. - Check that empty cells became
NULLin the INSERT statements, not''. - For real quantities with separators, clean the source (
1250, not1,250) or import as text and cast withreplace(col, ',', '')::bigintafterwards.
For the example, the sound schema is:
CREATE TABLE import (
id bigint,
zip text,
amount bigint
);
with amount imported as 1250 and NULL.
If it still fails
COPYreports the line number of the failing row;INSERT ... VALUESwith many rows does not, so import in smaller batches to locate it.- The MySQL equivalent is
Incorrect integer valueor, in strict mode,Data truncated for column; SQL Server saysConversion failed when converting the varchar value. Same data, same fix. - Nothing pasted into the converter leaves your browser, so a customer export can be checked here without redaction.