Postgresql, Restrict update on specific columns (Read Only)

前端 未结 2 816
野趣味
野趣味 2021-01-07 19:23

Is it possible to have postresql restrict/prevent an update on a specific record if the update includes changes to specific columns?

How would this be implemented. A

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-07 20:01

    No, but it should be pretty trivial to write. Just set up a BEFORE UPDATE trigger that compares old field against new field and does a RAISE ERROR if they're different. The pgSQL docs have a few examples of how to write a trigger function.

提交回复
热议问题