码迷,mamicode.com
首页 > 数据库 > 详细

oracle字符串提取记录

时间:2018-12-10 19:15:33      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:info   操作   time   str   instr   replace   ams   where   返回   

背景:需要限制用户操作次数,而用户操作次数只有统一的日志表有记录。 并且,因为在批量查询中也需做限制,所有需要一次查询多条数据,保证效率。后来采用视图做的

 

视图

instr 查找字符串,返回起始坐标, 坐标从1开始

substr切割字符串,substr(字符串,起始坐标,长度)

create or replace view v_log as
--用作批量核查时限制次数
select t2."PHONE_NUMBER",t2."TIME",t2."URL",
substr(t2.post_params, instr(t2.post_params, reportTime:)+length(reportTime:), instr(t2.post_params, ,companyName)-instr(t2.post_params, reportTime:)-length(reportTime:)) as reportTime,
substr(t2.post_params, instr(t2.post_params, companyName:)+length(companyName:), instr(t2.post_params, ,xyCode)-instr(t2.post_params, companyName:)-length(companyName:)) as companyName,
substr(t2.post_params, instr(t2.post_params, xyCode:)+length(xyCode:), instr(t2.post_params, ,zb)-instr(t2.post_params, xyCode:)-length(xyCode:)) as xyCode,
substr(t2.post_params, instr(t2.post_params, ,zb:)+length(,zb:), instr(t2.post_params, ,value)-instr(t2.post_params, ,zb:)-length(,zb:)) as zb,
substr(t2.post_params, instr(t2.post_params, ,type:)+length(,type:), length(t2.post_params)-instr(t2.post_params, ,type:)-length(,type:)) as type
from user_log t2
where t2.url like %/check/single;

 

查询结果

技术分享图片

 

oracle字符串提取记录

标签:info   操作   time   str   instr   replace   ams   where   返回   

原文地址:https://www.cnblogs.com/lurenjia1994/p/10098106.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!