2017-05-30 1 views
0

PostgreSQLデータベースのSQLスクリプトから次のコマンドライン文を実行する方法はありますか?SQLスクリプトから.exeを呼び出す

raster2pgsql -s 4326 -I -C -M D:\postgresql\data\input.tif -F -t 100x100 public.demelevation > output.sql 

私は、MicrosoftのSQL Serverのhereのための有望なものを見つけましたが、私は、PostgreSQLのための類似した何かを見つけることができませんでした。

+0

ある[ 'plsh'言語ハンドラ](https://github.com/petere/plsh)UNIXベース用OS-ES、しかし、私はわかりませんそれが窓でうまくいくのであれば。とにかく、理論的にはシステムコマンド(例えば ' pltclu'、['plperlu'](https://www.postgresql.org/docs/current/static/plperl-trusted.html)および[' plpythonu'](https://www.postgresql.org/docs/ current/static/plpython.html)) – pozs

+0

.exeが 'psql'が実行されているのと同じコンピュータにある場合は、SQL文の中で' \! 'を使って外部プログラムを実行することができます。 –

答えて

1

you can useCOPYです。しかし、psqlからprogrammを呼び出すことをお勧めします。また、スーパーユーザー権限が必要です。

例:

t=# create table c (t text); 
t=# copy (select 1) to program $$echo "whatever" -v >/tmp/12$$; 
COPY 1 
t=# copy c from program 'echo "whatever" -v'; 
COPY 1 
t=# select * from c; 
     t 
------------- 
whatever -v 
(1 row) 

Time: 0.380 ms 
t=# !\ cat /tmp/12 
Invalid command \. Try \? for help. 
t-# \! cat /tmp/12 
whatever -v 
関連する問題