From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | Sergio Gabriel Rodriguez <sgrodriguez(at)gmail(dot)com> |
Cc: | Lennin Caro <lennin(dot)caro(at)yahoo(dot)com>, pgsql-es-ayuda(at)postgresql(dot)org, Edwin Quijada <listas_quijada(at)hotmail(dot)com> |
Subject: | Re: GRANT SELECT para todas las tablas de una base |
Date: | 2009-09-17 03:59:15 |
Message-ID: | 20090917035915.GH13076@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Sergio Gabriel Rodriguez escribió:
> Gracias a todos por las respuestas, Lennin me llegó medio tarde tu consejo,
> pero lo voy a tener en cuenta para la próxima, dejo mi precaria función para
> el que la necesite o el que quiera corregirla:
>
> CREATE OR REPLACE FUNCTION "public"."dar_permisos" (esquema varchar, usuario
> varchar, privilegio varchar) RETURNS boolean AS
> $BODY$
> DECLARE
> registro record;
> BEGIN
> FOR registro IN SELECT * FROM pg_tables WHERE schemaname= esquema LOOP
> EXECUTE 'GRANT ' || privilegio || ' ON ' || esquema || '.' ||
> registro.tablename || ' TO ' || usuario;
> END LOOP;
> RETURN TRUE;
> END;
> $body$
> LANGUAGE 'plpgsql' VOLATILE
Prueba esto:
create schema "mi esquema" create table "mi tabla" ();
select dar_permisos("mi esquema", current_user, 'all');
--
Alvaro Herrera http://www.flickr.com/photos/alvherre/
"No hay cielo posible sin hundir nuestras raíces
en la profundidad de la tierra" (Malucha Pinto)
From | Date | Subject | |
---|---|---|---|
Next Message | Sergio Gabriel Rodriguez | 2009-09-17 10:49:58 | Re: GRANT SELECT para todas las tablas de una base |
Previous Message | Jorge Toro | 2009-09-16 23:08:53 | Nombre Campos en PostgreSQL |