Re: question: how to preload data and excute table creation scripts - Mailing list pgsql-general

From Michael Fuhr
Subject Re: question: how to preload data and excute table creation scripts
Date
Msg-id 20041211191525.GA40830@winnie.fuhr.org
Whole thread Raw
In response to question: how to preload data and excute table creation scripts  (Mark <sendmailtomark@yahoo.com>)
List 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/

pgsql-general by date:

Previous
From: Timothy Perrigo
Date:
Subject: Re: Regarding Postgres installation and administration on linux suse 9.0
Next
From: Bruno Wolff III
Date:
Subject: Re: Select after insert to the unique column