Oracle中INSTR,SUBSTR方法

來源:互聯網
上載者:User

INSTR方法的格式為
INSTR(源字串, 目標字串, 起始位置, 匹配序號)

例如:INSTR('CORPORATE FLOOR','OR', 3, 2)中,源字串為'CORPORATE FLOOR', 目標字串為'OR',起始位置為3,取第2個匹配項的位置。

預設尋找順序為從左至右。當起始位置為負數的時候,從右邊開始尋找。

所以SELECT INSTR('CORPORATE FLOOR', 'OR', -1, 1) "Instring" FROM DUAL的顯示結果是

Instring
——————
14


Oracle的substr函數的用法
取得字串中指定起始位置和長度的字串   substr( string, start_position, [ length ] )
如:
     substr('This is a test', 6, 2)     would return 'is'
     substr('This is a test', 6)     would return 'is a test'
     substr('TechOnTheNet', -3, 3)     would return 'Net'
     substr('TechOnTheNet', -6, 3)     would return 'The'select substr('Thisisatest', -4, 2) value from dual

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.