Oarcle之单行函数(上)
dual 是一个虚表,为了满足sql句式而设置这么一个表
单行函数
字符函数
concat 拼接两个字符串
select concat (concat(ename,‘的职位是’),job) from emp;
initcap将每个单词的首字母大写
select initcap (‘shou zi mu da xie’) from dual;
lower将字符串中的字符小写
select lower (‘DAXIE’ ) from dual;
upper将字符串中的字符大写
select upper(‘xiaoxie’) from dual;
注*:还可以将某一项的变成大写或者小写
例如:select upper/lower(ename) from emp;
length 获取字符串的长度
select ename,length (ename)from emp;
lpad 与 rpad (向左填充与向右填充)
select ltrim('a abccba ','a') from dual;
select rtrim(' abccba aaaa','a') from dual;
replace 替换字符串
select replace('he love you ','he','i')test from dual;
注*:将字符串里面的he用‘i’替换;原来的=======>ilove you