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)