\ copy(select * from remote_table)to'/local/file.txt' ...次に、\ copy local_tablefrom'/local/file.txt'を使用してファイルをローカルデータベースにロードします。psqlスクリプトから\copyコマンドを実行しました。
これが私のスクリプトです
export PGUSER = remoteuser export PGPASSWORD = remoteepwd
/opt/PostgreSQL/8.3/bin/psql -h xx.xx.xx -p 5432 -d remotedb -c "\ COPY(select * from remote_table where date(reccreationtim e)= date((current_date --interval '4 day' )))TO'/local/copied_from_remote.txt' D ELIMITER'|' "
export PGUSER = localuser export PGPASSWORD = localpwd
/opt/PostgreSQL/8.3/bin/psql -h xx.xx.xx.xx -p 5432 -d localdb -c "\ COPY local_table FROM'/local/copied_from_remote.txt' DELIMITER'|'"