您的位置:首页 > 数据库 > Oracle

Oracle基本用法补充学习

2017-10-23 20:32 351 查看
1字符串函数

(1)大小写转换函数Lower(待转换的字符串),将大写转换成小写

select Lower(ename) from emp ;
(2)将小写转换成大写

select Lower(ename) from emp ;
(3)将字符串的首字母大写

select  initcap(ename) from emp ;
(4)将两个字符串连接起来 (注意只能存在两个字符串)

select concat(ename,'hello') from emp ;
这里需要注意 concat只能连接两个字符串 ,而||可以连接多个字符串
--concat只能连接两个字符串,连接多个需要嵌套调用不方便

SQL> select concat('aa','bb') from dual;

CONCAT('AA','BB')

-----------------

aabb

--||直接连接多个字符串

SQL> select 'aa'||'bb'||'cc' from dual;



(5)截取字符串substr 存在3个参数

select  sub('HelloWorld',1,5) from dual ;


(6)查看字符串的长度length

select length(ename) from emp ;


(7)获得字符串某个字符的下标instr

select  instr('Helloworld',5) from dual ;
(8)补齐字符串Lpad Rpad

select lpad("Hello",'10','*'') from dual  ;
select rpad("Hello",'10','*') from dual ;
(9) trim函数

select trim(H from 'HelloWorld') from dual  ;   ----- elloWorld


(10) replace函数

select replace('abcde','e','o') from dual ;    ------ abcdo
2数字函数

round(45.926,2)    ------ 45.93
trunc 截断 trunc(45.926,2)   ----45.92
mod 求余 mod(1600,300)    ----100
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: