0

I am trying to dump this data into Postgres:

COPY address_types (game_id, device_type) FROM stdin;
1   Ps3
2   Xbox
3   Other
\.   

But I always get this error:

[Err] ERROR:  syntax error at or near "1"
LINE 2: 1 Ps3
        ^

Any ideas what might be wrong?

1
  • I don't think you can have multiple spaces as the delimiter. How did you create this statement? Is that taken directly from a SQL script created by pg_dump? If yes, maybe the tab character got lost somehow in the copy & paste process. Commented Mar 15, 2016 at 15:55

1 Answer 1

1

According to the PostgreSQL documentation on the COPY command the values must be separated by the delimiter character which is by default a tab (\t). If spaces are used instead I get a similar error on PostgreSQL 9.5. BTW: Which version do you use?

Alternatively you might try to alter the delimiter character:

nd1=> COPY address_types (game_id, device_type) FROM stdin with delimiter '#';
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
>> 1#Ps3
>> 2#Xbox
>> 3#Other
>> \.
COPY 3
10
  • I am using postgres 9.2, I still get the same error, using your example [Err] ERROR: syntax error at or near "1" LINE 2: 1#Ps3 Commented Mar 15, 2016 at 14:49
  • 1
    @MultiTask: are you using psql or some other SQL client? Commented Mar 15, 2016 at 14:53
  • @a_horse_with_no_name i am using navicat for postgres Commented Mar 15, 2016 at 15:07
  • @MultiTask: I guess Navicat doesn't supprt copy ... from stdin Commented Mar 15, 2016 at 15:32
  • @a_horse_with_no_name i tried it ffrom pg_admin same error result too Commented Mar 15, 2016 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.