mysql8.0创建存储过程

执行多批量多表单条相同记录删除操作;

DELIMITER //
CREATE PROCEDURE del_user(IN userId BIGINT)
BEGIN
DELETE FROM `user` WHERE id = userId ;
DELETE FROM `user_auths` WHERE user_id = userId ;
DELETE FROM `user_approval_log` WHERE user_id = userId ;
DELETE FROM `suser_extend` WHERE user_id = userId ;
DELETE FROM `order` WHERE user_id = userId ;
DELETE FROM `cepay_log` WHERE user_id = userId ;
DELETE FROM `volunteer` WHERE id = userId ;
END
//
DELIMITER ;

 

8.0格式要求:

必须成对出现

DELIMITER //

//
DELIMITER ;

创建存储过程核心语句:

 

CREATE PROCEDURE del_user(IN userId BIGINT)
BEGIN

/***执行内容**/

END

del_user:存储过程名称;

userId :传入参数 

IN: 输入参数;

OUT:输出参数-这里没用到;

BIGINT:传入参数类型,这里是长整型 根据业务需求来修改;

执行调用方式;

call del_user(1234565789789799)

你可能感兴趣的:(数据库,mysql8.0,存储过程,存储过程,mysql,批量删除)