06oracle学习笔记(03 单行函数)

本文详细介绍了Oracle数据库中的单行函数,包括字符串函数、数值函数、日期函数等,是学习Oracle数据库的重要笔记。
摘要由CSDN通过智能技术生成
--单行函数
/*
  字符函数
*/
--小写转大写 upper()
select upper('hello accp!') from dual ;


--大写转小写 lower()
select lower('HELLO ACCP!') from dual ;


--单词首字母大写,其余小写 initcap()
select initcap('hello accp!') from dual ;


--返回指定字符串的十进制数 ascii()
select ascii('\') ,ascii('n') n from dual ;


--返回指定整数对应的字符串 chr()
select chr(54740) zhao from dual ;

--字符串连接 concat()
select concat('0512-','88889999') from dual ;

--搜索指定字符串 instr(content,search,startindex,index)
select instr('hello accp welcome to you !','o',6,2) from dual ;

--返回字符串的长度 length()
select length('hello accp!') from dual ;

--粘贴字符 lpad(),rpad() 在左边或右边插入指定字符(根据指定返回结果长度循环插入指定字符)
select lpad(rpad('gao',10,'*'),17,'*') from dual ; --结果 *******gao*******
select rpad('hello',15,'accp') from dual ; --结果 helloaccpaccpac

--删除字符串 ltrim() rtrim() trim()
select '  accp  ' str from dual ;
select ltrim('  accp  ') str from dual ;
select rtrim('  accp  ') str from dual ;
select ltrim(rtrim('  accp  ',' '),' ') str from dual ;
select trim(' ' from '  accp  ') str from dual ;

--截取字符串 substr(str,startIndex,length)
select substr('hello accp!',1,7) str1,substr('hello accp!',0,7) str2 from dual ; 
--结果一样都是hello a

--查询雇员姓名的最后三个字母
select substr(ename,-3,3) ename from emp ;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值