
字符函数,顾名思义,操作的就是字符串。通过下图,我们来了解一下Oracle的字符函数。

一、大小写控制函数
|
1
2 |
select
lower(
'Hello World'
) 转小写,upper(
'Hello World'
) 转大写,initcap(
'hello world'
) 首字母大写
from dual; |
二、字符控制函数
|
1 |
select
substr(
'Hello World'
,3) from dual; |
|
1 |
select
substr(
'Hello World'
,3,4) from dual; |
|
1
2
3
4
5 |
--对于英文来说,字符数和字节数一样
select
length(
'Hello World'
) 字符, lengthb(
'Hello World'
) 字节 from dual;
--对于中文来说,一个字符数等于两个字节数
select
length(
'中国'
) 字符, lengthb(
'中国'
) 字节 from dual; |
|
1 |
select
instr(
'Hello World'
,
'll'
) 位置 from dual; |
|
1 |
select
lpad(
'abcd'
,10,
'*'
) 左,rpad(
'abcd'
,10,
'*'
) 右 from dual; |
|
1 |
select
trim(
'H'
from
'Hello WorldH'
) from dual; |
|
1 |
select
replace(
'Hello World'
,
'l'
,
'*'
) from dual; |
