oracle常用函式

2021-06-05 13:06:09 字數 1625 閱讀 6313

1.concat(,)

c1,c2均為字串,函式將c2連線到c1的後面,如果c1為null,將返回c2.如果c2為null,則返回c1,如果c1、c2都為null,則返回null。他和操作符||返回的結果相同

select concat('slobo ','svoboda') username from dualusername  slobo syoboda

2. initcap()

c1為一字串。函式將每個單詞的第乙個字母大寫其它字母小寫返回。單詞由空格,控制字元,標點符號限制。

select initcap('veni,vedi,vici') ceasar from dualceasar veni,vedi,vici

3.length()

c1為字串,返回c1的長度,如果c1為null,那麼將返回null值。

select length('ipso facto') ergo from dualergo10

4.返回c的小寫字元,經常出現在where子串中

select lower(colorname) from itemdetail where lower(colorname) like '%white%'colornamewinterwhite

5.ltrim(,)

把c1中最左邊的字元去掉,使其第乙個字元不在c2中,如果沒有c2,那麼c1就不會改變。

select ltrim('mississippi','mis') from dualltrppi

6.rtrim(,)

把c1中最右邊的字元去掉,使其第後乙個字元不在c2中,如果沒有c2,那麼c1就不會改變。

7.replace(,[,])

c1,c2,c3都是字串,函式用c3代替出現在c1中的c2後返回。

select replace('uptown','up','down') from dualreplace downtown

8.stbstr(,<i>[,])

c1為一字串,i,j為整數,從c1的第i位開始返回長度為j的子字串,如果j為空,則直到串的尾部。

select substr('message',1,4) from dualsubsmess 

9.translate(,,)

將c1中與c2相同的字元以c3代替

select translate('fumble','uf','ar') test from dualtextramble 

10.upper()

返回c1的大寫,常出現where子串中

select name from dual where upper(name) like 'ki%'nameking

11.abs()

返回n的絕對值

12.ceil()

返回大於或等於n的最小整數。

13.mod()

返回n1除以n2的餘數,

14.round(,)

返回捨入小數點右邊n2位的n1的值,n2的預設值為0,這回將小數點最接近的整數,如果n2為負數就捨入到小數點左邊相應的位上,n2必須是整數。

select round(12345,-2),round(12345.54321,2) from dualround(12345,-2) round(12345.54321,2)12300 12345.54

Oracle常用函式

一 row number over 資料甲 1 select column name column name,data type,2 row number over partition by column name order by column name row num 3 from test c...

Oracle常用函式

數學函式 1.絕對值 o select abs 1 value from dual 2.取整 大 o select ceil 1.001 value from dual 3.取整 小 o select floor 1.001 value from dual 4.取整 擷取 o select trun...

Oracle 常用函式

select power 3,2 平方 from dual select round 1000.24432,3 取精度 from dual select floor 1000.54432 取下限不計較四捨五入 from dual select ceil 1000.04432 取上限不計較四捨五入 f...