设置结束sql的符号
DELIMITER $ #以$符号结尾
创建存储过程
mysql> CREATE PROCEDURE procedure_test()
-> BEGIN
-> SELECT 'hello mysql'; # 此处分号;必须有
-> END $
调用存储过程
CALL procedure_test()$
查看存储过程列表
select name from mysql.proc where name = 'procedure_test';
查询存储过程的状态信息
show procedure status \G;
查询某个存储过程的定义
mysql> show create procedure test.procedure_test\G;
*************************** 1. row ***************************
Procedure: procedure_test
sql_mode: STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Create Procedure: CREATE DEFINER=`root`@`localhost` PROCEDURE `procedure_test`()
BEGIN
SELECT 'hello mysql';
END
character_set_client: utf8
collation_connection: utf8_general_ci
Database Collation: utf8_general_ci
1 row in set (0.00 sec)
删除存储过程
mysql> drop procedure if exsists procedure_test;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 13
Current database: test |
设置结束sql的符号
DELIMITER $ #以$符号结尾
创建存储过程
mysql> CREATE PROCEDURE procedure_test()
-> BEGIN
-> SELECT 'hello mysql'; # 此处分号;必须有
-> END $
调用存储过程
CALL procedure_test()$
查看存储过程列表
select name from mysql.proc where name = 'procedure_test';
查询存储过程的状态信息
show procedure status \G;
查询某个存储过程的定义
mysql> show create procedure test.procedure_test\G;
*************************** 1. row ***************************
Procedure: procedure_test
sql_mode: STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Create Procedure: CREATE DEFINER=`root`@`localhost` PROCEDURE `procedure_test`()
BEGIN
SELECT 'hello mysql';
END
character_set_client: utf8
collation_connection: utf8_general_ci
Database Collation: utf8_general_ci
1 row in set (0.00 sec)
删除存储过程
mysql> drop procedure if exsists procedure_test;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 13
Current database: test