This is something I don't understand, can somebody explain?
I create a table
CREATE TABLE cali (id SERIAL PRIMARY KEY,
ALK_from char,
ALK_to char,
AND_from char,
AND_to char);
Then I simply try to insert some data from a csv file like so
\COPY cali FROM '/home/.../data/output/id_cali.csv' (FORMAT CSV);
Which gives me this Error:
ERROR: value "4372840000" is out of range for type integer
CONTEXT: COPY cali, line 1, column id: "4372840000"
I know that 4372840000 results in an integer overflow. That is why I'm trying to insert the values as chars in the first place.
But my understanding is that id SERIAL PRIMARY KEY
is some sort of auto increment why is the value 4372840000 used for the column id
?
The file looks like this
4372840012,4372840013,13,14,
4372840014,4372840014,15,15,
Best Answer
The table should be
And do
So that it knows to not insert into the id serial column. The serial type is not a true type. From the manual: