[linux] Zalohovanie tabuliek v PostgreSQL zo shell-u
Marian Cavojsky
cavo+konf na cavo.sk
Pátek Květen 19 22:13:51 CEST 2006
On Fri, May 19, 2006 at 11:46:46AM +0200, "Ing. Dominik Tariška" wrote:
> Ahojte, mam zalohovaci skript, ktory spustam vo frontende "psql"
> standartne pomocou "\i zalohovaci_skript"
>
> Ten skript obsahuje toto:
>
> COPY tabulka1 TO '/var/lib/pgsql/zal/tabulka1';
>
> OTAZKA:
> Existuje moznost, ze by som tento skript spustal rovno
> zo shellu? T.j., ze by mi zalohu vytvaralo automaticky
> bez nutnosti spustat frontend "psql"?
man psql
-f filename
--file filename
Use the file filename as the source of commands instead of read-
ing commands interactively. After the file is processed, psql
terminates. This is in many ways equivalent to the internal com-
mand \i.
If filename is - (hyphen), then standard input is read.
Using this option is subtly different from writing psql < file-
name. In general, both will do what you expect, but using -f
enables some nice features such as error messages with line num-
bers. There is also a slight chance that using this option will
reduce the start-up overhead. On the other hand, the variant
using the shell's input redirection is (in theory) guaranteed to
yield exactly the same output that you would have gotten had you
entered everything by hand.
--
Marian Cavojsky
Další informace o konferenci linux