存储过程
PROCEDURE 存储过程
- 存储过程通常只在测试环境中使用,生产环境中不建议使用存储过程
调用存储过程
CALL sp_name ([ proc_parameter [,proc_parameter ...]]);查看存储过程列表
SHOW PROCEDURE STATUS;删除存储过程
DROP PROCEDURE [IF EXISTS] sp_name;存储过程范例
# cat testlog.sql
create table testlog (id int auto_increment primary key,name char(10),age int default 20);
delimiter $$
create procedure sp_testlog()
begin
declare i int;
set i = 1;
while i <= 10000
do insert into testlog(name,age) values (concat('xiang',i),i);
set i = i +1;
end while;
end$$
delimiter ;导入存储过程
mysql -D hellodb < testlog.sql