mysql查询和创建存储过程

查询数据库的存储过程:

show procedure status where db='test1';   

或者使用:

select * from mysql.proc

或者使用:

select * from information_schema.routines

想直接看某个存储的过程的创建明细:

SHOW CREATE PROCEDURE test1.proc\G;

创建存储过程:

示例:

#创建插入指定行数的记录到测试表中的存储过程
drop procedure if exists proc;
delimiter $$
create procedure proc(i int)
begin
    declare s int default 1;
    declare c char(50) default repeat('a',50);
    while s<=i do
        start transaction;
        insert into test_flush_log values(null,c);
        commit;
        set s=s+1;
    end while;
end$$
delimiter ;

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章