⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 怎样选取不连续的id.txt

📁 oracle问题集
💻 TXT
字号:
由 cactus 于 01-11-30 09:45 发表: 
 再问一个问题
我的数据表中有一个字段应该存储的连续的值,但是有可能出现某种异常,使记录不连续了,如何判断不连续的记录呢?
比如说,这个字段的值为
1
2
3
4
5
7
8
9
这样,缺少6,就应该把6找出来,如何实现,效率如何?


由 jlandzpa 于 01-11-30 21:32 发表: 
用一个sql不好实现,可以用过程。
__________________
任弱水三千,我独取一瓢饮!
勿以善小而不为,勿以恶小而为之!
不要以为登上了山峰,你就征服了世界!
出差[忙].



由 cactus 于 01-11-30 22:08 发表: 
怎么实现呢?
不会是把表里面的所有数据都选出来,然后一个一个比吧,要知道这可是海量数据啊!


由 easyfree 于 01-11-30 22:35 发表: 
不论sql还是plsql
你当然需要扫描表的这个字段才能找出数据
好像还没有印象哪个数据库会本身提供你要求的这个机制, 它不知道你顺序生成的方式, 它不知道你需要的结果方式, 这种机制是不会设置的
一个sql也可以实现,当然效率自己把握
比如以你这个为例:
select rownum from all_objects where rownum<=(select max(your_col) from 
your_tab)
minus
select your_col from your_tab
/


由 lee lele 于 02-02-24 18:33 发表: 
Hi easyfree,
I just saw your code. It is pretty good. But I have a question for you. I know 
you want to get the sequence from 1 to Max(your_col). why you use all_objects?

Thanks.



--四亿
select rownum from all_objects,all_objects 
where rownum<=(select max(your_col) from your_tab) 
minus 
select your_col from your_tab 

--八万亿
select rownum from all_objects,all_objects ,all_objects
where rownum<=(select max(your_col) from your_tab) 
minus 
select your_col from your_tab 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -