1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 在mysql中创建和调试存储过程

在mysql中创建和调试存储过程

时间:2021-07-15 09:39:32

相关推荐

在mysql中创建和调试存储过程

下面是在mysql 查询浏览器里写存储过程和调试,步子为:在数据库上右键选择create new procedure / function,输入一个名称,我这里输入的是"bbb",它会自动创建一个空的过程模板,我声明了三个变量,给三个变量赋值,并输出三个变量,在查询 浏览器菜单 tools -> mysql command line client 直接进DOS窗口,先use databasename;call procedurename();可以带参数,我这里没用参数。

----------------------------------------------------------------------------------------------------------

DELIMITER $$

DROP PROCEDURE IF EXISTS `test`.`bbb`$$

CREATE DEFINER=`root`@`localhost` PROCEDURE `test`.`bbb`()

BEGIN

declare a int;

declare b varchar(45);

declare c varchar(45);

set a = 3;

set b = "abc";

select strname from t1 into c;

select a;

select b;

select c;

END $$

DELIMITER ;

------------------------------------------------------------------------------------------------------------

Welcome to the MySQL monitor. Commands end with ; or /g.

Your MySQL connection id is 2

Server version: 5.1.30-community MySQL Community Server (GPL)

Type 'help;' or '/h' for help. Type '/c' to clear the buffer.

mysql> use test;

Database changed

mysql> call bbb();

+------+

| a |

+------+

| 3 |

+------+

1 row in set (0.02 sec)

+------+

| b |

+------+

| abc |

+------+

1 row in set (0.03 sec)

+-------------+

| c |

+-------------+

| test string |

+-------------+

1 row in set (0.03 sec)

Query OK, 0 rows affected (0.05 sec)

mysql>

-------------------------------------------------------------------------------------------------------

感觉csdn还没有百度专业,在那里可以贴抓图,我在百度也有博客一般都附了抓图

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。