① lower, 字符串转小写
SQL> select lower(ename) from emp;
SQL> select ename from emp
2 where ename like '_a%' or ename like '_A%';
SQL> select ename from emp
2 where lower(ename) like '_a%';
② upper
SQL> select upper('abc') from dual;
③ substr(字符串, 起始位置, 截取字符数), 从1开始
SQL> select substr('123456', 2, 3) from dual;
SUBSTR
------
234
SQL> select substr(ename, 2, 3) from emp;
④ chr(ASCII码), 转换成对应ASCII对应的字符
SQL> select chr(65) from dual;
CH
--
A
SQL> select chr(65+32) from dual;
CH
--
a
⑤ ascii(字符), 将字符转换成对应的ASCII码
SQL> select ascii('A') from dual;
ASCII('A')
----------
65
⑥ round(
浮点数 [,
四舍五入到哪一位]), 默认为0
SQL> select round(1234.56789) from dual;
ROUND(1234.56789)
-----------------
1235
SQL> select round(1234.56789, 2) from dual;
ROUND(1234.56789,2)
-------------------
1234.57
SQL> select round(1234.56789, -1) from dual;
ROUND(1234.56789,-1)
--------------------
1230
⑦ A. to_char(数字, '格式') 格式化数字,
以指定格式输出字符串; L,本地货币符
SQL> select to_char(sal, '$99,999.9999') from emp order by sal;
TO_CHAR(SAL,'$99,999.9999'
--------------------------
$950.0000
$1,210.0000
$1,250.0000
SQL> select to_char(sal, 'L99,999.9999') from emp order by sal;
TO_CHAR(SAL,'L99,999.9999')
--------------------------------------------
¥950.0000
¥1,210.0000
SQL> select to_char(sal, 'L00,000.0000') from emp order by sal;
TO_CHAR(SAL,'L00,000.0000')
--------------------------------------------
¥00,950.0000
¥01,210.0000
B. to_char(日期, '格式')
SQL> select to_char(sysdate, 'YYYY-MM-DD HH:MI:SS') from dual;
TO_CHAR(SYSDATE,'YYYY-MM-DD HH:MI:SS')
--------------------------------------
2013-08-10 08:18:31
SQL> select to_char(sysdate, 'YYYY-MM-DD HH24:MI:SS') from dual;
TO_CHAR(SYSDATE,'YYYY-MM-DDHH24:MI:SS'
--------------------------------------
2013-08-10 20:17:53
⑧ to_date(字符串, '格式'), 将
字符串转换成指定格式的日期
SQL> select ename, to_char(hiredate, 'YYYY-MM-DD HH24:MI:SS') from emp
2 where hiredate > to_date('1981-12-03 12:34:56', 'YYYY-MM-DD HH24:MI:SS');
ENAME TO_CHAR(HIREDATE,'YYYY-MM-DDHH24:MI:SS
-------------------- --------------------------------------
SCOTT 1987-04-19 00:00:00
⑨ to_number(带货币符的字符串, '格式')
SQL> select sal from emp
2 where sal > to_number('$1,234.567', '$999,999.999');
SAL
----------
1250
2975
⑩ nvl(参数, 0), 如果参数为NULL, 则返回0
SQL> select ename, sal*12 + comm from emp;
ENAME SAL*12+COMM
-------------------- -----------
BLAKE
CLARK
SCOTT
KING
SQL> select ename, sal*12 + nvl(comm, 0) from emp;
ENAME SAL*12+NVL(COMM,0)
-------------------- ------------------
CLARK 29400
SCOTT 39600
KING 60000