存储过程中的SQL语句集(StoredP

05/05 19:23:23 来源网站:268辅助卡盟网

调用存储过程查询年龄小于38的中学生人数:

-- 调用存储过程
mysql> CALL student_procedure(38, @num);
Query OK, 1 row affected
-- 查看返回结果
mysql> select @num;
+------+
| @num |
+------+
|    2 |
+------+

查看存储过程定义

句型:

SHOW CREATE PROCEDURE proc_name;

比如看student_procedure的定义:

mysql> SHOW CREATE PROCEDURE student_procedure;
+-------------------+----------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+
| Procedure         | sql_mode                                                       | Create Procedure                                                                                                                                                 | character_set_client | collation_connection | Database Collation |
+-------------------+----------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+
| student_procedure | STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION | CREATE DEFINER=`root`@`localhost` PROCEDURE `student_procedure`(IN age TINYINT, OUT num INT) BEGIN SELECT COUNT(*) INTO num FROM tb_student t WHERE t.age>=age;END | utf8                 | utf8_general_ci      | utf8_general_ci    |
+-------------------+----------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+

    暂无相关资讯
存储过程中的SQL语句集(StoredP