Thread: copy

copy

From
Clifton Zama
Date:
Please help.

 Please correct :  copy tmp_table from supplier_merch.dat with delimiter '|';

ERROR:  parser: parse error at or near "table" at character 6.

COPY table [ ( column [, ...] ) ]
    FROM { 'filename' | stdin }
    [ [ WITH ]
          [ BINARY ]
          [ OIDS ]
          [ DELIMITER [ AS ] 'delimiter' ]
          [ NULL [ AS ] 'null string' ] ]
COPY table [ ( column [, ...] ) ]
    TO { 'filename' | stdout }
    [ [ WITH ]
          [ BINARY ]
          [ OIDS ]
          [ DELIMITER [ AS ] 'delimiter' ]
          [ NULL [ AS ] 'null string' ] ]

.  

I assume table stands for table name, and all the stuff in [] is optional.

I tried working this out at home, which is when I first learnt of it and
couldn't get it to work. I had to use some psql command equivalent which I
cannot remember correctly anymore, and cannot find in
"/usr/local/pgsql/bin/".

I don't know if it only exist in 8.0.

Re: copy

From
Tom Lane
Date:
Clifton Zama <csz@jhb.ucs.co.za> writes:
> Please correct : copy tmp_table from supplier_merch.dat with delimiter '|';

> ERROR: parser: parse error at or near "table" at character 6.

Are you sure you transcribed the command accurately?  The only thing I
see wrong with it is that you didn't quote the file name, but the error
message is not pointing at that.  I can duplicate the error message by
inserting the word "table", eg

regression=# copy table foo from '/tmp/myfile';
ERROR:  parser: parse error at or near "table" at character 6
regression=#

BTW, syntax error messages have not been spelled this way since Postgres
7.3, so the server you are talking to is older than you think.  It's
certainly not PG 8.0.

            regards, tom lane

Re: copy

From
Christoph Della Valle
Date:
hi

this is an example that worked for me
copy import  from '/data/pp.csv'    with delimiter as ',' csv quote '"';

i gues that results in:
copy tmp_table from 'supplier_merch.dat' with delimiter as '|';

maybe as can be omitted, i didn't check this.

Clifton Zama schrieb:
> Please help.
>
>  Please correct :  copy tmp_table from supplier_merch.dat with delimiter '|';
>
> ERROR:  parser: parse error at or near "table" at character 6.
>
> COPY table [ ( column [, ...] ) ]
>     FROM { 'filename' | stdin }
>     [ [ WITH ]
>           [ BINARY ]
>           [ OIDS ]
>           [ DELIMITER [ AS ] 'delimiter' ]
>           [ NULL [ AS ] 'null string' ] ]
> COPY table [ ( column [, ...] ) ]
>     TO { 'filename' | stdout }
>     [ [ WITH ]
>           [ BINARY ]
>           [ OIDS ]
>           [ DELIMITER [ AS ] 'delimiter' ]
>           [ NULL [ AS ] 'null string' ] ]
>
> .
>
> I assume table stands for table name, and all the stuff in [] is optional.
>
> I tried working this out at home, which is when I first learnt of it and
> couldn't get it to work. I had to use some psql command equivalent which I
> cannot remember correctly anymore, and cannot find in
> "/usr/local/pgsql/bin/".
>
> I don't know if it only exist in 8.0.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>
>