The real release 0.46 :-)
[awl.git] / dba / grant-on-all-tables.sh
blob52d1c7181a1dd68b90c0482ff267f968990e6321
1 #!/bin/sh
3 DATABASE="$1"
4 USER="$2"
5 PERMISSION="${3:-SELECT}"
7 if [ "$USER" = "" ] ; then
8 echo "Usage: $0 <database> <username> [permissions]"
9 exit
12 TABLES="`psql \"$DATABASE\" -qt -c \"select relname from pg_class where relowner > 50 AND relkind in( 'r', 'S');\"`"
14 for T in ${TABLES} ; do
15 psql "$DATABASE" -c "grant ${PERMISSION} on ${T} to ${USER};"
16 done