1.存储
\d // :\d:定义执行符号默认是;
create procedure p3()
begin
//delcare a int;定义变量,存储的时候用
set @i=1;定义变量 //给变量赋值
while @i < 10000 do
insert into t2(id) values(@i);
end while;
end;
//
show procedure status;查看存储状态
show procedure status;查看存储状态
show create procedure p3;查看储存的定义
使用存储:call p3();
2.触发器:就是类似于事件模型。create trigger tg1 before/after insert/select/update/delete on t1 for each row
begin
insert into t2() values();
end
create trigger tg1 before/after delete on t1 for each row
begin
delete form t2 where name=old.name;//old.name 就是在t1表中用的条件
end
create trigger tg1 before/after update on t1 for each row
begin
update t1 set name=new.name where name=old.name ;//old.name 就是在t1表中用的条件
end
\d // :\d:定义执行符号默认是;
create procedure p3()
begin
//delcare a int;定义变量,存储的时候用
set @i=1;定义变量 //给变量赋值
while @i < 10000 do
insert into t2(id) values(@i);
end while;
end;
//
show procedure status;查看存储状态
show procedure status;查看存储状态
show create procedure p3;查看储存的定义
使用存储:call p3();
2.触发器:就是类似于事件模型。create trigger tg1 before/after insert/select/update/delete on t1 for each row
begin
insert into t2() values();
end
create trigger tg1 before/after delete on t1 for each row
begin
delete form t2 where name=old.name;//old.name 就是在t1表中用的条件
end
create trigger tg1 before/after update on t1 for each row
begin
update t1 set name=new.name where name=old.name ;//old.name 就是在t1表中用的条件
end