在Oracle中,SUBSTR函數(shù)用于從字符串中提取子字符串。
語法:
SUBSTR(string, start_position, [length])
參數(shù)說明:
string:要提取子字符串的字符串。
start_position:指定開始提取的位置,從 1 開始計(jì)數(shù)。
length:可選參數(shù),指定要提取的子字符串的長(zhǎng)度。如果省略該參數(shù),則提取從 start_position 開始到字符串末尾的所有字符。
示例:
SELECT SUBSTR(‘Hello World’, 7) FROM dual;
結(jié)果:‘World’
SELECT SUBSTR(‘Hello World’, 7, 5) FROM dual;
結(jié)果:‘World’
SELECT SUBSTR(‘Hello World’, 7, 3) FROM dual;
結(jié)果:‘Wor’