I just started using Postgres and I'm trying to create a sample db to understand its functions, looking around, I found some scripts in pgfoundry.org.
I understand the commands, since I previously used both Oracle and MS-SQL, but all the scripts I'm running return errors when they reach the "COPY FROM" instruction. More precisely, the error is thrown at the first element that should be inserted in the given table.
I've tried running the scripts both as queries and as pgScripts, but in both ways I'm getting an error at the first row after the COPY FROM.
I'm using pgAdminIII and I used StackBuilder to install PostgreSQL 9.2.4.1 as a DB Driver. May I be missing some basic configuration that's preventing me from running this command, or I just did not understand they way it works?
EDIT:
The error is:
ERROR: syntax error at or near "7"
LINE 5600: 7 4 13 37 2012-03-10 16:41:43.797787 2012-03-10 16:41:43.797...
^
********** Error **********
ERROR: syntax error at or near "7"
SQL status: 42601
Char: 140891`
where the text is:
COPY action_abilitations (id, group_action_id, partecipation_role_id, group_id, created_at, updated_at) FROM stdin;
7 4 13 37 2012-03-10 16:41:43.797787 2012-03-10 16:41:43.797787`
Best Answer
pgScript is a local script extension of pgAdmin, which you most probably do not want here.
pgAdmin is a GUI, not a console application - there is no
stdin
you could easily use. If you needstdin
to stream your content, use psql, which is a console application - with the\copy
meta-command of psql.If you have a file (which you obviously do), just use SQL
COPY
from pgAdmin:The file needs to be readable to the
postgres
system user.More info in this closely related request to the pgAdmin support list.