mass grant on sequences script

From: Michael Behan <michael(at)ezyield(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: mass grant on sequences script
Date: 2005-07-25 18:44:12
Message-ID: 42E532FC.6060303@ezyield.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

Browse pgsql-general by date

  From Date Subject
Next Message Chris Browne 2005-07-25 18:54:58 Re: Wishlist?
Previous Message Andreas 2005-07-25 18:39:05 Re: Bad locking with MS-Access