一、数据样例

二、劈开单行

SELECT id_,REGEXP_SUBSTR(name_, '[^,]+', 1, rownum) h2
FROM (select id_,name_ from test_reg_count t
where t.id_ =2 )
CONNECT BY level <= length(name_)-length(replace(name_,',',''))+1; --或者
SELECT id_,REGEXP_SUBSTR(name_, '[^,]+', 1, rownum) h2
FROM (select id_,name_ from test_reg_count t
where t.id_ =2 )
CONNECT BY REGEXP_SUBSTR(name_, '[^,]+', 1, rownum) is not null;

三、劈开多行

SELECT id_,REGEXP_SUBSTR(name_, '[^,]+', 1, level) name_
FROM test_reg_count
CONNECT BY level <= length(name_)-length(replace(name_,',',''))+1
AND name_ = PRIOR name_
AND PRIOR dbms_random.value <1; --或者
SELECT id_,REGEXP_SUBSTR(name_, '[^,]+', 1, level) name_
FROM test_reg_count
CONNECT BY level <= length(name_)-length(replace(name_,',',''))+1
AND name_ = PRIOR name_
AND PRIOR SYS_GUID() is not null;

这里最重要的是 prior操作符,关于prior的解释Oracle的官方文档是这么描述的:

  In a hierarchical query, one expression in the CONNECT BY condition must be qualified by the PRIOR operator. If the CONNECT BY condition is compound, then only one condition requires the PRIOR operator, although you can have multiple PRIOR conditions. PRIOR evaluates the immediately following expression for the parent row of the current row in a hierarchical query.

  PRIOR is most commonly used when comparing column values with the equality operator. (The PRIOR keyword can be on either side of the operator.) PRIOR causes Oracle to use the value of the parent row in the column. Operators other than the equal sign (=) are theoretically possible in CONNECT BY clauses. However, the conditions created by these other operators can result in an infinite loop through the possible combinations. In this case Oracle detects the loop at run time and returns an error.

Oracle SQL 劈开字符串的更多相关文章

  1. Oracle sql 子字符串长度判断

    Oracle sql 子字符串长度判断 select t.* from d_table t ,) ,instr(t.col,; 字符串的前两位都是数字: select * from d_table t ...

  2. Oracle SQL判断字符串是否在目标字符串中的函数

    转自:http://dacoolbaby.iteye.com/blog/1772156 根据需求,写了一段方法. 用于识别以下的情况: 判断 字符串A  在用逗号分隔的字符串B中是否存在 如: v_s ...

  3. 处理 Oracle SQL in 超过1000 的解决方案

    处理oracle sql 语句in子句中(where id in (1, 2, ..., 1000, 1001)),如果子句中超过1000项就会报错.这主要是oracle考虑性能问题做的限制.如果要解 ...

  4. Oracle SQL 优化原则(实用篇)

    由于SQL优化优化起来比较复杂,并且还受环境限制,在开发过程中,写SQL必须遵循以下几点原则: 1.Oracle 采用自下而上的顺序解析WHERE子句,根据这个原理,表之间的连接必须写在其他Where ...

  5. [Oracle] SQL*Loader 详细使用教程(2)- 命令行参数

    sqlldr工具   SQL*Loader的客户端工具是sqlldr,在操作系统的命令行下输入sqlldr,后面不接任何参数,将显示帮助信息如下所示(所有命令行参数的简单描述及其默认值),所以你并不需 ...

  6. oracle sql日期比较

    oracle sql日期比较:在今天之前: select * from up_date where update < to_date('2007-09-07 00:00:00','yyyy-mm ...

  7. oracle中一个字符串包含另一个字符串中的所有字符

    oracle中一个字符串包含另一个字符串中的所有字符 --解决监理报告中所勾选的标段信息,与该用户所管理的标段字符串不匹配的问题. select * from a where instr(a,b)&g ...

  8. oracle 插入含&字符串

    1.创建表 SQL> create table t(id number,name varchar2(20)); 表已创建. 2.常规方式插入 SQL> insert into t valu ...

  9. Oracle SQL in 超过1000 的解决方案

    处理 Oracle SQL in 超过1000 的解决方案 处理oracle sql 语句in子句中(where id in (1, 2, ..., 1000, 1001)),如果子句中超过1000项 ...

随机推荐

  1. JPasswordField 中得到的字符数组转化为字符串(密码乱码问题)

    转载自:http://blog.csdn.net/skl_tz/article/details/9009805 JPasswordField 用作密码的输入框,似乎很方便,但是,为了得到输入的内容,一 ...

  2. 转: 在线office的协作工具列表

    产品完备性.协作功能.功能完备性对比 &lt;img src="https://pic2.zhimg.com/af14a86eedcb93962e41e47788de5989_b.p ...

  3. 一分钟加入google站内搜索代码

    一分钟加入google站内搜索代码| 一分钟加入google站内搜索代码|只有7行最精简.网上有很多 google 站内搜索代码,但是出于某些目的,很多都加入了多余的代码,从seo的角度来讲,是很不优 ...

  4. Sharepoint 2013 安装部署系列篇 第二篇 -- SQL集群安装

    第一部分 系统集群安装. 第三部分 安装和配置网络负载均衡在前端web服务器 第四部分 安装和配置sharepoint 场(三层拓扑部署) 以下图片均为sharepoint 2010..由于本人的笔记 ...

  5. iOS10.1不能调试解决方案

    对于一些有强迫证的程序员来说只要苹果更新系统,会马上更新,但是军哥更新过10.1的系统后发现Xcode8不能调试了 苹果这次太不人性话了,解决办法,最简单的是 拷贝iOS10.1支持文件放在Xcode ...

  6. css隐藏元素display:none,opacity:0;filter:alpha(opacity=0-100;,visibility:hidden的区别

    在CSS中,让元素隐藏(指屏幕范围内肉眼不可见)的方法很多,有的占据空间,有的不占据空间:有的可以响应点击,有的不能响应点击.我们一般有三种方式:display:none, opacity:0;fil ...

  7. 地图 ajax-数据库

    通过数据库和ajax方法写出地图 客户端部分:html.js.css代码部分: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transit ...

  8. 第一个过滤器Filter

    过滤器实现Filter接口javax.servlet.Filter package com.henau.example; import java.io.IOException; import java ...

  9. CSS3 照片墙

    HTML <body> <h2>照片墙制作</h2> <div class="container"> <img class=& ...

  10. 代码研磨 Slim v3 (一)--app->get()&route->add()

    index.php代码如下: $app->get('/forbase', function ($request, $response, $args){ Example\Module\Base:: ...