Обсуждение: \copy...

Поиск
Список
Период
Сортировка

\copy...

От
"Ed"
Дата:
Hi,

I have a file that look like this :

firstname|lastname|email@domain.com
firstname2|lastname2|email2@domain.com

and a table foo like :

firstname  varchar(30),
lastname   varchar(30),
email    varchar(50)

and I would like to do a :

copy tablename from '/home/ed/import.dat';

But then, everything goes in the first field... what does i'm doing
wrong?!?!

Frédéric Boucher
Ed@jetumele.com
Programmation, Support technique
Jetumele Communications inc.




Re: \copy...

От
Webb Sprague
Дата:
Finally--a question I think I can answer!

You need to specify what delimiters you use in your
.dat file;  the default for COPY is tab, but you can
change that to | with
  copy tablename from '/home/ed/import.dat'       delimiters '|'

Hope this works...(oops--I mean 'helps')

--- Ed <ed@jetumele.com> wrote:
> Hi,
> 
> I have a file that look like this :
> 
> firstname|lastname|email@domain.com
> firstname2|lastname2|email2@domain.com
> 
> and a table foo like :
> 
> firstname  varchar(30),
> lastname   varchar(30),
> email    varchar(50)
> 
> and I would like to do a :
> 
> copy tablename from '/home/ed/import.dat';
> 
> But then, everything goes in the first field... what
> does i'm doing
> wrong?!?!
> 
> Fr�d�ric Boucher
> Ed@jetumele.com
> Programmation, Support technique
> Jetumele Communications inc.
> 
> 


__________________________________________________
Do You Yahoo!?
Send instant messages with Yahoo! Messenger.
http://im.yahoo.com/


Re: \copy...

От
Christopher Sawtell
Дата:
On Fri, 16 Jun 2000, Ed wrote:
> Hi,
> 
> I have a file that look like this :
> 
> firstname|lastname|email@domain.com
> firstname2|lastname2|email2@domain.com
> 
> and a table foo like :
> 
> firstname  varchar(30),
> lastname   varchar(30),
> email    varchar(50)
> 
> and I would like to do a :
> 
> copy tablename from '/home/ed/import.dat';
> 
> But then, everything goes in the first field... what does i'm doing
> wrong?!?!

You are nearly there, use:-

copy tablename from '/home/ed/import.dat' using delimiters '|';

see sql-copy.htm in online doco.

-- 
Sincerely etc.,
NAME       Christopher Sawtell - iOpen Technologies Ltd.CELL PHONE 021 257 4451ICQ UIN    45863470EMAIL      chris @
iopen. co . nz,  csawtell @ xtra . co . nzWWW        http://www.iopen.co.nzCNOTES
ftp://ftp.funet.fi/pub/languages/C/tutorials/sawtell_C.tar.gz
-->> Please refrain from using HTML or WORD attachments in e-mails to me <<--