Oracle 产生序列的 6 种方法
来源:互联网 发布:南风知我意1百度云 编辑:程序博客网 时间:2024/06/01 14:49
方法一:sys@ORCL> select level from dual connect by level<=5; LEVEL---------- 1 2 3 4 5方法二:sys@ORCL> select rownum from dba_objects where rownum<=5; ROWNUM---------- 1 2 3 4 5方法三:sys@ORCL> select to_number(column_value) n from xmltable('1 to 5'); N---------- 1 2 3 4 5方法四: select n from (select 1 v from dual)model dimension by (v) measures (v n) rules ( n[for v from 2 to 5 increment 1] = n[cv(v)-1] + 1 ) sys@ORCL> / N---------- 1 2 3 4 5方法五:with t(n) as ( select 1 from dual union all select n + 1 from t where n < 5)select n from tsys@ORCL> / N---------- 1 2 3 4 5 方法六:create or replace function generator (n pls_integer) return sys.odcinumberlist pipelined is m pls_integer := trunc(n / 10); r pls_integer := n - 10 * m;begin for i in 1 .. m loop pipe row (null); pipe row (null); pipe row (null); pipe row (null); pipe row (null); pipe row (null); pipe row (null); pipe row (null); pipe row (null); pipe row (null); end loop; for i in 1 .. r loop pipe row (null); end loop;end;/alter function generator compile plsql_code_type = native;sys@ORCL> select * from table(generator(5)); N---------- 1 2 3 4 5
By David Lin
2013-06-19
Always be a first-rate version of yourself,insted of a second-rate version of someone else
- Oracle 产生序列的 6 种方法
- Spring-以序列的方式产生主键值(ORACLE)
- oracle中产生固定格式的自增长序列
- ORACLE产生随机数的多种方法分享
- ORACLE产生随机数的多种方法分享
- 在linux shell中使用for遍历产生的递增数字序列的N种方法
- 在linux shell中使用for遍历产生的递增数字序列的N种方法
- 基于MATLAB的m序列产生函数及其调用方法
- 用oracle单独导出序列的两种方法
- 获取Oracle产生的Sequence和Uuid方法
- oracle重置序列方法
- 高并发场景下oracle触发器+序列产生序号的一些现象与思考
- 产生crashdump的三种方法
- js产生随机数的几种方法
- js产生随机数的几种方法
- OC产生随机数的几种方法
- 产生随机数的两种方法
- 产生随机数的两种方法
- line-rate 与traffic-limit 限速区别
- page,request,session,application的区别
- 不懂程序的人如何理解网页的动态与静态之的区别
- 简译《Dissecting SQL Server Execution Plans》——连载总入口
- Rabbitmq教程翻译(六)Remote procedure call (RPC)远程过程调用
- Oracle 产生序列的 6 种方法
- 让Firefox 3.6 显示无效图片
- 现在我知道有什么地方存写一些技术贴了
- 杭电2098
- QT如何编译出带调试信息的qtwebkit库
- 字符驱动
- 浏览器js打印
- 阿里巴巴 网易 开源代码
- 11.PHP生成XML数据,android解析XML案例简介