Oracle 의 instr()함수 응용 및 사용 상세 설명

3089 단어 Oracleinstr()
1.instr()함수 의 형식(속칭:문자 찾기 함수)
형식 1:instr(string 1,string 2)//instr(원본 문자열,대상 문자열)
형식 2:instr(string 1,string 2[,startposition [, nth_appearance])//instr(원본 문자열,대상 문자열,시작 위치,일치 번호)
해석:string 2 의 값 은 string 1 에서 찾 아야 합 니 다.startposition 에서 제 시 된 수치(즉:위치)는 string 1 에서 검색 하고 nth 를 검색 합 니 다.appearance(몇)회 string 2 가 나타 납 니 다.
주:Oracle/PLSQL 에서 인 스 터 함 수 는 원본 문자열 의 위 치 를 되 돌려 줍 니 다.한 번 만 검색 하면 문자 의 시작 부터 문자 의 끝 까지 끝 난 다 는 것 이다.
2.실례
서식 1

 select instr('helloworld','l') from dual; --    :3         “l”   
select instr('helloworld','lo') from dual; --    :4   “lo”  (  )  ,“l”   
select instr('helloworld','wo') from dual; --    :6   “w”       
서식 2

select instr('helloworld','l',2,2) from dual; --    :4      : "helloworld"  2(e)     ,        “l”   
select instr('helloworld','l',3,2) from dual; --    :4      : "helloworld"  3(l)     ,        “l”   
select instr('helloworld','l',4,2) from dual; --    :9      : "helloworld"  4(l)     ,        “l”   
select instr('helloworld','l',-1,1) from dual; --    :9      : "helloworld"    1(d)     ,          “l”   
select instr('helloworld','l',-2,2) from dual; --    :4      : "helloworld"    2(l)     ,          “l”   
select instr('helloworld','l',2,3) from dual; --    :9      : "helloworld"  2(e)     ,        “l”   
select instr('helloworld','l',-2,3) from dual; --    :3      : "helloworld"    2(l)     ,          “l”   
주:MySQL 의 모호 한 조회 like 와 Oracle 의 intr()함수 가 같은 조회 효 과 를 가 집 니 다.다음 과 같다.

MySQL: select * from tableName where name like '%helloworld%';
Oracle:select * from tableName where instr(name,'helloworld')>0; --            


3.인 스 턴 스 캡 처
1、

2、

3、

4、

5、

6、

7、

8、

9、

이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.

좋은 웹페이지 즐겨찾기