mysql存储过程基础

DELIMITER //

create procedure ss(in x1 int)
begin

insert into pro(id) values(x1);
end//
DELIMITER ;

call ss(1004);

################################

查看:

 

方法一:(直接查询,比较实用,查看当前自定义的存储过程)

select `specific_name` from mysql.proc where `db` = 'your_db_name' and `type` = 'procedure'

方法二:(查看数据库里所有存储过程+内容)

show procedure status;

方法三:(查看当前数据库里存储过程列表)

select specific_name from mysql.proc ;

方法四:(查看某一个存储过程的具体内容)

select body from mysql.proc where specific_name = 'your_proc_name';

查看存储过程或函数的创建代码 :

show create procedure your_proc_name;
show create function your_func_name;

 

调用:

mysql> set @a = 10;
Query OK, 0 rows affected (0.00 sec)

 

mysql> set @b = 20;
Query OK, 0 rows affected (0.00 sec)

 

mysql> set @c = 0;
Query OK, 0 rows affected (0.00 sec)

 

mysql>select @c;
+------+
| @c   |
+------+
|    0 |
+------+

 

mysql> call my_add(@a, @b, @c);
Query OK, 0 rows affected (0.00 sec)


mysql> select @a, @b, @c;
+------+------+------+
| @a   | @b   | @c   |
+------+------+------+
|   10 |   20 |   30 |
+------+------+------+
1 row in set (0.00 sec)

 

删除

drop procedure your_proc_name;

 

posted @ 2016-04-11 09:15  ivon168  阅读(180)  评论(0编辑  收藏  举报