日期:2014-05-16 浏览次数:20440 次
initcap(char) 把每个字符串的首字符换成大写
lower(char) 整个字符串转换成小写upper(char) 整个字符串转换成大写
BYS@bys1>Select lower(ename),upper(ename),initcap(ename) from emp where rownum<3;
LOWER(ENAM UPPER(ENAM INITCAP(EN
---------- ---------- ----------
smith SMITH Smith
allen ALLEN Allen
CONCAT (char1, char2) 连接char1和char2,注意:CONCAT只能连接两个字符串,连接三个将报错。
BYS@bys1>select ename,job,ename,concat(ename,job) from emp where rownum<3;
ENAME JOB ENAME CONCAT(ENAME,JOB)
---------- --------- ---------- -------------------
SMITH CLERK SMITH SMITHCLERK
ALLEN SALESMAN ALLEN ALLENSALESMAN
BYS@bys1>select ename,job,ename,concat(ename,job,ename) from emp where rownum<3;
select ename,job,ename,concat(ename,job,ename) from emp where rownum<3
*
ERROR at line 1:
ORA-00909: invalid number of arguments
||连接符,一大优势是可以在连续符中间添加指定的字符
BYS@bys1>select ename,job,ename,ename||ename||job from emp where rownum<3;
ENAME JOB ENAME ENAME||ENAME||JOB
---------- --------- ---------- -----------------------------
SMITH CLERK SMITH SMITHSMITHCLERK
ALLEN SALESMAN ALLEN ALLENALLENSALESMAN
BYS@bys1>select ename,job,ename,'mingzi '||ename||ename||' gongzuo '||job from emp where rownum<3;
ENAME JOB ENAME 'MINGZI'||ENAME||ENAME||'GONGZUO'||JOB
---------- --------- ---------- -----------------------------------------------
SMITH CLERK SMITH mingzi SMITHSMITH gongzuo CLERK
ALLEN SALESMAN ALLEN mingzi ALLENALLEN gongzuo SALESMAN
length--按照字,可以求字符串长度,也可以求数字的长度
lengthb--按字节
lengthc--unicode的长度
BYS@bys1>select ename,length(ename),sal,length(sal) from emp where rownum<5;
ENAME LENGTH(ENAME) SAL LENGTH(SAL)
---------- ------------- ---------- -----------
SMITH 5 800 3
ALLEN