📜  mysql 双向复合主键 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:31.735000             🧑  作者: Mango

代码示例2
CREATE TRIGGER uinsert BEFORE INSERT ON tbl_challenger
 FOR EACH ROW SET NEW.u0 = LEAST(NEW.host,NEW.challenger),
  NEW.u1 = GREATEST(NEW.host,NEW.challenger);
#same for update
CREATE UNIQUE INDEX uniqueness ON tbl_challenger(u0,u1);