zoukankan      html  css  js  c++  java
  • oracle instr函数

    oracle instr函数 

    在oracle PL/SQL中,instr函数返回string2在string1中出现的位置,语法如下:

    instr(string1,instring2[,start_position[,nth_appearance]])
    string1:被搜索的字符串
    string2:在string1里面寻找的字符串
    start_position:从string1中开始搜索的位置,这是个可选参数,默认为1。
     sting1中第一个字符的位置为1。如果这个参数为一个负数,那么搜索将从string1的末尾开始,并向string1的开始位置进行搜索。
    nth_appearance:string2在string1中出现的次数,这是一个可选参数,默认值为1.
    注意:如果string2未在string1中出现,那么instr函数的返回值为0。

    实例
    1.从起始位置开始搜索,第一次出现子串的位置
    SQL> select instr('chen_linbo_bobo12082119','bo',1,1) from dual;
    INSTR('CHEN_LINBO_BOBO12082119
    ------------------------------
                                 9
    SQL> select instr('chen_linbo_bobo12082119','bo') from dual;
    INSTR('CHEN_LINBO_BOBO12082119
    ------------------------------
                                 9

    2.从后往前搜索,第二次出现子串的位置
    SQL> select instr('chen_linbo_bobo12082119','bo',-1,1) from dual;
    INSTR('CHEN_LINBO_BOBO12082119
    ------------------------------
                                14
    SQL> select instr('chen_linbo_bobo12082119','bo',-1) from dual;
    INSTR('CHEN_LINBO_BOBO12082119
    ------------------------------
                                14

    3.从指定位置开始搜索
    SQL> select instr('chen_linbo_bobo12082119','bo',7,3) from dual;
    INSTR('CHEN_LINBO_BOBO12082119
    ------------------------------
                                14
    SQL> select instr('chen_linbo_bobo12082119','bo',10,3) from dual;
    INSTR('CHEN_LINBO_BOBO12082119
    ------------------------------
                                 0

  • 相关阅读:
    版本号中Snapshot的含义
    Spring Security 过滤器链
    Spring Security入门
    签个到
    Centos下Mysql密码忘记解决办法
    idea 修改静态资源不需要重启的办法
    X509证书信任管理器类的详解
    一、DES加密和解密
    Spring Boot中的事务管理
    SpringBoot JPA实现增删改查、分页、排序、事务操作等功能
  • 原文地址:https://www.cnblogs.com/BetterWF/p/2556444.html
Copyright © 2011-2022 走看看