Oracle基本用法补充学习

来源:互联网 发布:程序员三大浪漫 编辑:程序博客网 时间:2024/06/05 17:05

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.93trunc 截断 trunc(45.926,2)   ----45.92mod 求余 mod(1600,300)    ----100









原创粉丝点击