Bug #4044 Are Triggers available?
Submitted: 7 Jun 2004 22:16 Modified: 4 Aug 2005 23:02
Reporter: Nick Pelov Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version: OS:
Assigned to: CPU Architecture:Any

[7 Jun 2004 22:16] Nick Pelov
Description:
Where are well known triggers?
I've read about mysql triggers, but what I want to say is this:

When I post query like
insert into songs (title,code) values ('song name',123)

automatically in table codes to be inserted the code 123
And because I'm not good in explainations here is an example from little database engine called SQLite:
let's create 3 tables:

create table keys (id integer primary key, code integer,type varchar(10));

create table songs (id integer primary key,title varchar(40),code integer);

create table pics (id integer primary key,pic varchar(40),code integer);

now the triggers:
create trigger t1 after insert on songs for each row begin
insert into keys values(null,new.code,'song');
end;
create trigger td1 before delete on songs for each row begin
  delete from keys where k=old.id;
end;
create trigger t2 after insert on pics for each row begin
insert into keys values (id,new.code,'picture');
end;
create trigger td2 before delete on pics for each row begin
  delete from keys where k=old.id;
end;

So when a query is executed for songs or pics tables keys table will automatically update.

Tell me if this feature is already made in new releases of mysql

How to repeat:
Well in feature request I don't need to supply instructions for bug repeating

Suggested fix:
this is very use full feature, but I didn't find it in mysql
[4 Aug 2005 23:02] Jim Winstead
Triggers are available in MySQL 5.0.