oracle对应pl/sql,sqlserver对应t-sql,
mysql有类似的语言吗,可以实现像上述2种数据库
的循环,选择和函数等等的语句结构吗?
------解决方案--------------------
- SQL code
mysql> create procedure pro10() -> begin -> declare i int; -> set i=0; -> while i<5 do -> insert into t1(filed) values(i); -> set i=i+1; -> end while; -> end;//Query OK, 0 rows affected (0.00 sec)
------解决方案--------------------
- SQL code
mysql> create procedure pro11() -> begin -> declare i int default 0; -> repeat -> insert into t1(filed) values(i); -> set i=i+1; -> until i>=5 -> end repeat; -> end;//Query OK, 0 rows affected (0.00 sec)mysql> create procedure pro12() -> begin -> declare i int default 0; -> loop_label: loop -> insert into t1(filed) values(i); -> set i=i+1; -> if i>=5 then -> leave loop_label; -> end if; -> end loop; -> end;//