MYSQL入门学习之十三:自定义函数的基本操作(二)
ot`@`localhost` FUNCTION `fun_add_rand`(
in_int int
) RETURNS int(11)
BEGIN
declare i_rand int;
declare i_return int;
set i_rand=floor(rand()*100);
set i_return = in_int + i_rand;
return i_return;
END | latin1 | latin1_swedish_ci | latin1_swedish_ci |
+--------------+----------+-----------------------------------------------------------+----------------------+----------------------+--------------------+
5、查看自定义函数状态
SHOW FUNCTION STATUS [ LIKE '' ];
示例:
[sql]
mysql> show function status like 'fun%';
+------+--------------+----------+----------------+---------------------+---------------------+---------------+
| Db | Name | Type | Definer | Modified | Created | Security_type |
+------+--------------+----------+----------------+---------------------+---------------------+---------------+
| test | fun_add_rand | FUNCTION | root@localhost | 2012-12-18 20:08:50 | 2012-12-18 20:08:50 | DEFINER |
+------+--------------+----------+----------------+---------------------+---------------------+---------------+