Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSql : Disallow the update of a column : how?

Tags:

postgresql

Is is possible with PostgreSql without a trigger to not allow the update of a column, just the insertion is allowed.

like image 246
mada Avatar asked Jul 19 '10 13:07

mada


People also ask

How can one restrict access to certain columns of a database table Postgres?

You must revoke SELECT access on the table and provide column access with only columns you want the user to access. Column access to particular columns will not work if users already have SELECT access on the whole table.

How do I change the properties of a column in PostgreSQL?

First, specify the name of the table to which the column you want to change belongs in the ALTER TABLE clause. Second, give the name of column whose data type will be changed in the ALTER COLUMN clause. Third, provide the new data type for the column after the TYPE keyword.

How do I undo an update query in PostgreSQL?

PostgreSQL ROLLBACK command is used to undo the changes done in transactions.

How do I change the constraint of a column in PostgreSQL?

For modifying the column's default value, we can use the ALTER TABLE ALTER COLUMN SET DEFAULT or DROP DEFAULT command. ALTER TABLE table_name ALTER COLUMN column_name [SET DEFAULT value | DROP DEFAULT]; We will use ALTER TABLE ADD CONSTRAINT command for adding a constraint.


1 Answers

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;
like image 101
Martin Smith Avatar answered Oct 03 '22 23:10

Martin Smith