SQL SUBSTRING()函數
SUBSTRING(str,pos)
SUBSTRING(str FROM pos)
SUBSTRING(str,pos,len)
SUBSTRING(str FROM pos FOR len)
格式不帶len參數是從字符串str的pos處開始位置返回一個字符串。用len參數的格式從字符串str從位置pos返回子len個字符。使用FROM形式是標準的SQL語法。另外,也可以使用pos負值。在這種情況下,子字符串的開始是從字符串的末尾,而不是從pos字符開始。負值可用於在任何該函數的pos形式。
SQL> SELECT SUBSTRING('Quadratically',5); +---------------------------------------------------------+ | SSUBSTRING('Quadratically',5) | +---------------------------------------------------------+ | ratically | +---------------------------------------------------------+ 1 row in set (0.00 sec) SQL> SELECT SUBSTRING('foobarbar' FROM 4); +---------------------------------------------------------+ | SUBSTRING('foobarbar' FROM 4) | +---------------------------------------------------------+ | barbar | +---------------------------------------------------------+ 1 row in set (0.00 sec) SQL> SELECT SUBSTRING('Quadratically',5,6); +---------------------------------------------------------+ | SUBSTRING('Quadratically',5,6) | +---------------------------------------------------------+ | ratica | +---------------------------------------------------------+ 1 row in set (0.00 sec)