pradeep prajapati
pradeep prajapati

Reputation: 1

Is there any way to add additional serial type of id column while importing .csv file?

I have created a record table in postgresql.

Create table record:
(
recordid serial not null,
name varchar,
handedness varchar,
height numeric,
weight numeric,
average numeric,
hr numeric,
constraint pk_record primary key (recordid)
);

I fired one import command:

postgres=# copy record from 'C:\postgesql_demo_csv\baseball_data.csv' delimiter ',' csv header;

I got one issue.

ERROR: invalid input syntax for type integer: "Tom Brown" CONTEXT: COPY record, line 2, column recordid: "Tom Brown"

Can anyone help me .....?

Upvotes: 0

Views: 206

Answers (1)

jjanes
jjanes

Reputation: 44305

Either include all columns when you export the data, or if not then specify which columns of the table to copy the data into:

COPY record (name, handedness, height, weight, average, hr) from ....

Upvotes: 2

Related Questions