创建规则忽略错误的数据;操作正确的数据。
create
rule [规则名称] as on insert to [表名]
where
exists
(select 1 from [表名] where [判断条件])
do instead nothing;
#下面的规则是:插入数据到表system_lock时,id相同的就忽略。
create
rule r_insert_ignore as on insert to system_lock
where
exists
(select 1 from system_lock where id = new.id)
do instead nothing;
后续就可以用正常的语句insert;