dbTalk Databases Forums  

How to initialize from flat files?

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss How to initialize from flat files? in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
kynn@panix.com
 
Posts: n/a

Default How to initialize from flat files? - 03-01-2004 , 08:27 PM










[ I posted this once already, but for some reason it never showed...]


What's the simplest way (through psql?) to initialize PostgreSQL
tables from data stored in flat files? (In this case the data is
stored in several files consisting of newline-delimited records of
tab-delimited fields.)

Thanks!

kj


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: How to initialize from flat files? - 03-01-2004 , 10:49 PM






<kynn (AT) panix (DOT) com> writes:
Quote:
What's the simplest way (through psql?) to initialize PostgreSQL
tables from data stored in flat files? (In this case the data is
stored in several files consisting of newline-delimited records of
tab-delimited fields.)
The COPY command should do what you want. If the data contains any
tabs, newlines, or backslashes, you'll need to do a bit of preprocessing
to quote those characters; else you're good to go.

BTW, there is a difference between the SQL-level COPY command and psql's
\copy command. With COPY the data file is read directly by the backend,
with \copy the file is read by psql and sent to the backend. The COPY
method is faster when it works, but it doesn't work across machines or
when the data file is protected against access by the postgres user.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings



Reply With Quote
  #3  
Old   
kynn@panix.com
 
Posts: n/a

Default Re: How to initialize from flat files? - 03-02-2004 , 04:41 AM




tom lane writes:
Quote:
kynn (AT) panix (DOT) com> writes:
What's the simplest way (through psql?) to initialize PostgreSQL
tables from data stored in flat files? (In this case the data is
stored in several files consisting of newline-delimited records of
tab-delimited fields.)

The COPY command should do what you want. If the data contains any
tabs, newlines, or backslashes, you'll need to do a bit of preprocessing
to quote those characters; else you're good to go.

BTW, there is a difference between the SQL-level COPY command and psql's
\copy command. With COPY the data file is read directly by the backend,
with \copy the file is read by psql and sent to the backend. The COPY
method is faster when it works, but it doesn't work across machines or
when the data file is protected against access by the postgres user.
Thanks!

kj

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



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.