substr('hello world',0,1) //返回结果为 'h' *从字符串第一个字符开始截取长度为1的字符串
substr('hello world',1,1) //返回结果为 'h' *0和1都是表示截取的开始位置为第一个字符
substr('hello world',2,4) //返回结果为 'ello'
substr('hello world',-3,3)//返回结果为 'rld' *负数(-i)表示截取的开始位置为字符串右端向左数第i个字符
测试:
select substr('hello world',-3,3) value from dual;
附:java中substring(index1,index2)的简单用法
作用:从字符串索引(下标)为index1的字符开始截取长度为index2-index1 的字符串。
string str=hello world;
system.out.println(str.substring(0,5));
打印结果为:hello