mysql stored procedure

DROP PROCEDURE IF EXISTS `user1234`;      
DELIMITER //                              
CREATE PROCEDURE `user1234` (IN u VARCHAR(255)) 
LANGUAGE SQL  
DETERMINISTIC  
SQL SECURITY DEFINER
COMMENT '查询用户'
BEGIN
SELECT * FROM `user`;
INSERT INTO `user`(name,age,sex,address) VALUES('wang','19','男','广西');
END//
DELIMITER;
call `user1234`('张三')

1. DROP PROCEDURE IF EXISTS [stored procedure name]

(If the stored procedure exists, delete it and create it! If it is not written, it can only be executed once)
2.DELIMITER //  

(Replace the end of each sentence with //)
3.CREATE PROCEDURE `stored procedure name` (parameter)

(Create a stored procedure (parameter list [IN input parameter [out output parameter inout input and output parameter] u parameter name parameter type]))

4.LANGUAGE sql
 (stored statement is sql statement)

5. DETERMINISTIC [not DETERMINISTIC]
(indicates that the stored procedure produces the same result for the same input parameters [indicates that an indeterminate result will be produced (default).])

6.SQL SECURITY DEFINER

(

SQL SECURITY

DEFINER defaults to the current user, and other users can also be specified. If you want to judge whether you have the right to access the PROCEDURE by the visitor, you can specify it with SQL SECURITY.

)

7.COMMENT ‘’

(Description of stored procedures is similar to java)

8.BEGIN method body starts
... write sql statement
END//method body ends

9. call XX

(calling the stored procedure XX is the storage name)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324481630&siteId=291194637