Mybatis同时执行多条SQL

1. Mybatis配置文件示例
<delete id="resetDB">
    DELETE from wechat_question;
    DELETE from wechat_answer;
    DELETE from wechat_answer_record;
    DELETE from wechat_code_record;
    DELETE FROM wechat_award_record;
    DELETE from wechat_sms_record;
    DELETE from wechat_user;
</delete>
2. 数据连接开启多条语句处理allowMultiQueries=true
# 数据源配置
spring:
    datasource:
        type: com.alibaba.druid.pool.DruidDataSource
        driverClassName: com.mysql.jdbc.Driver
        druid:
            # 主库数据源
            master:
                url: jdbc:mysql://10.200.0.112:3306/wechat?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&allowMultiQueries=true
                username: root
                password: root

加上allowMultiQueries=true就可以在一个方法里同时执行多条sql了

你可能感兴趣的:(日常随笔,mybatis,多少条delete)