怎么在mybatis可以创建临时表呢

滚动的轮胎 2016-07-06 12:07:11
现在项目有这样的一个需求:将大量的数据导出到excel文件中。

由于数据量比较大,直接查询大量数据导出会内存溢出,所以我想分批查询,分几次查询和导出。

这过程遇到个问题,Sysbase怎么实现查第5000条到10000条数据?

试过用临时表,想先将第1条到10000条数据放到临时表,然后倒序查第10000条到5000条数据,但是在mybatis可以创建临时表?我下面这样测试,

Xml文件:

<select id="createTemp" >
create table #temp(
Insure_id decimal,
Ins_status char(1),
Book_time datetime null
)
</select>

Dao:

sqlSessionTemplate.selectList(clazz.getName() + ".createTemp");

报错:

Caused by: java.sql.SQLException: The 'CREATE TABLE' command is not allowed within a multi-statement transaction in the 'tempdb' database.
...全文
3187 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
HDU鬼先生 2020-04-29
  • 打赏
  • 举报
回复
我觉得会不会是表名不加能用# 应该用$
打打卡夫卡 2016-12-08
  • 打赏
  • 举报
回复
引用 3 楼 zyshen123 的回复:
回复有点晚了,也是一样的效果,报错Caused by: java.sql.SQLException: The 'CREATE TABLE' command is not allowed within a multi-statement transaction in the 'tempdb' database. 不过,谢谢版主了!
你好。请问你最后怎么解决的
滚动的轮胎 2016-07-13
  • 打赏
  • 举报
回复
回复有点晚了,也是一样的效果,报错Caused by: java.sql.SQLException: The 'CREATE TABLE' command is not allowed within a multi-statement transaction in the 'tempdb' database. 不过,谢谢版主了!
街头小贩 2016-07-07
  • 打赏
  • 举报
回复

    <update id="createNewTable" parameterType="String" > 

        CREATE TABLE IF NOT EXISTS #{value} ( 
                id             INT UNSIGNED        AUTO_INCREMENT PRIMARY KEY, 
        ENGINE=InnoDB DEFAULT CHARSET=utf8; 

    </update > 
街头小贩 2016-07-07
  • 打赏
  • 举报
回复
<select> 可以执行ddl语句

10,606

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 其他
社区管理员
  • 其他
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧