2

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
0

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Nick, got you on Pgadmin it is not working while on sql shell able to add data, Thanks a lot :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.