Hello, all!
Attached is a simple bash script to do a mass grant on all sequences in
a DB. This is meant to complement grantall.sh by f3ew, Elein and
RevTresh. I realize there are probably more efficient ways of doing this
with psql shortcuts, but I am no guru with the psql command line.
However, this has been working well for me and I thought I'd share it
with the rest of the Postgres community. Enjoy!
#!/bin/sh
#
# Does a mass grant on all sequences in a database
#
# Usage:
# ./grantallseq.sh ALL username database
#----------------------------------------
TMPFILE=/tmp/grantallseq`date +%Y%d%m%H%M%S%M`.txt
psql -c "\d" $3 | grep "| sequence |" | cut --bytes=11-59 > $TMPFILE
for i in `cat $TMPFILE` ; do echo "> GRANT $1 ON $i TO $2"; psql $3 -c
"GRANT $1 ON $i TO $2" ; done
rm -f $TMPFILE
unset TMPFILE
--
Michael Behan
Lead Project Manager
EZ Yield.com, Inc.
481 N. State Road 434 Suite 117
Altamonte Springs, FL 32714
v 407.629.0900 ext 29
IMPORTANT NOTICE:
The information contained in this e-mail message
may be privileged and confidential. If you are
not the intended recipient, any further
disclosure or use, distribution, or copying of
this message or any attachment is strictly
prohibited. If you have received this e-mail
message in error, please delete the e-mail, and
either e-mail the sender at the above address or
notify us at our telephone number (407) 629-0900.
Internet e-mail may be subject to delays,
non-delivery and unauthorized alterations,
therefore opinions, conclusions and other
information expressed are not binding upon
EZ Yield.com unless otherwise notified
independently of this message.
---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend