You can probably do:

1. login to your database: psql <database>

2. create a 'read only' role: CREATE ROLE readonly;

3. create a script to be able to implement read-only access to your db
table:

#!/bin/sh

tables=$(psql database -A -t -c "SELECT table_name FROM
information_schema.tables \
WHERE table_schema = 'public';")

for table in $tables
do
echo "Granting select to readonly on $table"
psql database -c "GRANT SELECT ON $table to readonly;"
done

4. Grant the readonly role:  GRANT readonly TO <user>;

Dont take my word for it. Take it  for a spin and see if you can improve it.
Good luck.


** Note: it helps to disregard negative responses and focus on extending
help to people and being objective in everything. Regards!





On Fri, Sep 11, 2009 at 3:37 PM, Francis Alvin Barretto <
[email protected]> wrote:

> Hi to all,
>
> Has anyone tried to create user restriction that will prevent creating
> tables for PostgreSql DB?
>
> Setup:
>
> Database: users
> Database owner: (user_owner) -- with all grant options and privileges.
>
> Requirement:
> Create another user to acess the DB (users) but the restriction should only
> allow the user to VIEW and SELECT on the tables.
> I already restrict the other requirements but I can't restrict the creation
> of table.
>
> I already tried REVOKE but wala ga work.
>
> Kinsa naka balo pa help pod. heheh
>
>
> Daghang salamat po.
>
> _________________________________________________
> Kagay-Anon Linux Users' Group (KLUG) Mailing List
> [email protected] (http://lists.linux.org.ph/mailman/listinfo/klug)
> Searchable Archives: http://archives.free.net.ph
>



-- 
Penguin, penguin, and more penguin.

Believe that within the brain is a brain, and within it another brain, and
so on and so forth.
_________________________________________________
Kagay-Anon Linux Users' Group (KLUG) Mailing List
[email protected] (http://lists.linux.org.ph/mailman/listinfo/klug)
Searchable Archives: http://archives.free.net.ph

Reply via email to