I have a database table that want to protect some rows from deleting and updating. I am using MySQL database. How can fix it in phpmyadmin or sql syntax?
EX: prevent row with id:18
from delete and update:
I have a database table that want to protect some rows from deleting and updating. I am using MySQL database. How can fix it in phpmyadmin or sql syntax?
EX: prevent row with id:18
from delete and update:
You have various options.
SESSION WISE: if you are using INNODB
SET AUTOCOMMIT=0;
UPDATE table SET mainpage =1 WHERE id = 18;
-- do NOT commit until you want to release the lock.
-- if you do that under myisam,
-- I think it is going to lock the whole table (to be verified)
STRUCTURAL PROTECTION
Create a trigger before update/delete on your table and raise an error when :new.id = 18