--//storage functions, custom functions----------
--New
CREATE FUNCTION function_name (argument list) RETURNS return value type
function Body
-the function name, which should be a valid identifier, and should not conflict with an existing keyword.
-a function should belong to a database, you can use the form of Db_name.funciton_name to execute the database that the current function belongs to, otherwise the current database.
-The Parameters section, which consists of the parameter name and the parameter type. Multiple parameters are separated by commas.
-The function body consists of a number of available MySQL statements, flow control, variable declaration and other statements.
-Multiple statements should be contained using the BEGIN...END statement block.
-Be sure to have a return value statement.
--Delete
DROP FUNCTION [IF EXISTS] function_name;
--View
SHOW FUNCTION STATUS like ' Partten '
SHOW CREATE FUNCTION function_name;
--Modify
ALTER function function_name option
--//stored procedures, custom features----------
--Definition
A stored procedure is a piece of code (procedure) that is composed of SQL stored in a database.
A stored procedure is typically used to complete a business logic, such as registration, handover fees, order warehousing, etc.
while a function is usually focused on a function, as other program services, you need to call the function in other statements, and the stored procedure cannot be called by others, it is executed by call.
--Create
CREATE PROCEDURE sp_name (parameter list)
Process Body
parameter list: Different from the parameter list of the function, you need to indicate the parameter type
in, indicates input type
out, indicating the output type
INOUT, indicating mixed type
Note that there is no return value.
/ * Stored procedure */------------------
A stored procedure is a collection of executable code. The business logic is more biased than the function.
Invocation: Call Procedure name
--Note
-no return value.
-can only be called separately and cannot be mixed in other statements
--Parameters
in| Out| INOUT parameter name data type
In input: During invocation, data is entered into parameters inside the procedure body
Out output: Returns the result of process body processing to the client during the call process
INOUT input and output: can be input or output
--Grammar
CREATE PROCEDURE Procedure name (parameter list)
BEGIN
Process Body
END
(not to be continued)
(Shocker Source: http://www.cnblogs.com/shockerli/p/1000-plus-line-mysql-notes.html)
1000 Lines MySQL study notes (11)