gpt4 book ai didi

java - RowNum 行为

转载 作者:行者123 更新时间:2023-12-02 11:56:23 31 4
gpt4 key购买 nike

我的表中有 6442670 条记录,我正在使用以下命令获取它们jdbctemplate 使用行号一次 1000000 个。以下是查询

select * 
from (select rowNum rn
, e.*
from table_name e) table_name
where rn >= ? and rn <= ?

我正在八次迭代中获取

  • 0 to 1000000
  • 1000001 to 2000001
  • 2000002 to 3000002
  • 3000003 to 4000003
  • 4000004 to 5000004
  • 5000005 to 6000005
  • 6000006 to 7000006
  • 6442669 to 7442669

经过八次迭代后,我在列表中只看到 6442668 条记录,其中大部分都是重复的。使用rowNum获取记录可以多次获取同一条记录吗?

最佳答案

尝试在 个唯一列上使用 row_number() 而不是 ROWNUM

SELECT *
FROM (SELECT row_number() OVER ( ORDER BY unique_column_s ) rn, e.*
FROM table_name e ) table_name
WHERE rn >= ? and rn <= ?

关于java - RowNum 行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47574496/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com