[Assorted-commits] SF.net SVN: assorted:[1839] shell-tools/trunk/src/bash-commons/common.bash
Brought to you by:
yangzhang
From: <yan...@us...> - 2012-09-08 01:13:17
|
Revision: 1839 http://assorted.svn.sourceforge.net/assorted/?rev=1839&view=rev Author: yangzhang Date: 2012-09-08 01:13:11 +0000 (Sat, 08 Sep 2012) Log Message: ----------- Add pg-for-all Modified Paths: -------------- shell-tools/trunk/src/bash-commons/common.bash Modified: shell-tools/trunk/src/bash-commons/common.bash =================================================================== --- shell-tools/trunk/src/bash-commons/common.bash 2012-08-15 17:22:44 UTC (rev 1838) +++ shell-tools/trunk/src/bash-commons/common.bash 2012-09-08 01:13:11 UTC (rev 1839) @@ -672,6 +672,28 @@ psql } +# Outputs a query that selects all schema.table names. +# +# Usage example: +# pg-for-all tables | +# sudo -u postgres psql pod | +# xargs -I_ echo 'alter table _ owner to joe;' | +# sudo -u postgres psql pod +pg-for-all() { + local type=$1 where=${2:-true} + case $type in + tables ) + echo " + select schemaname || '.' || tablename + from pg_tables + where $where + and schemaname != 'pg_catalog' + and schemaname != 'information_schema' + order by 1; + " ;; + esac +} + # Resume SCP; from <http://joen.dk/wordpress/?p=34> scp-resume() { rsync --partial --progress "$@" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |