oracle 常用字符串函数
select initcap('guodongdong') from dual; /返回字符串并将字符串的第一个字母变为大写;
select initcap(ename) from scott.emp; /针对scott.emp表中的ename开头全部大写。
select lower(ename) from scott.emp; /针对scott.emp表中的ename名字中全部小写。
select * from scott.emp where lower(ename)='scott'; /以防scott中有大小写。
select upper(ename) from scott.emp; /针对scott.emp表中的ename名字全部大写
select length(ename) from scott.emp; /查询scott.emp表中的ename名字所占的单词个数。
select ename,substr(ename,length(ename)-2) from scott.emp /查询Scott.emp表中的ename名字最后的三个英文名称。
或者 select ename,substr(ename,-3) from scott.emp;
select concat('guo','dongdong') from dual; /CONCAT只能连接两个字符串,没有|| 强大。
select concat(ename,sal) from scott.emp; /针对scott.emp表中的名字个工资做一个连接。
select substr('guodongdong',1,5) from dual; /查询guodongdong,從左邊1-5的单词列出。
select subsrt('guodongdong',-1,5) from dual; /從右邊開始。
select subsrt('guodongdong',-1) from dual; /截取末尾;
select lpad('guodongdong',15,'*') from dual; /显示guodongdong,15表示15为,不够15为则在前方补*。
select rpad('guodongdong',15,'*') from dual; /显示guodongdong,15表示15为,不够15为则在后方补*。
select lpad(ename,length(ename)+30,'*' )from scott.emp;
select lpad (ename,length(ename)+30,'*') from scott.emp;
select rpad (lpad (ename,length(ename)+30,'*'),length(lpad(ename,length(ename) +30,'*')) +30,'*') from scott.emp;
select replace('guodongdong','d','j') from dual; /修改guodongdong,d单词全部替换为j,则是guojongjong
select trim('k' from 'gkgguodonkkgdonggg') from dual; /只要gkgguodonkkgdonggg去除指定字符的前后空格。
ltrim
rtrim
三个主要函数:ROUND,trunc,mod
1: SELECT
round(78915.67823823), 78916,小数点之后的内容直接进行四舍五入
round(78915.67823823,2), 78915.68,保留两位小数
round(78915.67823823,-2), 78900,把不足5的数据取消了
round(78985.67823823,-2), 79000,如果超过了5则进行进位
round(-15.65) ; -16
from dual;
2:截取小数,所有的小数都不进位
SELECT
trunc(78915.67823823), 78916,小数点之后的内容直接进行四舍五入
trunc(78915.67823823,2), 78915.68,保留两位小数
trunc(78915.67823823,-2), 78900,把不足5的数据取消了
trunc(78985.67823823,-2), 79000,如果超过了5则进行进位
trunc(-15.65) ; -16
from dual;
3:求模(求余数)
select mod(10,3) from dual; 得1
最新文章
- [Unity3D]自己动手重制坦克舰队ArmadaTank
- CMPP错误码说明
- jquery .post .get中文参数乱码解决方法详解
- jquery-ui 进度条
- encodeURI和encodeURIComponent的比较
- nyoj_471:好多的树(容斥原理)
- 【原】Java学习笔记010 - 数组
- 常见RPC开源框架
- STM32 一直进入串口接收中断
- 『计算机视觉』Mask-RCNN_推断网络其二:基于ReNet101的FPN共享网络暨TensorFlow和Keras交互简介
- linux命令学习 随笔
- PAT甲题题解-1071. Speech Patterns (25)-找出现最多的单词
- jQuery table td可编辑
- 再springMVC中自定义文件上传处理解决与原spring中MultipartResolve冲突问题
- package.json常用的字段
- MT【155】单调有界必有极限
- Codeforces Round #358 (Div. 2) D. Alyona and Strings dp
- 【C】——压缩字符串
- windows编程之内核对象
- jmeter-BeanShell Sampler
热门文章
- vscode已有64位版本。
- Error: Program type already present: com.google.gson.FieldAttributes 的解决方法
- Java学习必备书籍推荐终极版!
- 分散的配置文件VS集中的注册表
- 使用@JsonFormat引起的时间比正常时间慢8小时解决方法
- Codeforces 985 D - Sand Fortress
- python Django 创建应用
- 第 8 章 容器网络 - 050 - 创建 overlay 网络
- Linux中apt与apt-get命令的区别与解释
- (转)stm32启动文件详解