oracle中substr的使用方法是什么

2024-04-15

Oracle中,SUBSTR函数用于提取字符串的子串。其语法如下:

SUBSTR(string, start_position, length)
  • string是要提取子串的字符串。
  • start_position是子串的起始位置,从1开始计数。
  • length是要提取的子串的长度。如果不指定length,则会返回从start_position到字符串末尾的所有字符。

例如,假设我们有一个字符串'Hello World',我们想要提取World这个子串,可以这样写:

SELECT SUBSTR('Hello World', 7) FROM dual;

这将返回World