MySQL built-in functions:
- Character functions
- numeric functions
- Time-Date function
Common use of numeric functions:
1 Select avg from Tdb_goods; Find the average of field values
Built-in summation functions:
1 Select sum from Tdb_goods; To find the value of the field and
- Examples of common date functions
1 Select
User-defined functions:
20.2.1.CREATEProcedure and createFUNCTIONCREATE PROCEDURESp_name ([proc_parameter[,...]]) [characteristic ...]Routine_bodyCREATE FUNCTIONSp_name ([func_parameter[,...]]) RETURNStype[characteristic ...]routine_body Proc_parameter:[In | Out | INOUT]param_name type Func_parameter:param_name type type: anyvalid MySQL data type Characteristic:language SQL| [ not]Deterministic|{CONTAINSSql|NO SQL|READS SQL DATA|modifies SQL DATA}|SQL SECURITY {Definer|INVOKER}|COMMENT'string'routine_body:valid SQLprocedureStatementorStatements
If a custom function contains a compound statement, you will use begin. End statement.
1 [Begin_label:] BEGIN 2 [statement_list] 3 END [end_label]
//
The storage subroutine can use the begin ... End Compound statement to contain multiple statements. statement_list represents a list of one or more statements. Each statement within Statement_list must be terminated with a semicolon (;).
Compound statements can be marked. Unless Begin_label exists, End_label cannot be given, and if both exist, they must be the same.
Note that the optional [NOT] atomic clause is not currently supported. This means that a storage point that has no interaction at the beginning of the instruction block is set, and the BEGIN clause used in the context has no effect on the current interaction action.
Using multiple statements requires the client to send a query string containing the statement delimiter; This symbol is handled by the command line client with the delimiter command. Change the end of the query delimiter; (e.g. change to//) make; Can be used in the subroutine body.
MYSQL common built-in functions and custom functions