Mysql储存过程1: 设置结束符与储存过程创建

#显示储存过程
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>

 

posted on 2017-07-04 06:14  Perl6  阅读(1235)  评论(0编辑  收藏  举报

导航