#显示储存过程
show procedure status; #设置结束符
delimiter $;
#创建储存过程
create procedure procedure_name()
begin
--sql语句
end$ create procedure myshow()
begin
select user(),database();
end$ #调用储存过程
call procedure()
call procedure
#没有对数时括号可省
mysql> use test$
Database changed
mysql> create procedure myshow()
-> begin
-> select user(),database();
-> end$
Query OK, 0 rows affected (0.03 sec) mysql> call myshow
-> $
+----------------+------------+
| user() | database() |
+----------------+------------+
| root@localhost | test |
+----------------+------------+
1 row in set (0.02 sec) Query OK, 0 rows affected (0.03 sec) mysql> myshow()$
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near 'myshow()' at line 1
mysql> call myshow()$
+----------------+------------+
| user() | database() |
+----------------+------------+
| root@localhost | test |
+----------------+------------+
1 row in set (0.00 sec) Query OK, 0 rows affected (0.01 sec) mysql>
05-12 04:20