Oracle内置函数内容整理
--绝对值
select abs(-100) from dual;
--取余
select mod(8,3) from dual;
--取整,大于该数的最小整数(上限值)
select ceil(12.0) from dual;
select ceil(12.5) from dual;
--取整,小于该数的最大整数(下限值)
select floor(12.5) from dual;
--四舍五入,选择需要保留的小数位
select round(12.456,0) from dual;
--截取小数,输入需要保留的小数位数,最多保留最大长度,也可取整
select trunc(12.456,1) from dual;
--截取长度
select length('abcdefg') from dual;
select xingm,length(xingm) from t_hq_ryxx;
--截取字符串,第1个数为截取位置,正数从做开始算,负数从右边开始算,第二个数为截取长度,截取位置超过字符长度的为空
select xingm,substr(xingm,0,1) from t_hq_ryxx;
--字符串连接
select concat('ab',concat ('cd','efg')) from dual;
select 'ab' || 'cd' || 'efg' from dual;
--查找,可以指定起始位置
select instr('abcdefg','d') from dual;
select instr('adcdefg','d',1) from dual;
select instr('abcdefg','h') from dual;
--转换大小写,首字母转换大写
select upper('assa'),lower('ASDF') from dual;
select upper('assa'),lower('ASDF'), initcap('this is a test') from dual;
--替换
select replace('abcdefg','ab','123') from dual;
--update t_hq_ryxx set xingm = replace(xingm,'额','阿') where xingm like '额%';
--填充,没有的用空格填充,从往有填充,往左填充
select rpad('aa',8,'c') from dual;
select lpad('aa',8) from dual;
--去空格
select trim (' abcde ') from dual;
--去右边的空格
select rtrim (' abcde ') from dual;
--去首部字符
select trim (leading 'a' from 'aabcde ') from dual;
--去后部字符
select trim (trailing 'a' from 'aabcdea') from dual;
--去前后字符
select trim (both 'a' from 'aabacdea') from dual;
--当前系统时间
select sysdate from dual;
--修改当前月份
select add_months(sysdate,-2) from dual;
--取月份的最后一天,修改天数
select last_day(sysdate)+1 from dual;
--转换函数
select cast('123' as number) +123 from dual;
select cast(123 as varchar2(3)) + 147 from dual;
select '123' +123 from dual;
select to_char(sysdate,'yy-dd-mm') from dual;
select to_char(sysdate,'yyyy-dd-mm hh24:mi:ss') from dual;
--四舍五入
select to_char(123.456,'999.9') from dual;
--转换日期
select to_date('2015-12-23 04:13:25','yyyy-mm-dd hh24:mi:ss') +1 from dual;
update t_hq_ryxx set ruzrq = to_date('24-10-2015','dd-mm-yyyy') where bianh = 107;
select * from t_hq_ryxx where ruzrq > to_date('2015-10-22','yyyy-mm-dd');
--转换数字格式
select to_number('123.456','999.999') from dual;
--null函数
--select nvl(nianl,54) from t_hq_ryxx;
--非空的替换成20,空值为1000
--select nvl2(nianl,20,1000) from t_hq_ryxx;
--空值替换成0
--select nvl(nianl,0) + gongz from t_hq_ryxx
--提出符合条件的内容
select * from t_hq_ryxx where lnnvl(nianl > 20);
Oracle内置函数内容整理的更多相关文章
- oracle 内置函数 least decode
在博客园的第一个博客,为什么叫第一个.... oracle 内置函数 east(1,2,3,4.....) 可以有多个值,最多几个?不知道欢迎补充 ,,,) from dual 这个函数返回是1,就是 ...
- SQL入门(2): Oracle内置函数-字符/数值/日期/转换/NVL/分析函数与窗口函数/case_decode
本文介绍Oracle 的内置函数. 常用! 一. 字符函数 ASCII 码与字符的转化函数 chr(n) 例如 select chr(65) || chr(66) || chr(67) , ch ...
- Oracle内置函数:时间函数,转换函数,字符串函数,数值函数,替换函数
dual单行单列的隐藏表,看不见 但是可以用,经常用来调内置函数.不用新建表 时间函数 sysdate 系统当前时间 add_months 作用:对日期的月份进行加减 写法:add_months(日期 ...
- ORACLE 内置函数之 GREATEST 和 LEAST(转)
Oracle比较一列的最大值或者最小值,我们会不假思索地用MAX和MIN函数,但是对于比较一行的最大值或最小值呢?是不是日常用的少,很多人都不知道有ORACLE也有内置函数实现这个功能:COALESC ...
- oracle——学习之路(oracle内置函数)
oracle与很多内置函数,主要分为单行函数与集合函数. 首先要提一下dual表,它oracle的一个表,没有什么实质的东西,不能删除它,否则会造成Oracle无法启动等问题,他有很大用处,可以利用它 ...
- python: 基本数据类型 与 内置函数 知识整理
列表 list.append(val) #末尾追加,直接改变无返回 list.inert(2,val) #插入到指定位置 list.extend(mylist1) #list会被改变 list2=li ...
- Oracle内置函数
单行函数:当查询表或试图时每行都能返回一个结果,可用于select,where,order by等子句中. 对于没有目标的select查询用dual表,这个表时真实存在的,每个用户都可以读取. 单行函 ...
- Oracle内置函数SQLCODE和SQLERRM的使用
在我们写proc程序中经常要有错误处理,在错误处理中我们经常要输出错误信息来给帮助我们分析和解决错误原因,从而更正数据.这时候就会用到SQLCODE和SQLERRM. SQLCode:数据库操作的返回 ...
- Oracle 内置函数
三. 字符函数(可用于字面字符或数据库列) 1,字符串截取 select substr('abcdef',1,3) from dual 2,查找子串位置 select instr('abcfdgfdh ...
随机推荐
- Docker-利用dockerfile来搭建tomcat服务
在前面的例子中,我们从下载镜像,启动容器,在容器中输入命令来运行程序,这些命令都是手工一条条往里输入的,无法重复利用,而且效率很低.所以就需要一 种文件或脚本,我们把想执行的操作以命令的方式写入其中, ...
- 统一事件源epoll代码示例
可以将信号注册进pipe管道的写端,通过对读端的监听,来实现统一事件源. #include <sys/types.h> #include <sys/socket.h> #inc ...
- Gas Station
Description: There are N gas stations along a circular route, where the amount of gas at station i i ...
- 转:copy initialization
转自: http://en.cppreference.com/w/cpp/language/copy_initialization copy initialization C++ C++ la ...
- Bootstrap列表
一.HTML的列表 在HTML文档中,列表结构主要有三种:有序列表.无序列表和定义列表.具体使用的标签说明如下: 1.无序列表 <ul> <li>…</li> &l ...
- org.apache.hadoop.hbase.TableExistsException: hbase:namespace
Problem is here : https://community.cloudera.com/t5/Storage-Random-Access-HDFS/HMaster-not-starting- ...
- OpneCV 二值图像区域处理
//--------------------------------------[程序说明]------------------------------------------- // 在图像处理中总 ...
- 无法找到脚本*.VBS的脚本引擎解决办法
当你在运行一些基于VBS脚本语言的文件时,系统可能报错.这时候可能是你的VBS脚本服务在注册表中出错了,原因可能是卸载或安装一些代码不规范的程序引起的.这里给出无法找到脚本引擎"vbscri ...
- mysql spider之拆库无忧
数据库的三板斧 先上MySQL,之后再上读写分离,然后呢? 后面典型的做法是垂直拆库和水平分表. 一旦数据库拆了之后,代价就来了. 1.事务不能跨库了(少,但是很重要,可以适当改写) 2.相关的关联查 ...
- SQL Server 2012清除连接过的服务器名称历史
退出客户端后 SQL Server 2012: 删除这两个地方!请提前备份! X:\Users\XXX\AppData\Roaming\Microsoft\SQL Server Management ...