开发者

Stopping a delete on MySQL via Triggers

I'm trying to intercep开发者_如何学运维t any DELETE commands against a particular table. MySQL supports triggers but it doesn't seem to support a way to raise an error yet like SQL Server and other databases.

Can I do this with just an empty Trigger definition? Something like:

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

In SQL Server I could add a RAISEERROR('You cannot delete lists.') statement to force it to fail and that way I know the Delete wouldn't be executed. Since MySQL doesn't support raising errors, how do I simply ignore the Delete command?


The technique is you do something that will cause an error, such as update a column that doesn't exist.

Details here: MySQL Triggers: How do you abort an INSERT, UPDATE or DELETE with a trigger?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜