Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write once, read many mysql field

Tags:

mysql

Can you restrict a field from being updated without granting any additional user privileges ?

Basically a value in a row can only be set during an insert statement.

like image 639
lostsource Avatar asked Apr 18 '11 14:04

lostsource


2 Answers

Yes. If you grant only insert and select privileges. Like:

grant select, insert, update(message, time) on hibtest.message to 'worm'@'localhost' identified by 'worm'

... this way the user can only update message and time columns.

like image 91
vbence Avatar answered Sep 28 '22 12:09

vbence


You can use an update trigger to prevent the value from being updated.

like image 24
Ocaso Protal Avatar answered Sep 28 '22 11:09

Ocaso Protal