mysql创建存储过程测试实验讲解
mysqlmysql 创建存储过程测试实验讲解创建存储过程测试实验讲解1.创建数据库 test3:create databse test3;2.创建表 t2:use test3;create table t2 (id int,name char(50),dtime timestamp);plain view plain copymysql> select * from t2; Empty set (0.00 sec) 3.创建 procedure 来循环插入数据到新建的 t2 表中plain view plain copymysql> DELIMITER $ mysql> CREATE PROCEDURE t2insert(IN count INT) -> BEGIN -> DECLARE i INT DEFAULT 0; -> WHILE i DO -> insert into t2 values(i,concat('yoo',i),CURRENT_TIMESTAMP(); -> SET i=i+1; -> END WHILE ; -> END$ Query OK, 0 rows affected (0.06 sec) 988 棋牌 http:/www.rodlg.com4.查看存储过程的信息:DELIMITER ;show procedure status like '%insert%' G;show create procedure t2insert G;select * from information_schema.routines where routine_name = 't2insert' G;plain view plain copymysql> show procedure status like '%insert%' G; * 1. row * Db: test3 Name: t2insert Type: PROCEDURE Definer: rootlocalhost Modified: 2018-06-10 22:13:09 Created: 2018-06-10 22:13:09 Security_type: DEFINER Comment: character_set_client: gbk collation_connection: gbk_chinese_ci Database Collation: utf8_general_ci 1 row in set (0.00 sec) 5.调用存储过程plain view plain copymysql> call t2insert(10); Query OK, 1 row affected (0.65 sec) mysql> select * from t2; +-+-+-+ | id | name | dtime | +-+-+-+ | 0 | yoo0 | 2018-06-10 22:18:25 | | 1 | yoo1 | 2018-06-10 22:18:26 | | 2 | yoo2 | 2018-06-10 22:18:26 | | 3 | yoo3 | 2018-06-10 22:18:26 | | 4 | yoo4 | 2018-06-10 22:18:26 | | 5 | yoo5 | 2018-06-10 22:18:26 | | 6 | yoo6 | 2018-06-10 22:18:26 | | 7 | yoo7 | 2018-06-10 22:18:26 | | 8 | yoo8 | 2018-06-10 22:18:26 | | 9 | yoo9 | 2018-06-10 22:18:26 | +-+-+-+ 10 rows in set (0.00 sec) 6.可以使用 alter 修改存储过程的简单特性但并不能修改过程体,所以要修改过程体的SQL 语句只能drop 删除后重新创建alter proceduredrop procedure t2insert; 来运棋牌 http:/www.411196.com