NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Granting permissions on all objects (Score:1)
That said, these little functions might help you out. call "select grant_all('insert', 'nmueller')" to grant nmueller insert acess on all tables in your database.
create or replace function grant_all (text, text) returns integer as '
declare
tables record;
perms alias for $1;
user alias for $2;
begin
for tables in select ''"'' || nspname || ''"."'' || relname || ''"'' as table fr
om pg_class, pg_namespace where relname not like ''pg_%'' and relkind in (''r'',
''v'', ''S'') and nspname != ''information_schema'' and relnamespace = pg_names
pace.oid loop
execute ''grant '' || perms || '' on '' || tables.table || '' to '' || user;
end loop;
return 1;
end;
' language 'plpgsql';
create or replace function revoke_all (text) returns integer as '
declare
tables record;
user alias for $1;
begin
for tables in select nspname || ''.'' || relname as table from pg_class, pg_name
space where relname not like ''pg_%'' and relkind in (''r'', ''v'', ''S'') and r
elnamespace = pg_namespace.oid loop
execute ''revoke all on '' || tables.table || '' from '' || user;
end loop;
return 1;
end;
' language 'plpgsql';
--Nate
PS: Try being more positive -- it's good for your health.
Reply to This