1CREATE TRIGGER uinsert BEFORE INSERT ON tbl_challenger
2 FOR EACH ROW SET NEW.u0 = LEAST(NEW.host,NEW.challenger),
3 NEW.u1 = GREATEST(NEW.host,NEW.challenger);
4#same for update
5CREATE UNIQUE INDEX uniqueness ON tbl_challenger(u0,u1);
1create trigger bi_foo before insert on foo
2for each row
3begin
4 if exists(select 1 from foo where bar1 = NEW.bar2 and bar2 = NEW.bar1)
5 then
6 signal sqlstate '50000' set message_text="Oops";
7 end if;
8end