Thursday, July 30, 2009

create read-only user in postgres

grant select,insert,update,delete only allows you to grant privileges to an indiviual table.

the following generate the grant commands to all tables in a database for you to copy & paste:
select 'grant select on ' || relname || ' to username;' from pg_class join pg_namespace on pg_namespace.oid=pg_class.relnamespace where nspname ='public' and relkind in ('r','v');

No comments: