mysql
>
 delimiter 
//

mysql
>
mysql
> CREATE PROCEDURE simpleproc ( IN myId INT )
-> BEGIN
-> CREATE TEMPORARY TABLE tmpMyTbl LIKE t2;
-> insert into tmpMyTbl
-> select * from t2 where id < myId;
-> END ;
-> //
Query OK,
0 rows affected ( 0.09 sec)

mysql
>
mysql
> delimiter ;
mysql
> call simpleproc( 10 );
Query OK,
9 rows affected ( 0.13 sec)

mysql
> select * from tmpMyTbl;
+ -- --+------+
| id | col |
+ -- --+------+
| 1 | 2 |
| 2 | 4 |
| 3 | 6 |
| 4 | 8 |
| 5 | 10 |
| 6 | 12 |
| 7 | 14 |
| 8 | 16 |
| 9 | 18 |
+ -- --+------+
9 rows in set ( 0.00 sec)

mysql
>

版权声明:本文为rushcc2006原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/rushcc2006/article/details/5755062