connect by \ instr() \bulk connect
connect by
connect by 函数一般用于查询树形结构或父子关系的数据,与start with [condition]结合使用,按照分层去查询,其中start with 是分层查询的条件
select * from table start with [condtion] connect by [prior] column = parentColumn
树形结构部门
查询“营业部” 及其子部门的所有部门
select * from department start with department_id='01' connect by prior department_id =parent_id
Instr(‘源字符串’,‘目标字符串’) 俗称字符串查找函数
- Instr(‘源字符串’,‘目标字符串’)
-- 默认第一次出现目标字符串的位置
select instr('helloworld','l') from dual
-- 默认第一次出现目标字符串中第一个字符的位置
select instr('helloworld','lo') from dual
- Instr(‘源字符串’,‘目标字符串’,‘起始位置’,‘匹配序号’)
-- 查找字符串中从第二位置开始查找第二次出现的位置
select instr('helloworld','l',2,2) from dual
bulk collect
通过bulk collect减少loop处理的开销, 使用Bulk Collect提高Oracle查询效率,可以在select into,fetch into,returning into语句使用bulk collect。