Thread: copy command

copy command

From
"Jose' Soares Da Silva"
Date:
Hi, all

PostgreSQL has two COPY commands to import/export data;

     copy [binary] <class_name> [with oids]
        {to|from} {<filename>|stdin|stdout} [using delimiters <delim>];
and...

     \copy table {from | to} <fname>

both of them work in a different way;
     In the first one you have to specify 'filename' surrounded by ''
     and if you don't specify an absolute pathname PostgreSQL uses
     $PGDATA/base/<databasename>/<filename>

     In the last one you have to specify 'filename' without by ''
     and if you don't specify an absolute pathname PostgreSQL uses
     current working directory.
     and last...  if you don't specify any parameter it show me this:

java=> \copy
connecting to new database: opy
PQexec() -- There is no connection to the backend.

Could not connect to new database. exiting

My question is:

       Why do we have two commands to doing the same operation ?
       Why are they different ?

                                                            Thanks, Jose'