对IN()的限制

时间:2013-10-10 19:27:56

标签: sql oracle11g

SQL查询中IN()内传递的值的数量有何限制?我一直在网上四处看看,但没有找到我想要的答案?

1 个答案:

答案 0 :(得分:2)

明确规定时,限制为1,000,即:

select * from the_table where id in (1, 2, ..., 1000)

这是documentation on the IN conditon

  

您最多可以在expression_list中指定1000个表达式。

如果没有明确说明,则没有限制:

select * from table1 where id in ( select id from table2 )

虽然有用但通常有更好的方法将这么多或多个值传递给SELECT。可能值得考虑一些描述的参考表或JOIN。

另见: