优米格
分享有营养的

Oracle ORA-01795: maximum number of expressions in a list is 1000错误解决

BraUndress.png

解决办法有两个:

1.使用INNER JOIN替换IN

例:

SELECT  foo   
FROM    bar   
WHERE bar.stuff IN  
       (SELECT  stuff FROM asdf)

转换为

SELECT  b.foo 
FROM    ( 
        SELECT  DISTINCT stuff 
        FROM    asdf ) a 
JOIN    bar b 
ON      b.stuff = a.stuff

2.多个or连接

select * from table_name
  where
      column_name in (V1,V2,V3,...V1000)
  or
      column_name in (V1001,V1002,V1003,...V2000)
  ...

参考:

  1. java.sql.SQLSyntaxErrorException: ORA-01795: maximum number of expressions in a list is 1000
  2. SQL IN Clause 1000 item limit
赞(3)
未经允许禁止转载:优米格 » Oracle ORA-01795: maximum number of expressions in a list is 1000错误解决

评论 抢沙发

合作&反馈&投稿

商务合作、问题反馈、投稿,欢迎联系

广告合作侵权联系