Oracle常用函式

2021-08-18 17:12:06 字數 2043 閱讀 5312

1.upper

將字元轉為大寫

select

upper

('abddesdamount'

)damount

from

dual

;

2.lower將字串轉為小寫

select

lower

('abddesdamount'

)damount

from

dual

;

3.floor取地板,將某個浮點數取整數部分,丟棄小數部分

select

floor

(23.45)as

amount

from

dual

;

4.

按指定精度捨入

select

round

(55.44,1

)roa

,round

(55.66,1

)roa1

,round

(-55.44,1

)rob

,round

(-55.66,1

)rob1

from

dual

;

時間相關

1.

月份的加減

select

to_char

(add_months

(to_date

('201712'

,'yyyymm'),1

),'yyyymm')a

from

dual;--

月份加1 結果 201801

2.

獲取系統當前時間

select

to_char

(sysdate

,'yyyy-mm-dd day'

)a 

from

dual

;--2018-04-13

星期五

select

to_char

(sysdate

,'yyyy-mm-dd hh24:mi:ss')a

from

dual

;--2018-04-13 10:50:09

3.

字串轉數字

select

to_number

('2000'

)usd

from

dual

;

4.group by hiving ,order by asc (desc) ,substr 

等在這裡不說明了

小技巧1.不足5位前補0

select replace(lpad('123',5),' ','0') from dual

2.隨機時間戳

select to_number(to_char(to_date('2010-01-01', 'yyyy-mm-dd')+dbms_random.value(1,(to_char(sysdate, 'j')-to_char(to_date('2010-01-01', 'yyyy-mm-dd'), 'j'))*24*60*60)/3600/24,'yyyymmddhh24miss'))

from dual;

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常用函式

1.concat c1,c2均為字串,函式將c2連線到c1的後面,如果c1為null,將返回c2.如果c2為null,則返回c1,如果c1 c2都為null,則返回null。他和操作符 返回的結果相同 select concat slobo svoboda username from dualuse...