Skip to content

Instantly share code, notes, and snippets.

@nad2000
Last active December 22, 2015 06:29
Show Gist options
  • Save nad2000/6431169 to your computer and use it in GitHub Desktop.
Save nad2000/6431169 to your computer and use it in GitHub Desktop.
One-liner loops through a PostgreSQL DB list and executes on each of them a script
for db in $(psql -t -X -h 192.168.132.111 -U postgres -d probedb -c 'SELECT erfstore_id FROM erfstores') ; do psql -X -h 192.168.132.111 -U postgres -d $db -f /build/trunk/dock/tree/customer/endace/src/bin/dbmgr/scripts/erfstoredb/da_breakdown_summary_sql.sql ; done
# Or slightly more readable:
export PGHOST=fin7000-4
export PGDATABASE=probedb
export PGUSER=postgres
cd /ginkgo/trunk/ginkgo/tree/customer/endace/src/bin/dbmgr/scripts/erfstoredb/
for db in $(psql -t -X -c 'SELECT erfstore_id FROM erfstores') erfstoredb ; do psql -X -d $db -f da_breakdown_summary_sql.sql ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment