Search
 
SCRIPT & CODE EXAMPLE
 

SQL

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);
Comment

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
Comment

PREVIOUS NEXT
Code Example
Sql :: insert all or first in oracle sql 
Sql :: delete entries in postgresql 
Sql :: mysql subtract month from timestamp 
Sql :: oracle kill session by sql_id 
Sql :: encoding UTF8 has no equivalent in encoding WIN1252 
Sql :: postgres check timezone 
Sql :: set permanent SET GLOBAL sql_mode ubuntu 
Sql :: set boolean flasksql 
Sql :: how to create a variable in mysql 
Sql :: oracle activate job 
Sql :: update substring in mysql 
Sql :: mysql user permission database 
Sql :: show table columns 
Sql :: postgres get database encoding 
Sql :: sql get guid 
Sql :: mysql copy table1 to table2 
Sql :: remove spaces sql server 
Sql :: apex add months to date 
Sql :: sort by last three charecter in sql 
Sql :: asp.net core with postgresql deploy on ubuntu 
Sql :: view linked servers 
Sql :: varchar plsql 
Sql :: describe table query in postgresql 
Sql :: mariadb.service: Main process exited, code=exited, status=1/FAILURE 
Sql :: sql server date now 
Sql :: t sql check active deadlock 
Sql :: this week mysql 
Sql :: get only first row mysql 
Sql :: how to remove default in mysql 
Sql :: sql not contains 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =