1. 程式人生 > >oracle中substr函式的用法(sqlserver right)

oracle中substr函式的用法(sqlserver right)

 oracle:

語法:

substr(string,a,b):

a:從第幾位開始,第一位a=1,倒數第三位(即sqlserver中的right)a=-3

b:取幾個字元 

    substr('This is a test', 6, 2) would return 'is'
    substr('This is a test', 6) would return 'is a test'
    substr('TechOnTheNet', 1, 4) would return 'Tech'
    substr('TechOnTheNet', -3, 3) would return 'Net'
    substr('TechOnTheNet', -6, 3) would return 'The'
    substr('TechOnTheNet', -8, 2) would return 'On'

sqlserver:

使用RIGHT函式從右邊取得指定個數的字串。
SELECT RIGHT('C:\DATABASE\銷售管理系統.MDF',4)
SELECT RIGHT('C:\DATABASE\銷售管理系統.LDF',4)
執行結果:
.MDF
.LDF