Postgresql – Lock All Column Changes, Except One Column On Trigger

postgresqltrigger

I want to ask how to lock all updates except one column with Trigger, is it possible to achieve this?

For example my table structure is:

--------------------------
id | name | age | point 
--------------------------
1  | Test | 10  | 10
2  | Test | 12  | 10

So what I want is to lock all changes update columns, except the point column.

Thank you in advance, sorry for my bad english

Best Answer

The best thing is to use permissions. If datamoduser is the database user that performs the data modifications, make sure the user has no permissions except

GRANT UPDATE (point) ON mytable TO datamoduser;

Then all UPDATE statements except the ones that update point will fail.