Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
    
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. – a_horse_with_no_name Mar 15 at 15:55

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
share|improve this answer
    
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 – Multi Task Mar 15 at 14:49
1  
@MultiTask: are you using psql or some other SQL client? – a_horse_with_no_name Mar 15 at 14:53
    
@a_horse_with_no_name i am using navicat for postgres – Multi Task Mar 15 at 15:07
    
@MultiTask: I guess Navicat doesn't supprt copy ... from stdin – a_horse_with_no_name Mar 15 at 15:32
    
@a_horse_with_no_name i tried it ffrom pg_admin same error result too – Multi Task Mar 15 at 15:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.