標籤:acl tca 集合 轉寄 cap 日期 floor 語句 oracle資料庫
一、運算子
算術運算子:+ - * / 可以在select 語句中使用
串連運算子:|| select deptno|| dname from dept;
比較子:> >= = != < <= like between is null in
邏輯運算子:not and or
集合運算子: intersect ,union, union all, minus
要求:對應集合的列數和資料類型相同
查詢中不能包含long 列
列的標籤是第一個集合的標籤
使用order by時,必須使用位置序號,不能使用列名
二、時間相關
select to_char(to_date(‘2016-12-22‘,‘yyyy-mm-dd‘),‘day‘) from dual; --指定時間是周幾
select floor(sysdate - to_date(‘20020405‘,‘yyyymmdd‘)) from dual; --兩個日期間的天數
select TO_CHAR(SYSDATE,‘DDD‘),sysdate from dual; --一年的第多少天
--目前時間的時分秒(oracle資料庫時間哦)
三. 字元函數(可用於字面字元或資料庫列)
select instr(‘abcfdgfdhd‘,‘fd‘) from dual;--截取 4
select ‘HELLO‘||‘hello world‘ from dual;--拼接 HELLOhello world
select ltrim(‘ abc‘) s1,rtrim(‘zhang ‘) s2,trim(‘ zhang ‘) s3 from dual--;去掉空格
select trim(leading 9 from 9998767999) s1,trim(trailing 9 from 9998767999) s2,trim(9 from 9998767999) s3 from dual;--去掉前後墜
select ascii(‘a‘) from dual;--轉ascii
select chr(97) from dual;--擷取字母
select length(‘abcdef‘) from dual;--計算長度
select lower(‘ABC‘) s1,upper(‘def‘) s2, initcap(‘efg‘) s3 from dual; --initcap(首字母變大寫) ,lower(變小寫),upper(變大寫)
select translate(‘abc‘,‘b‘,‘xc‘) from dual; -- x是1位 結果是axc
select lpad(‘func‘,15,‘=‘) s1, rpad(‘func‘,15,‘-‘) s2 from dual;--lpad [左添充] rpad [右填充](用於控制輸出格式)
decode[實現if ..then 邏輯]
case[實現switch ..case 邏輯]
後面的有時間在完善 整理不易 轉寄請標明出處
oracle常用函數