Thread: Problems with copy

Problems with copy

From
Fred Soustra
Date:
Hi, I am trying to import data from a cvs, file using copy the only problem i
have is that the first field of my table is automatically generated.
So I wanted to know if there is a way to select which columns copy should use.
the command i am running is the following

copy client from
'/path/client.del' using
delimiters ',';

Can i get it to do something like
import from file foo insert into (col2,col3 ...) ?

Thanx

Fred

Re: Problems with copy

From
"Patrick Hatcher"
Date:
I think this is correct:

copy client(field1,field2,fieldn) from
'/path/client.del' using
delimiters ',';

HTH
Patrick Hatcher






     
                    Fred Soustra
     
                    <fredboard@sus.mcgill.c       To:     pgsql-novice@postgresql.org
     
                    a>                            cc:
     
                    Sent by:                      Subject:     [NOVICE] Problems with copy
     
                    pgsql-novice-owner@post
     
                    gresql.org
     

     

     
                    03/14/2003 12:40 AM
     

     




Hi, I am trying to import data from a cvs, file using copy the only problem
i
have is that the first field of my table is automatically generated.
So I wanted to know if there is a way to select which columns copy should
use.
the command i am running is the following

copy client from
'/path/client.del' using
delimiters ',';

Can i get it to do something like
import from file foo insert into (col2,col3 ...) ?

Thanx

Fred

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly




Re: Problems with copy

From
"Duncan Adams (DNS)"
Date:
I guess u could create a temp table, copy the info to that and then use sql to extract the information that u what.

-----Original Message-----
From: Fred Soustra [mailto:fredboard@sus.mcgill.ca]
Sent: Friday, March 14, 2003 10:41 AM
To: pgsql-novice@postgresql.org
Subject: [NOVICE] Problems with copy


Hi, I am trying to import data from a cvs, file using copy the only problem i
have is that the first field of my table is automatically generated.
So I wanted to know if there is a way to select which columns copy should use.
the command i am running is the following

copy client from
'/path/client.del' using
delimiters ',';

Can i get it to do something like
import from file foo insert into (col2,col3 ...) ?

Thanx

Fred

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

User check

From
Ben Clewett
Date:
PostgreSQL,

I want to definitively check whether a user is logged in.  I see there
is a table pg_stat_activity:

ben=# SELECT DISTINCT datname FROM ps_stat_activity

Are these better ways, or is this about right?

If right, does this table ever become corrupt, eg a TCP connection
failure without termination?



Whilst I am writing, something which has been bothering me.  Does any
person know the quickest method for checking the existence of a record,
selected by Primary Key?

ben=# SELECT pk FROM table WHERE pk = value

I guess this way might be performance impared as it has to create the
output table with the extracted value.

ben=# SELECT COUNT(*) FROM table WHERE pk = value

I guess this might be faster, since it's only counting results without
creating a table.  Or it might be slower if the table has already been
created, and then counted...



Ever a Novice, Ben.