“MySQL Bidirectional Composite Primary Key” Réponses codées

MySQL Bidirectional Composite Primary Key

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);
jcho.morpheo

MySQL Bidirectional Composite Primary Key

create trigger bi_foo before insert on foo
for each row
begin
  if exists(select 1 from foo where bar1 = NEW.bar2 and bar2 = NEW.bar1)
  then
    signal sqlstate '50000' set message_text="Oops";
  end if;
end
jcho.morpheo

Réponses similaires à “MySQL Bidirectional Composite Primary Key”

Questions similaires à “MySQL Bidirectional Composite Primary Key”

Plus de réponses similaires à “MySQL Bidirectional Composite Primary Key” dans Sql

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code