From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Mark <sendmailtomark(at)yahoo(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: question: how to preload data and excute table creation scripts |
Date: | 2004-12-11 19:15:25 |
Message-ID: | 20041211191525.GA40830@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Dec 08, 2004 at 08:58:49AM -0800, Mark wrote:
> I guess is simple, but cannot find out how to run scripts in psql(
> Linux)
Create a file with the SQL statements you'd like to run. There are
several ways to get psql to read the file:
Redirection:
psql < foo.sql
Command-line option:
psql -f foo.sql
Include into the current psql session:
psql
\i foo.sql
See the psql documentation for more info.
> What I would like to do is following:
>
> 1. Create a table structure from scripts ?
> 2. Preload data to remote Linux box (IP added to conf file)
See above. For bulk loads, consider using COPY instead of INSERT
since COPY is faster. You can find additional advice in the
"Populating a Database" section of the "Performance Tips" chapter
in the PostgreSQL documentation.
Consider using transactions in your script -- that way if you make
a mistake and psql raises an error, you're not left with the work
half done. See also the ON_ERROR_STOP variable in the psql
documentation.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
From | Date | Subject | |
---|---|---|---|
Next Message | David Fetter | 2004-12-11 19:22:52 | Re: What's faster |
Previous Message | Bruno Wolff III | 2004-12-11 19:06:47 | Re: table with sort_key without gaps |