MySQL Forums
Forum List  »  Newbie

Re: How to prevent data deletion from MySQL table
Posted by: Peter Brawley
Date: September 22, 2015 02:55PM

Calling a non-existent procedure from a Delete Trigger will work, but it's a hack and may have undesirable side-effects, for example if the deletion command occurs in a transaction, all cmds in the transaction will roll back.

The most straightforward method is to withhold DELETE permission for that table from all users except perhaps yourself.

Next alternative will require a bit of code: create a guard table that references the table in a foreign key constraint ...

create table table1guard( table1ID int primary key, foreign key(table1ID) references table1(table1ID);

... and use Triggers to ensure that all table1 primary keys exist in table1guard.

Options: ReplyQuote


Subject
Written By
Posted
Re: How to prevent data deletion from MySQL table
September 22, 2015 02:55PM


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.