其实创建临时表,跟增删改查的原理是一样的,只不过是在xml中写一个创建临时表sql语句,xml中并不是只能写增删改查语句的
在xml中写一个修改头标签,因为是建立的是临时表,所以表名要变,需要在表名处接收一个参数$(tableName) ,这时xml文件就写好了
这时需要在参数中加上注解@Param,只有加上这个注解,在xml中才可以接收到我传入的参数
然后在postman中传入需要的表名,就可以生成这个表了。
/** * 创建临时表 */ @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 " + " <foreach collection="list" item="doct" index="index" separator=","> " + " (" + " #{doct.doctorId,jdbcType=VARCHAR} " + " ) " + " </foreach> " + "</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);
以上就是springboot中怎么实现通过后台创建临时表的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号