How to prevent data deletion from MySQL table
I am completely new to this arena so please forgive me if my question seems unclear.
I would like to prevent the deletion of any record data from a table using a trigger that would abort any delete command executed upon that table.
I've found the following code via Google and would very much appreciate anyone who be willing or able to offer advice regarding if this code would work and if not perhaps suggest an alternative method.
Here's the code:
DELIMITER $$
CREATE TRIGGER trigger1
BEFORE DELETE
ON table1
FOR EACH ROW
BEGIN
CALL cannot_delete_error; -- raise an error to prevent deleting from the table
END IF;
END
$$
DELIMITER ;
Many thanks in advance for any help : )
Subject
Written By
Posted
How to prevent data deletion from MySQL table
September 22, 2015 01:25PM
September 22, 2015 01:55PM
September 22, 2015 02:16PM
September 22, 2015 02:55PM
September 22, 2015 03:27PM
September 22, 2015 11:34PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.