Oracle substr函數用法

來源:互聯網
上載者:User

Oracle substr函數用法

取得字串中指定起始位置和長度的字串 substr( string, start_position, [ length ] );

substr(字串,截取開始位置,截取長度) //返回截取的字;

start_position為正時,從左往右擷取字串;

start_position為負時,從右往左擷取字串;

start_position為0時,從字串開始位置擷取字串;

 

Examples:

1、start_position = 0

SELECT SUBSTR('hello',0,3) FROM dual; --hel
SELECT SUBSTR('hello',0,6) FROM dual; --hello
SELECT SUBSTR('hello',0,0) FROM dual; --null
SELECT SUBSTR('hello',0) FROM dual; --hello

2、start_position > 0

SELECT SUBSTR('hello',1,0) FROM dual; --null
SELECT SUBSTR('hello',1,2) FROM dual; --he
SELECT SUBSTR('hello',1,6) FROM dual; --hello
SELECT SUBSTR('hello',1) FROM dual; --hello

3、start_position < 0

SELECT SUBSTR('hello',-3) FROM dual; --'llo'
SELECT SUBSTR('hello',-1) FROM dual; --'o'
SELECT SUBSTR('hello',-3,2) FROM dual; --'ll'
SELECT SUBSTR('hello',-7) FROM dual; --null

 

Oracle函數之Replace()

Oracle函數大全

Oracle函數之case和decode的用法區別及效能比較

Oracle函數和預存程序簡單一實例

Oracle函數 通過秒數或分鐘數擷取時間段

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.