求:ORACLE取数的方法

mgan 2006-11-23 07:18:55
一表有3KW左右的数据
表中无特别的标志可区分
由于数据库 segment 不是很大,导致 直接spool取数的时候会报 segment too small 数据导出失败
现在想要分批取数,应该如何实现?
...全文
345 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
kittykula 2006-11-30
  • 打赏
  • 举报
回复
select B.* from (select rownum rn,a.* from test a )B where B.rn between 1 and 100000

需要排序吗?不需要吧
baojianjun 2006-11-30
  • 打赏
  • 举报
回复
1.增加segment空间
2.不想有错误的话可以使用ROWID来处理
mgan 2006-11-29
  • 打赏
  • 举报
回复
虽然如此
但是还是不能作为分批取数的

gwallan 2006-11-29
  • 打赏
  • 举报
回复
mark
doer_ljy 2006-11-29
  • 打赏
  • 举报
回复
rownum和数据库里的实际存储没有任何关系,它是在你的查询完成后自上而下生成的一个连续的数字。
数据库中每条数据头有唯一的rowid,所以排序应该用rowid而不是rownum。
fullish 2006-11-28
  • 打赏
  • 举报
回复
rownum对应数据库里的顺序1,2,3......
而rowid对应于一些字母然后是从A,B,C.....这样的顺序
为什么要用rowid排序呢??? 能指教吗,谢谢
doer_ljy 2006-11-28
  • 打赏
  • 举报
回复
楼上的测试过吗?
如果要用rownum作为过滤条件,需要用子表的。
select * from tablename where rownum between 1001 and 2000 order by rowid
这样的写法可能会出现0条记录返回的情况。
如果一定要使用
如果要用rownum作为过滤条件,需要用子表的。
select * from (select *,rownum rnum from tablename where rownum order by rowid)
where rnum between 1001 and 2000
比较好
shyming 2006-11-27
  • 打赏
  • 举报
回复
spool file1
select * from tablename where rownum between 0 and 1000 order by rowid
spool off;
spool file2
select * from tablename where rownum between 1001 and 2000 order by rowid
spool off;
spool file3
select * from tablename where rownum between 2001 and 3000 order by rowid......
可測試一下,因為排序是按rowid排,其rownum應該會與rowid對應,這樣就不會select重復的或漏掉。。。
mgan 2006-11-25
  • 打赏
  • 举报
回复
select * from tablename where rownum between 0 and 1000 order by rowid
这个要分多次运行
但是oracle的rownum只能在一次查询中使用吧
mgan 2006-11-24
  • 打赏
  • 举报
回复
love_2008(love2008) 的方法 不能分批取

我在UNIX用的spool导数字
shyming 2006-11-24
  • 打赏
  • 举报
回复
分開select,分開spool,最後把文件組合在一起
select * from tablename where rownum between 0 and 1000 order by rowid;
。。。
gw_delphi 2006-11-23
  • 打赏
  • 举报
回复
查询6到10的5条数据
select * from tablename where rownum<=10
minus
select * from tablename where rownum<=5

select * from (select tablename.*, rownum as rid from tablename where rownum<=10) where rid > 5
wangzk0206 2006-11-23
  • 打赏
  • 举报
回复
select * from test where rownum<10000

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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