一、数据样例

二、劈开单行

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. PHP提示Deprecated: mysql_connect(): The mysql extension is deprecated的解决方法

    这篇文章主要介绍了PHP提示Deprecated: mysql_connect(): The mysql extension is deprecated的解决方法,是在进行PHP数据库程序开发中常会遇 ...

  2. Linux下MySQL主从同步配置

    Centos6.5 MySQL主从同步 MySQL版本5.6.25 主服务器:centos6.5 IP:192.168.1.101 从服务器:centos6.5 IP:192.168.1.102 一. ...

  3. 20145102 《Java程序设计》第2周学习总结

    20145102 <Java程序设计>第2周学习总结 教材学习内容总结 这章先介绍了基本类型,和其他语言相似,分为short整数(2字节).int整数(4字节).long整数(8字节).f ...

  4. codeforces 590C C. Three States(bfs+连通块之间的最短距离)

    题目链接: C. Three States time limit per test 5 seconds memory limit per test 512 megabytes input standa ...

  5. 关于onsaveinstancestate和 onRestoreInstanceState()

    之所以有这个话题,是因为工作遇到过两个问题.一个问题是页面空白,fragment重复创建.另一个问题是登录页用到了AutoCompleteTextView,调用showDropDown()方法导致cr ...

  6. Windows装机指南

    开发相关: Anaconda整合了很多python的dependency,方便使用

  7. ASP.Net 验证控件 RangeValidator

    RangeValidator 定义和用法 RangeValidator 控件用于检测用户输入的值是否介于两个值之间.可以对不同类型的值进行比较,比如数字.日期以及字符. 注释:如果输入控件为空,验证不 ...

  8. sublime text 3 扩展插件SideBarEnhancements用法教程

    SideBarEnhancements本是增强侧边栏的插件,这里将教大家如何用来做sublime text 3浏览器预览插件,并可自定义浏览器预览的快捷键. 第一步:安装此插件,搜索相关教程,本博客有 ...

  9. backbone.Collection源码笔记

    Backbone.Collection backbone的Collection(集合),用来存储多个model,并且可以多这些model进行数组一样的操作,比如添加,修改,删除,排序,插入,根据索引取 ...

  10. SQL循环

    加群学习:457351423 这里有4000多部学习视频,有需要的欢迎进群学习! declare @temp Table ( nf varchar(50), yf varchar(50), sm va ...