当前位置:网站首页>Oracle intercepts special characters

Oracle intercepts special characters

2022-04-23 21:25:00 Plant a sweet smell

Oracle Character interception

1.substr(varchar2,start_index,sub_length)

####  explain :

  1. varchar2 : String to process
  2. start_index : Intercept starting position
  3. sub_length : Interception length

2.instr(varchar2,char,index,n)

explain :

  1. varchar2 : String to process
  2. char : Characters to search
  3. index : char Character No index position ,index<0, The sign starts on the right

3. Intercept the first part of a special string

select substr('Ajjjjjsss-36kk699-KL3369',0,(instr('Ajjjjjsss-36kk699-KL3369', '-',1, 1)-1)) from dual;

4. Intercept the second half of the string

select substr('AFGLasa-22589assa-KL33dssdd339',instr('AFGLasa-22589assa-KL33dssdd339', '-',2, 2) + 1,length('AFGLasa-22589assa-KL33dssdd339')) from dual;

5. Intercept the middle part of the string

select substr('kjjshgdhbdf-236688sss-sssasdsd89555',instr('kjjshgdhbdf-236688sss-sssasdsd89555', '-',-1, 2) + 1,
instr('kjjshgdhbdf-236688sss-sssasdsd89555', '-', -1, 1) -(instr('kjjshgdhbdf-236688sss-sssasdsd89555', '-', -1, 2) + 1)) from dual;

版权声明
本文为[Plant a sweet smell]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/110/202204200619557042.html