createtable test(id int); delimiter // #定义标识符为双斜杠 dropprocedure if exists test; #如果存在test存储过程则删除 createprocedure test() #创建无参存储过程,名称为test begin declare i int; #申明变量 declare id_ int; declare done int; declare cur cursorforselect id from test; declare continue handler fornot found set done =1; open cur; read_loop: loop fetch cur into id_; if done =1then leave read_loop; end if; select id_; end loop; close cur; end // #结束定义语句 call test(); #调用存储过程