Stop uninstalling on MySQL via triggers

I am trying to intercept any DELETE commands for a specific table. MySQL supports triggers, but doesn't seem to support a way to raise errors like SQL Server and other databases.

Can I do this with just an empty trigger definition? Sort of:

create trigger trListsDelete on lists
instead of delete
as
begin
  /* Do nothing */
end

In SQL Server, I can add a statement RAISEERROR('You cannot delete lists.')to make it crash, and this way I know that Delete will not be executed. Since MySQL does not support error collection, how to simply ignore the Delete command?

+3
source share
1 answer

The technique is that you are doing something that causes an error, for example, updating a nonexistent column.

: MySQL: INSERT, UPDATE DELETE ?

+3

Source: https://habr.com/ru/post/1721495/


All Articles