How to reject delete statement in before delete trigger (mysql) ?
Sample use case : I have a record with specified id that I want to will not be deleted.
How to reject delete statement in before delete trigger (mysql) ?
Sample use case : I have a record with specified id that I want to will not be deleted.
You could create a table that uses a foreign key constrait referencing your ID column (provided that is the primary key of your table). The insert a row into that "child" table that references ID = 0 and remove all update/delete privileges for your user from that table.
Now if someone tries to delete the row with ID = 0 in the "parent" table that will fail due to an existing child row in the other table.
Look here, same thing but with an insert-trigger: How to abort INSERT operation in MySql trigger?