tags:

views:

35

answers:

1

Hi, Is is possible with PostgreSql without a trigger to not allow the update of a column, just the insertion is allowed. Thanks in advance for your answer.

+3  A: 

Completely untested but as Postgres SQL supports column level permissions it looks like it might be. http://www.postgresql.org/docs/current/static/sql-grant.html

Does this work?

GRANT SELECT (col1, col2), INSERT(col1, col2), UPDATE (col1) ON mytable TO userX;
Martin Smith
+1, but I would draw attention this this bit in the referred page: "A user may perform SELECT, INSERT, etc. on a column if he holds that privilege for either the specific column or its whole table. Granting the privilege at the table level and then revoking it for one column will not do what you might wish: the table-level grant is unaffected by a column-level operation." Your example covers this as it explicitly grants all the permissions, but I believe it may be easy to miss this point.
Matthew Wood