How to read data from a file?

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

How to read data from a file?

От:
<kynn@panix.com>
Дата:



Is there a way to initialize tables by reading the data from a regular
text file?

Thanks!

kynn

Re: How to read data from a file?

От:
<kynn@panix.com>
Дата:



Sorry, I meant to add this to the post quoted below.  I'm still trying
to find the mother-lode of useful PostgreSQL info for beginners.  I
looked at *4* PG books yesterday at the bookstore (Douglas & Douglas,
Momjian, Stinson, and the one published by O'Reilly).  *None* of them
answered the question quoted below (or if they did, I couldn't find
their answers using the index and the table of contents, which is just
as bad as not giving the answer at all), so I decided none was worth
buying.  (I had been warned about how poor PG books are, so this did
not come as a surprise.)



   Date: Sun, 8 Feb 2004 12:04:54 -0500 (EST)
   From: 


   Is there a way to initialize tables by reading the data from a regular
   text file?

   Thanks!

   kynn

   ---------------------------(end of broadcast)---------------------------
   TIP 4: Don't 'kill -9' the postmaster

Re: How to read data from a file?

От:
Reshat Sabiq <sabiq@purdue.edu>
Дата:
Вложения:


kynn@panix.com wrote:

>Is there a way to initialize tables by reading the data from a regular
>text file?
>
>Thanks!
>
>kynn
>
>---------------------------(end of broadcast)---------------------------
>TIP 4: Don't 'kill -9' the postmaster
>
>  
>
You could parse the file programmatically issuing insert/update 
commands. The best i know. :)

-- 
Sincerely,
Reshat.

-------------------------------------------------------------------------------------------
If you see my certificate with this message, you should be able to send me encrypted e-mail. 
Please consult your e-mail client for details if you would like to do that.

Re: How to read data from a file?

От:
Stephan Szabo <sszabo@megazone.bigpanda.com>
Дата:
On Sun, 8 Feb 2004 kynn@panix.com wrote:

> Is there a way to initialize tables by reading the data from a regular
> text file?

That depends on the definition of regular.  COPY (and \copy in psql)
allow importing of data from a delimited text file with one line per row.

Re: How to read data from a file?

От:
Bill Moseley <moseley@hank.org>
Дата:
On Sun, Feb 08, 2004 at 12:04:54PM -0500, kynn@panix.com wrote:
> 
> Is there a way to initialize tables by reading the data from a regular
> text file?

Define "regular".

How about:

  psql -d databse -f regular_text_file.sql


-- 
Bill Moseley
moseley@hank.org

Re: How to read data from a file?

От:
<kynn@panix.com>
Дата:


Thanks for all replies.  From them I was able to find the "\i"
command, which is what I was looking for.

kynn
FAQ