Oracle_071_lesson_p4

函數

單行函數 single-row functions
多行函數 mutilple-row functions

單行函數:
字符函數
lower 小寫 如where lower(last_name)='HH';
upper 大寫 如where upper(last_name)='hh'; 生產維護中用的比較多
initcap 首字母大寫 如where initcap(last_name)='Test';
concat 連接 類似|| 如concat(last_name,first_name) ,只能2個參數
substr(column,0,4) 從左到右,默認開始位爲1, 此爲輸出4個字符
substr(column,-5,4) 倒數第5位起,取4位輸出
substr(column,4) 從第4位開始取,直到結束
instr(column,'t') 找t在第幾位
length('abc') 此計算輸出字符長度爲3
函數可嵌套,計算是從裏到外的順序

數字函數
round(45.926,2) 四捨五入,此輸出45.93 ,那麼如果round(-45.926) ,輸出是多少呢?
trunc(45.926,2) 只保留小數點後2位,此輸出爲45.92
ceil(2.83) 向上取整,此輸出爲3,那麼如果ceil(-2.83),輸出是多少呢?
floor(2.83) 向下取整,此輸出爲2,那麼如果ceil(-2.83),輸出是多少呢?
mod(1600,300) 求模,即餘數

日期函數
理解此圖:
Oracle_071_lesson_p4
select sysdate from dual;

修改時間格式:alter system set nls_date_format='yyyy-mm-dd hh24:mi:ss' scope=spfile;

Oracle_071_lesson_p4

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章