lpad(字段名,填充长度,填充的字符)
select lpad('1',4,'0') from dual;
rpad(字段名,填充长度,填充的字符)
select rpad('1',4,'0') from dual;
select lower('STUDENT') from dual;
select upper('admin') from dual;
select initcap('admin') from dual;
select length('中国') from dual;
substr(字符串,截取开始位置,截取长度)
select substr('123456789',2,3) from dual;
instr(源字符串, 目标字符串,[ 起始位置, ][匹配序号])
select instr('12345678','56') from dual;
select ltrim(' 00000') from dual;
rtrim()函数和trim()函数。
SELECT CONCAT('hello', ' world') AS TEXT FROM DUAL;
translate(string,from_str,to_str)
SELECT TRANSLATE('abcdefghij','abcdef','123456') FROM dual;
当为汉字时候,会出现乱码,因为中文是双字节字符。
SELECT RPAD('HELLO', 10, '*') FROM DUAL;
REPLACE('string','被替换','替换')
SELECT REPLACE('HE LOVE YOU', 'HE' ,'I') FROM DUAL;
NVL(X, VALUE)
SELECT NVL(NULL, '2') FROM DUAL; SELECT NVL('33', '2') FROM DUAL;
NVL2(X, VALUE1, VALUE2)
SELECT NVL2(NULL, '3', '4') FROM DUAL;
oracle中处理字符串的函数还有许多,我就不一一列举了。