-> insert into cdb_invites values (1,1279616286,1280480286,'10.0.7.7',a,0,0,1);
-> set a=a+1;
-> end while;
-> end //
Query OK, 0 rows affected (0.00 sec)
/*调用一次该存储过程。后查看该表,增加了99条新数据*/
mysql> call hi()//
Query OK, 1 row affected (0.01 sec)
mysql> select count(*) from cdb_invites//
+----------+
| count(*) |
+----------+
| 360 |
+----------+
1 row in set (0.00 sec)
/*显示创建存储过程hi的字符串内容*/
mysql> show create procedure hi//
+-----------+----------+----------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------+
| hi | | CREATE DEFINER=`root`@`localhost` PROCEDURE `hi`()
begin
declare a int(10);
set a=1;
while a<100 do
insert into cdb_invites values (1,1279616286,1280480286,'10.0.7.7',a,0,0,0);
set a=a+1;
end while;
end |
+-----------+----------+----------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
/*显示现有的存储过程*/
mysql> show procedure status//
+-----------------+--------------------+-----------+----------------+---------------------+---------------------+-----------
----+---------+
| Db | Name | Type | Definer | Modified | Created | Security_type | Comment |
+-----------------+--------------------+-----------+----------------+---------------------+---------------------+----------+
| mhqy_bbs | hi | PROCEDURE | root@localhost | 2010-07-22 13:39:51 | 2010-07-22 13:39:51 | DEFINER | |
| mhqy_bbs | p1 | PROCEDURE | root@localhost | 2010-07-20 17:13:26 | 2010-07-20 17:13:26 | DEFINER | |
+-----------------+--------------------+-----------+----------------+---------------------+---------------------+----------+
2 rows in set (0.00 sec)