Mysql for databases (6) -- mysql common functions/user-defined functions, mysql Functions
Common functionsOperation Functions
I believe you can understand it, so I will not explain it too much.
Then there is another, missed between and:
Indicates whether 10 is between 0 and 20. If 1 is returned, otherwise 0 is returned.
Date Functions
Note that the first parameter is the start date, interval is fixed, 2 is the number of days to be added, and the following day is the unit, or week, year.
Information Functions
Aggregate functions
Because the tables in my test database do not have good data, the operation result is very strange. Sorry, you know how to use it.
Encryption Functions
I personally think these two encryption functions are not very secure.
Although the md5 encryption operation is irreversible (it is not allowed to use the encrypted data for reverse translation), the encrypted data is regular, do not believe that you can operate on your own computer to see if the encrypted "testing" is the same as mine, so long as you can integrate all the data encrypted by md5 into a database, then you can decrypt the code one by one. And the password method can also be in this situation,
However, in general operations, it is enough to use these two encryption functions.
Custom functions:
1) Necessary Conditions for user-defined functions:
- There can be zero or multiple parameters
- Only one value can be returned.
There can be no inevitable relationship between parameters and return values. All functions have return values, but the parameters are not necessarily.
The function can return any type of data, or accept any type of data as a parameter.
2) User-Defined Function body:
3) Example:
A: No Parameters
- Returns specifies the data type returned by the function.
- Return is used to return specific values/value variables.
- The function name must be enclosed in parentheses. Otherwise, an error is returned.
B: With parameters:
C: Create Compound Functions
Current table information:
Create:
The error is reported because mysql ends with a semicolon by default, and data is not inserted into the table.
You can change the default end character of mysql from semicolon //
Create and view data again:
D: delete a UDF.