Mayur
Mayur

Reputation: 904

Postgresql Copy Syntax error

While running copy command on Postgresql I am getting SQL syntax error. Please find below command.

COPY analyte (id, name, normal_max, normal_min, unit_of_measure, version, category, data_type) FROM stdin;
16  Cholesterol - HDL (Good)    \N  40  mg/dl   0   3   9
\.

Error

ERROR:  syntax error at or near "16"
LINE 2: 16 Cholesterol - HDL (Good) \N 40 mg/dl 0 3 9
        ^
********** Error **********

ERROR: syntax error at or near "16"
SQL state: 42601
Character: 109

Upvotes: 2

Views: 2371

Answers (1)

Nick Barnes
Nick Barnes

Reputation: 21306

This script format - a COPY FROM stdin statement followed by a stream of data - is designed to be executed by psql. Most other tools (e.g. pgAdmin) won't know what to do with it.

I'm guessing this script came from pg_dump. If you want something which you can run without psql, you can use pg_dump --column-inserts to dump the table as a series of INSERT statements instead of a COPY.

Upvotes: 3

Related Questions