oracle截取字符串的函数substr的用法
{ Posted on 星期四, 六月 16, 2011
by Kaiser.XKw
}
oracle中,可以用substr函数截取字符串.
语法:
substr( string, start_position, [ length ] )
取子字符串,从start_position开始,取length个,length为可选,如果length为空则返回start_position后的所有字符。
实例:
substr('This is a test', 6, 2) would return 'is'
substr('This is a test', 6) would return 'is a test'
substr('TechOnTheNet', 1, 4) would return 'Tech'
substr('TechOnTheNet', -3, 3) would return 'Net'
substr('TechOnTheNet', -6, 3) would return 'The'
substr('TechOnTheNet', -8, 2) would return 'On'
select substr('TechOnTheNet', -3, 2) from dual
start_position为负数时,表示从字符串尾巴倒着数。
语法:
substr( string, start_position, [ length ] )
取子字符串,从start_position开始,取length个,length为可选,如果length为空则返回start_position后的所有字符。
实例:
substr('This is a test', 6, 2) would return 'is'
substr('This is a test', 6) would return 'is a test'
substr('TechOnTheNet', 1, 4) would return 'Tech'
substr('TechOnTheNet', -3, 3) would return 'Net'
substr('TechOnTheNet', -6, 3) would return 'The'
substr('TechOnTheNet', -8, 2) would return 'On'
select substr('TechOnTheNet', -3, 2) from dual
start_position为负数时,表示从字符串尾巴倒着数。
No Response to "oracle截取字符串的函数substr的用法"
发表评论