How to define variables in psql?

Поиск
Список
Период
Сортировка
От
Тема How to define variables in psql?
Дата
Msg-id 200601311217.k0VCHH712178@panix3.panix.com
обсуждение исходный текст
Ответы Re: How to define variables in psql?  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Список pgsql-novice


I know that one can store multiple psql commands and SQL statements in
a separate "script" file, and then "source" the script file, e.g. with
the \i command.

My question is, can I define variables in such a script file?
E.g. can I do something like the following unix-shell-like script?

-- beginning of script

DB=frobozz
DIR=/foo/bar/baz/quux

\c $frobozz
\i "$DIR/other_script.sql"
\i "$DIR/one_more_script.sql"
\i "$DIR/yas.sql"

\echo "done with $DB"

-- end of script

Thanks!

kj

В списке pgsql-novice по дате отправления:

Предыдущее
От: Clifton Zama
Дата:
Сообщение: copy
Следующее
От: Tomka Gergely
Дата:
Сообщение: lost archives, alpha data files