Oracle函数

一 函数

rownum

oracle生成多行序列 或 left join 右表多条数据只取一条

select rownum from dual connect by rownum<=10;

initcap

-- 驼峰 首字母大写 ,返回字符串并将字符串的第一个字母变为大写

select REPLACE(INITCAP('first_second_three_ttt_dd_tt_ff'),'_','') from dual;  

  

--首字母小写  

select lower(substr('first_second_three',1,1)) || substr(REPLACE(INITCAP('first_second_three'),'_',''),2) from dual;  

wm_concat

-- 多行转为一行

select replace(wm_concat(name),',','|') from test;

select id,wm_concat(name) name from test group by id;

instr

--字符串包含

select * from students where instr(address, 'beijing') > 0;

union 和 union all

union 筛选掉重复的记录,结果集进行排序运算

而 union all 只是简单的将两个结果合并后就返回,union all 要比 union 快很多

start with

是连接条件,其中用PRIOR表示上一条记录,比如 CONNECT BY PRIOR org_id = parent_id;就是说上一条记录的org_id 是本条记录的parent_id

timestamp

1) 插入

insert into tpurview(IPURVIEWID,CPURVIEWNAME,COPERATENAME,IPARENTID,DADDTIME,DEDITTIME,CADDUSER,SLOCK) 
values(3501,'结算设置',null,3500,to_timestamp('2012-07-24 12:26:23','yyyy-mm-dd hh24:mi:ss'),to_timestamp('2012-07-24 12:26:23','yyyy-mm-dd hh24:mi:ss'),'wang',0);

 2) 查询

SELECT * FROM TEST1 WHERE TO_CHAR(TIMESTAMP,'yyyy-MM-dd') >'2021-01-01'

nvl

nvl用法:nvl(arg,value)代表如果前面的arg的值为null那么返回的值为后面的value

nvl(commision,0)

partition by

分组函数,取其他字段

select t.*
from 
    (
        select a.*, ROW_NUMBER() OVER (PARTITION BY 分组列 ORDER BY 组内排序列 DESC) rn 
        from 表名 a
    ) t 
where t.rn = 1

trim

截取两边的字符串

判断是空串

TRIM(era.customer_id) IS NOT NULL )

日期转换时分秒【注意mi 分】

to_char(sysdate,'yyyy-mm-dd,hh24:mi:ss')

prior树的层级关系

--部门层级关系
SELECT
      OON.ORGCODE,oon.orgname,oon.orglevel,oon.orgseq
    FROM
      ORG_ORGANIZATION OON
    --WHERE ORGTYPE = 'company' AND ROWNUM = 1
    START WITH ORGCODE = ''
    CONNECT BY PRIOR PARENTORGID = ORGID

substr

返回:ABC,截取从A开始3个字符

substr("ABCDEFG", 0, 3)

instr

是否包含某个字符

select * from students where instr(address, 'beijing') > 0

length

select lengthb('飘') from dual 

length(string)计算string所占的字符长度:返回字符串的长度,单位是字符

lengthb(string)计算string所占的字节长度:返回字符串的长度,单位是字节

to_number 

查找最大数字

SELECT to_number(REGEXP_REPLACE(SID,'[^-0-9]','')) SID2 FROM table_name ORDER BY SID2 DESC

ASCIISTR

包含汉字的情况

SELECT t.* FROM pub_jk_receivedata t WHERE ASCIISTR(t.businame) LIKE '%\%' 
 

REGEXP_LIKE

不全是数字

SELECT DISTINCT(t.name) FROM pub_jk_receivedata t WHERE NOT  REGEXP_LIKE(t.name, '[[:digit:]]');

二 Oracel  在线版本

https://livesql.oracle.com

转载地址:

Oracle函数_tamosln的博客-CSDN博客_oracle函数(函数列表)

2.特殊的数据表dual_紫色的忧伤123456的博客-CSDN博客(驼峰 在线脚本) 

Union Union all 的区别,以及排序的问题 - 简书 (union和union all的区别)

start with ... connect by 递归查询_tanghuan0827的博客-CSDN博客(start with)

oracle 插入timestamp - Tom1997 - 博客园(insert timestamp)

oracle 以timestamp为条件查询_Alexnul的博客-CSDN博客_oracle timestamp查询(select timestamp)

oracle 空字符串 null 和各种判断当前字段是否为空_eric_za的博客-CSDN博客_oracle 判空(nvl)

oracle表 分组,并查每组第一条_混乱谜零的博客-CSDN博客_分组查询每组取第一条(partition by)

oracle查询当前系统时间不准确可能情况_LDG1998的博客-CSDN博客_oracle系统时间不对

https://www.cnblogs.com/sumsen/archive/2012/05/30/2525767.html (nvl)

https://www.cnblogs.com/gsk99/archive/2011/06/14/2080573.html (substr)

https://blog.csdn.net/jumtre/article/details/38020389 (instr)

https://blog.csdn.net/fengyifei11228/article/details/6072431 (length)

https://www.cnblogs.com/mellowsmile/p/4642306.html (wm_concat)

https://blog.csdn.net/u010825931/article/details/102931661 (to_number)

如何判断oracle数据库的列中有中文数据的三种方式_oracle查询包含中文字符_kangfu_521的博客-CSDN博客

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值