oracle之单行函数1
生活随笔
收集整理的這篇文章主要介紹了
oracle之单行函数1
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
--全部小寫 全部大寫 全部首字母大寫
select lower('ATGUIGUJAVA'),UPPER('ATGUIGU Java'),initcap('ATGUIGU Java')
from dual
--
運行結果
--轉換為小寫查詢 select * from employees where lower(last_name)='king'運行結果
字符控制函數
--拼接 截取 長度 select CONCAT('hello','world'), SUBSTR('helloworld',2,4), LENGTH('helloworld') from dual;運行結果
--判斷字符的位置 沒有返回0 select instr('helloworld','w') from dual運行結果
--座對齊 輸出十位 不足*號補齊 左端補齊 select employee_id,last_name,lpad(salary,10,'*') from employees;運行結果
--在字符里面取出 去除首尾h select trim('h'from 'hhellhoworldh') from dual運行結果
--替換所有的a select replace('abcgavc','a','c') from dual運行結果
--保留數 select round(435.35,2),round(435.35),round(435.35,-2) from dual運行結果
--保留數 截斷 select trunc(435.35,2),trunc(435.35),trunc(435.35,-2) from dual運行結果
--員工工作天數 select employee_id,last_name,trunc(sysdate-hire_date) worked_days from employees;運行結果
--員工工作月數 select employee_id,last_name,(sysdate-hire_date)/30,months_between(sysdate,hire_date) from employees;運行結果
--加上月數2月 減去三月 下個周日 select add_months(sysdate,2),add_months(sysdate,-3),next_day(sysdate,'星期日') from dual運行結果
--每個月倒數第二天來的員工 select last_name,hire_date from employees where hire_date=last_day(hire_date)-1運行結果
--日期函數 按照月份 日期 select round(sysdate,'month'),round(sysdate,'mm'),trunc(sysdate,'hh') from dual運行結果
隱式類型轉換
--轉換 select '12'+2 from dual;運行結果
顯式轉換
--進行日期轉換 select employee_id,hire_date from employees --where hire_date='7-06月-94' where to_char(hire_date,'yyyy-mm-dd')='1994-06-07'運行結果
--進行日期轉換 select employee_id, to_char(hire_date,'yyyy"年"mm"月"dd"日"') from employees --where hire_date='7-06月-94' where to_char(hire_date,'yyyy"年"mm"月"dd"日"')='1994年06月07日'運行結果
--轉換 select to_char(1234567.89,'999,999,999,99') from dual;運行結果
--員工工資 select to_char(1234567.89,'$999,999,999,99') from dual;員工工資
總結
以上是生活随笔為你收集整理的oracle之单行函数1的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 前端学习(1934)vue之电商管理系统
- 下一篇: CSS制作一个半透明边框