---恢复内容开始---
Loop循环
label: LOOP statement_list IF exit_condition THEN LEAVE label; END IF; END LOOP label;
Repeat循环
REPEAT statement_list UNTIL search_condition END REPEAT;
While循环
WHILE search_condition DO statement_list END WHILE;
IF...ELSE分支判断
IF search_condition THEN statement_list ELSE statement_list END IF;
IF...ELSEIF...ELSE分支判断
IF search_condition THEN statement_list ELSEIF search_condition THEN statement_list ELSE statement_list END IF;
CAST分支判断
CASE case_value WHEN when_value THEN statement_list ELSE statement_list END CASE;
创建存储过程(PROCEDURE)
create PROCEDURE procedure_name([IN|OUT|INOUT] param_name param_type,...) BEGIN statement_list END
删除存储过程(PROCEDURE)
DROP PROCEDURE procedure_name
查看存储过程(PROCEDURE)
SELECT * FROM mysql.proc WHERE type = 'PROCEDURE'
创建函数(FUNCTION)
CREATE FUNCTION function_name(param_name param_type,...) RETURNS return_type BEGIN statement_list END
删除函数(FUNCTION)
DROP FUNCTION IF EXISTS function_name
查看函数(FUNCTION)
SELECT * FROM mysql.proc WHERE type = 'FUNCTION'
定义变量赋值
-- 函数(FUNCTION)或存储过程(PROCEDURE)定义变量及赋值 -- 定义 DECLARE variable_name variable_type DEFAULT default_value; -- 赋值 SET variable_name = new_value; -- 在SELECT查询里进行赋值 SELECT variable_name := col_name;
关于定义变量赋值的详细说明:https://www.cnblogs.com/EasonJim/p/7966918.html
关于动态MySQL语句:http://blog.itpub.net/29773961/viewspace-1852824/