Latest 100 public snipts »
Fotinakis's
snipts » permissions
showing 1-2 of 2 snipts for permissions
-
∞ Drop all tables, constraints, and sequences within an Oracle schema
BEGIN FOR c IN (SELECT table_name FROM user_tables) LOOP EXECUTE IMMEDIATE ('DROP TABLE ' || c.table_name || ' CASCADE CONSTRAINTS'); END LOOP; FOR s IN (SELECT sequence_name FROM user_sequences) LOOP EXECUTE IMMEDIATE ('DROP SEQUENCE ' || s.sequence_name); END LOOP; END;
-
∞ Grant all permissions on PostgreSQL DB
ER="$2" PSQL="psql -q -n -A -t" SCHEMES="'public'" if [ -z "$1" ]; then echo "Something like: ./grant mydatabase myuser | psql mydatabase" exit fi if [ -z "$2" ]; then USER="$1" fi echo "-- Granting rights on $DB to $USER ($SCHEMES)" # tables Q="select 'grant all on '||schemaname||'.'||tablename||' to \\\"$USER\\\";' from pg_tables where schemaname in ($SCHEMES);" $PSQL -c "$Q" "$DB"; # views Q="select 'grant all on '||schemaname||'.'||viewname||' to \\\"$USER\\\";' from pg_views where schemaname in ($SCHEMES);" $PSQL -c "$Q" "$DB"; # sequences Q="select 'grant all on function '||n.nspname||'.'||p.proname||'('||oidvectortypes(p.proargtypes)||') to \\\"$USER\\\";' from pg_proc p, pg_namespace n where n.oid = p.pronamespace and n.nspname in ($SCHEMES);" $PSQL -c "$Q" "$DB"; # functions Q="select 'grant all on '||n.nspname||'.'||c.relname||' to \\\"$USER\\\";' from pg_class c, pg_namespace n where n.oid = c.relnamespace and c.relkind IN ('S') and n.nspname in ($SCHEMES);" $PSQL -c "$Q" "$DB";


