Is there a possibility in PostgreSQL to do a sample from different PostgreSQL servers to one.

Example:

  1. Schools have servers with PostgreSQL.
  2. Another server with PostgreSQL is in the management of education.

Can a server in control make a selection on school servers?

  • What does sampling mean? - e_klimin
  • The management server should, using SQL queries, select certain fields on school servers, that is, collect information from schools for subsequent processing on their server. - Alex68

2 answers 2

The easiest way to use dblink.

    Well, then you can write a script that wakes up the server to pull the data and shift to another database. And so that the server itself is navryatli.

    # !/bin/sh###usr="root"hosts="localhost"for hst in $hosts ; doconnect=`mysql -h $hst -u $usr -p -e "use test ; select * from user where user='jonny'";`echo $connecthost2="localhost"qwerty=( $connect )echo ${qwerty[0]} ${qwerty[1]} ${qwerty[2]};mysql -h $host2 -u $usr -p -e "use test2; INSERT INTO test2.users (${qwerty[0]}, ${qwerty[1]}) VALUES ('${qwerty[2]}', '${qwerty[3]}');"done 
    • Is it possible to roughly sketch this script. - Alex68
    • can be done without entering a password - password = And naturally you need to check the connection and the example is written for mysql. Naturally, the syntax wakes up differently and I almost forgot I still have to think of the option so that the data is not inserted if they already have - e_klimin