- Custom functions
- A user-defined function (user-defined function, UDF) is a way to extend MySQL, using the same functionality as built-in functions.
- parameter, return value
- Creating a Custom function
CREATE FUNCTIONfunction_nameRETURNS[string| integer| real| DECIMAL]Routine_body//about function Bodies//1the function body has a valid SQL statement structure;//2the function body can be a simple select or INSERT statement;//3the function body uses the BEGIN if the structure is compliant. End statement;//4. The composite machine bone puppet can contain declarations, loops, and control structures.
// for Example: CREATE FUNCTION RETURN VARCHAR (in) RETURN ' %y%m Month%d day%h%m minutes%s seconds ');
- DELIMITER//This statement indicates that the SQL console will no longer be in the future; For statement Terminator instead of//end
MySQL (vi)--Custom function