springboot mybatis下临时表的创建和删除,可用于查重去重


    /**
     * 创建临时表
     */
    @Update({"drop temporary table if exists ${tableName};", "create temporary table ${tableName} select doctor_id from crm_speaker where  1=2 "})
    void createTemoraryTable(@Param("tableName") String tableName);

    /**
     * 保存数据到临时表里面以便校验数据重复
     */
    @Insert("<script>" +
            "insert into ${tableName} (doctor_id) values\n" +
            "    <foreach collection=\"list\" item=\"doct\" index=\"index\" separator=\",\">\n" +
            "       (" +
            "       #{doct.doctorId,jdbcType=VARCHAR}\n" +
            "       )\n" +
            "    </foreach>\n" +
            "</script>")
    void insertBatchCheckDatas(@Param("list") List<SpeakerDO> dOs, @Param("tableName") String tableName);


    /**
     * 删除临时表
     */
    @Update({"drop temporary table if exists ${tableName}"})
    void dropTemporaryTable(@Param("tableName") String tableName);

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM