0
我想在插入一组新数据之前清除/清空/截断MySQL中的一个表。我认为这只能使用触发器来完成。在插入新数据之前截断表
我创建了以下触发:
create trigger top_destinations_truncate BEFORE INSERT
on top_destinations FOR EACH ROW
delete from top_destinations
但是,当我尝试使用我的查询增加几百记录我得到这个错误:
HY000Can't update table 'top_destinations' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
的insert into table top_destinations
查询本身工作正常,如果触发器不存在。但我需要每次重新开始...
我该怎么办?也许在没有触发器的情况下,MySQL有更好的方式:像一个顺序类型的查询。首先截断,稍等一会,然后插入,如果可能的话。