--substr 和 between and
select substr(字段1,0,8) from 表名 t where 字段2 like '%关键字%' and substr(字段1,0,8) between '20100726' and '20100802';
--oracle 日期转字符串
--12小时制(hh)
select to_char(sysdate,'yyyy-mm-dd HH:MI:SS') from dual;
--24小时制(hh24)
select to_char(sysdate,'yyyy-mm-dd HH24:MI:SS') from dual;
--oracle 字符串转日期
--12小时制(hh)
select to_date('2009-5-7 07:09:37','yyyy-mm-dd HH:MI:SS') from dual;
--24小时制(hh24)
select to_date('2009-5-7 07:09:37','yyyy-mm-dd HH24:MI:SS') from dual;
--日期比较
--字符串比较
select * from 表名 where to_char(时间类型的字段,'yyyy-mm-dd hh:mi:ss') like '2010-11-23%';
--时间比较
select * from 表名 where date类型的字段 >= to_date('2010-11-23 00:00:00','yyyy-mm-dd hh24:mi:ss');
--获得字段值的长度
select length('qqq123') from dual;
--系统时间加上一秒钟
select sysdate,sysdate+1/(24*60*60) from dual;
--查找字符
select sysdate,instr(sysdate,'-',1,2) from dual;
注:
在ORACLE/PLSQL中,instr函数返回要截取的字符串在源字符串中的位置。
语法如下:instr(str1,str2,[start_position],[nth_appearance])
str1源字符串,要在此字符串中查找。
str2要在str1中查找的字符串。
start_position代表str1的哪个位置开始查找,此参数可选,默认为1,字符串索引从1开始。如果此参数为正,从左到右开始检索,如果此参数为负,从右到左开始检索,返回要查找的字符串在源字符串的开始索引。
nth_appearance代表要查找第几次出现的str2,此参数可选,默认为1,如果为负数系统会报错。
如果str2在str1中没有找到,instr函数返回0.
--NVL函数
NVL函数的格式如下:NVL(expr1,expr2)
如果oracle第一个参数为空那么显示第二个参数的值,如果第一个参数的值不为空,则显示第一个参数本来的值。
--NVL2函数
NVL2函数的格式如下:NVL2(expr1,expr2, expr3)
如果该函数的第一个参数为空那么显示第三个参数的值,如果第一个参数的值不为空,则显示第二个参数的值。
--NULLIF函数
NULLIF(exp1,expr2)
函数的作用是如果exp1和exp2相等则返回空(NULL),否则返回第一个值
--Coalesce函数
Coalesce(expr1, expr2, expr3….. exprn)
select substr(字段1,0,8) from 表名 t where 字段2 like '%关键字%' and substr(字段1,0,8) between '20100726' and '20100802';
--oracle 日期转字符串
--12小时制(hh)
select to_char(sysdate,'yyyy-mm-dd HH:MI:SS') from dual;
--24小时制(hh24)
select to_char(sysdate,'yyyy-mm-dd HH24:MI:SS') from dual;
--oracle 字符串转日期
--12小时制(hh)
select to_date('2009-5-7 07:09:37','yyyy-mm-dd HH:MI:SS') from dual;
--24小时制(hh24)
select to_date('2009-5-7 07:09:37','yyyy-mm-dd HH24:MI:SS') from dual;
--日期比较
--字符串比较
select * from 表名 where to_char(时间类型的字段,'yyyy-mm-dd hh:mi:ss') like '2010-11-23%';
--时间比较
select * from 表名 where date类型的字段 >= to_date('2010-11-23 00:00:00','yyyy-mm-dd hh24:mi:ss');
--获得字段值的长度
select length('qqq123') from dual;
--系统时间加上一秒钟
select sysdate,sysdate+1/(24*60*60) from dual;
--查找字符
select sysdate,instr(sysdate,'-',1,2) from dual;
注:
在ORACLE/PLSQL中,instr函数返回要截取的字符串在源字符串中的位置。
语法如下:instr(str1,str2,[start_position],[nth_appearance])
str1源字符串,要在此字符串中查找。
str2要在str1中查找的字符串。
start_position代表str1的哪个位置开始查找,此参数可选,默认为1,字符串索引从1开始。如果此参数为正,从左到右开始检索,如果此参数为负,从右到左开始检索,返回要查找的字符串在源字符串的开始索引。
nth_appearance代表要查找第几次出现的str2,此参数可选,默认为1,如果为负数系统会报错。
如果str2在str1中没有找到,instr函数返回0.
--NVL函数
NVL函数的格式如下:NVL(expr1,expr2)
如果oracle第一个参数为空那么显示第二个参数的值,如果第一个参数的值不为空,则显示第一个参数本来的值。
--NVL2函数
NVL2函数的格式如下:NVL2(expr1,expr2, expr3)
如果该函数的第一个参数为空那么显示第三个参数的值,如果第一个参数的值不为空,则显示第二个参数的值。
--NULLIF函数
NULLIF(exp1,expr2)
函数的作用是如果exp1和exp2相等则返回空(NULL),否则返回第一个值
--Coalesce函数
Coalesce(expr1, expr2, expr3….. exprn)
发表评论
-
ORACLE 手工备份与恢复
2013-10-25 09:50 8631、手工冷备 1.1、在非归档模式下,ORACLE只能 ... -
oracle 分页,oracle 随机数
2012-11-16 17:23 854oracle分页 select * from ( sele ... -
Oracle函数next_day
2012-11-14 17:53 1063--获取date日期的下一个星期weekday; next_d ... -
trunc函数截断日期
2012-11-08 14:26 1292截断日期: 先执行命令:alter session set ... -
复杂的SQL语句
2012-10-25 17:30 931--select 语句中执行判断 select sysdate ... -
oracle 密码永不过期
2012-07-06 11:54 16331. 成功安装ORACLE11g后,默认密码有效期为180天, ... -
ORACLE 错误记录
2012-06-29 17:34 8591. ORACL数据库表空间不够,试图增加表空间,之后进行大量 ... -
关于ORA-01034和ORA-27101的一种解决方法(转)
2012-06-29 17:11 19931 先看oracle的监听和oracle的服务是否都启动了。启 ... -
Oracle导出文件
2012-03-13 11:35 936SET echo off --是否显示脚本中正在 ... -
oracle 备份、还原(导入|导出)
2012-01-10 13:42 819下面介绍的是导入导出的实例。 数据导出: 1 将数据库TE ... -
oracle 启动状态介绍
2011-12-09 15:39 13541、startup nomount 读初始化参数文 ... -
oracle日期时间型timestamp相关学习
2011-09-14 15:12 352811、获取系统时间的语句(ssxff6获取小数点后面六位) se ... -
数据库性能优化
2011-07-12 14:14 882Oracle数据库性能优化 ... -
oracle死锁处理
2011-05-05 12:10 631--1.查看数据库中那些用户产生了锁 select usern ... -
ORACLE sysdate 相加减
2011-04-27 16:01 7914加法 select sysdate,add_months ... -
oracle job(定时任务)
2011-04-27 13:53 18281、创建job 使用Submit()过 ... -
Oracle snapshot (快照)
2011-03-28 16:56 2853--在BMS中创建快照日志 create snapshot l ... -
Oracle bug 汇总
2011-03-28 11:33 990database link --访问database link ... -
oracle游标
2011-03-11 16:05 1349一 游标是什么 游标字面理解就是游动的光标。 用数据库 ... -
oracle 包、方法、存储过程
2011-03-11 15:30 942--定义包 create or replace package ...
相关推荐
oracle函数介绍 1 著名函数之单值函数 pdf oracle函数介绍 2 非著名函数之单值函数 pdf oracle函数介绍 3 著名函数之聚合函数 pdf oracle函数介绍 4 非著名函数之聚合函数 pdf oracle函数介绍 5 分析函数简述 ...
oracle 函数大全oracle 函数大全oracle 函数大全oracle 函数大全oracle 函数大全oracle 函数大全oracle 函数大全
oracle函数大全 oracle函数大全 oracle函数大全
postgresql 兼容 oracle 函数, postgresql 兼容 oracle 函数,postgresql 兼容 oracle 函数, postgresql 兼容 oracle 函数
oracle 函数大全 参考函数 手册 速查 chm格式。。。
Oracle函数.chm
oracle函数大全,oracle函数大全,oracle函数大全,oracle函数大全,
Oracle函数.txt Oracle函数.txt Oracle函数.txt
oracle函数大全.chm oracle函数大全.chm
ORACLE函数.pdfORACLE函数ORACLE函数.pdf
ORACLE函数及其用法ORACLE函数及其用法ORACLE函数及其用法ORACLE函数及其用法ORACLE函数及其用法
oracle函数大全,介绍各自oracle函数1111111111111111111
Oracle自定义函数返回一张表。主要用于生成一张等时间间隔的表数据。
Oracle函数大全 Oracle函数大全 Oracle函数大全Oracle函数大全
Oracle函数学习资料,包含各种常用Oracle函数。
oracle函数大全.doc oracle函数大全.doc oracle函数大全.doc oracle函数大全.doc
Ora9iSQL参考手册 oracle函数大全 分类显示 Oracle函数大全 Oracle函数手册 ORACLE九阴真经 oracle知识库 SQLCodes Oracle错误代码与消息解释 SQL语言参考大全
Ora9iSQL参考手册 oracle函数大全 分类显示 Oracle函数大全 Oracle函数手册 ORACLE九阴真经 oracle知识库 SQLCodes Oracle错误代码与消息解释 SQL语言参考大全
DBA日记(第一部),oracle函数介绍(1) 著名函数之单值函数,oracle函数介绍(2) 非著名函数之单值函数,oracle函数介绍(6) 著名函数之分析函数等
oracle函数大全.pdf oracle函数大全.pdf