Oracle MyBatis 提示:java.sql.SQLSyntaxErrorException: ORA-01795: 列表中的最大表达式数为 1000

2023-11-10

产生原因:oracle 使用 in 关键字查询且集合数量大小大于1000

解决办法:

第一种、将集合拆分,使用or 连接。
select * from A where id in (1, 2, …, 1000) or id in (1001, …, 1999)
第二种、将集合修改为查询语句
select * from A where id in (select id from B)
第三种、与 第二种 类似,使用 with  as 语法,把条件封装成一个表
with temp as (select * from B)
select * from A where id in (select id from temp)

推荐使用第二种方式。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Oracle MyBatis 提示:java.sql.SQLSyntaxErrorException: ORA-01795: 列表中的最大表达式数为 1000 的相关文章

随机推荐