Can we prevent table from update directly but allow update using trigger from another table? So, let's say I have 3 tables:


stocks table, it have columns: id, product_id, stock
sell table, it have columns: id, product_id, qty
buy table, it have columns: id, product_id, qty


What I want to do:


Prevent update stocks.stock value directly.
But allow update stocks.stock value by trigger from buy or sell table.


Is this possible? If it's possible, how? If its impossible, why?
create trigger has a definer = {user} option for this.

You need to ensure that this defined user has update access to the stocks.stock however the other users only have select table access.

GRANT can control access at a table level.