mysql触发器helloworld

修改my.ini
thread_stack = 128M
大于128k
CREATE TABLE tab2(
    tab2_id varchar(11)
);
CREATE TABLE tab1(
    tab1_id varchar(11)
);
delimiter |
create trigger t_afterinsert_on_tab1 after INSERT ON tab1
FOR EACH ROW BEGIN
	insert into tab2(tab2_id) values(new.tab1_id); 
END

delimiter ;
INSERT INTO tab1(tab1_id) values('0001');
SELECT * FROM tab1;
SELECT * FROM tab2;

你可能感兴趣的:(helloworld)