oracle基本操作-字符

来源:互联网 发布:苏州收银软件sjzpos 编辑:程序博客网 时间:2024/06/04 19:42

1.字符转大写-UPPER

    select  UPPER('hello') from dual;

2.字符转小写

    select LOWER('Hello') from dual;

ps: oracle 是大小写不敏感的

3.首字母大写

select initcap('hello') from dual;

4.字符拼接

select concat('hello','world') from dual;select 'hello'||'world' from dual;

5.字符串截取

    select substr(str,起始位置,截取数量)    **注意:起始位置 填0或者1 都是指第一个字符**    这里-n的意思是从后面开始数第n个为起始位子              select substr(str,-n,4) from dual;

4.取字符串长度

    select length(str) from  ..

5.字符串替换

    select replace(str,str中的字符,替换之后的字符) from dual;    如果字符不在str中,则不替换

6.字符串填充

--左填充select lpad('hi',10,'*') from dual;--右填充(rpad)

7.字符串查找

select instr('111222333','22') from dual;--查找结果INSTR('111222333','22')-----------------------                      4
原创粉丝点击