Re: question: how to preload data and excute table creation scripts

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: question: how to preload data and excute table creation scripts
Дата
Msg-id 20041211191525.GA40830@winnie.fuhr.org
обсуждение исходный текст
Ответ на question: how to preload data and excute table creation scripts  (Mark <sendmailtomark@yahoo.com>)
Список 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 по дате отправления:

Предыдущее
От: Timothy Perrigo
Дата:
Сообщение: Re: Regarding Postgres installation and administration on linux suse 9.0
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: Select after insert to the unique column