随笔分类 -  Oracle

oracle 列转行函数listagg、判断函数decode
摘要:1、decode 使用decode判断字符串是否一样 DECODE(value,if1,then1,if2,then2,if3,then3,...,else) decode(条件,值1,返回值1,值2,返回值2,...值n,返回值n,缺省值) 某些场景可以代替case when 2、listagg 阅读全文

posted @ 2020-03-26 13:28 平平无奇杨小兵 阅读(726) 评论(0) 推荐(0)

case when嵌套
摘要:如果该列字段有为空的值,那么根据另一个字段值去判断结果,可以使用嵌套case when select p.id, p.pay_no, p.pay_status, case when nvl(p.check_result,'-1')='-1' then case when p.pay_status = 阅读全文

posted @ 2020-03-23 11:26 平平无奇杨小兵 阅读(17656) 评论(0) 推荐(0)

sql多表关联更新—用b表字段来更新a表对应的字段
摘要:在开发时,如果遇到表需要加字段,那么需要对存量数据刷新这个字段值 1、mysql --两张表关联 UPDATE JC_COLL_REPAY r INNER JOIN lc_lm_loan l ON r.loan_no = l.loan_no SET r.loan_typ = l.tep_cde, r 阅读全文

posted @ 2020-03-20 14:51 平平无奇杨小兵 阅读(1153) 评论(0) 推荐(0)

按某一列分组并筛选时间最新的一条记录
摘要:方法一: -- 方法1 select a.* from table a where not exists(select 1 from table b where b.id_no=a.id_no and b.crt_time>a.crt_time) 方法二:子查询 -- 方法2 select a.* 阅读全文

posted @ 2020-03-18 16:35 平平无奇杨小兵 阅读(235) 评论(0) 推荐(0)

记一次oracle表空间不足解决方案
摘要:通过存储过程执行4000多万条大批量数据插入时,报表空间不足错误 方法一: 1.先查询目前的表空间状态 SELECT UPPER(F.TABLESPACE_NAME) "表空间名", D.TOT_GROOTTE_MB "表空间大小(M)", D.TOT_GROOTTE_MB - F.TOTAL_BY 阅读全文

posted @ 2020-03-16 14:33 平平无奇杨小兵 阅读(516) 评论(0) 推荐(0)

oracle批量插入数据优化 与 sqlldr
摘要:千万级数据量直接插入速度很慢,可以通过sqlldr批量插入数据 注: 批量插入大量数据,先删除索引,速度会大大提高,之后重建索引即可 阅读全文

posted @ 2020-03-12 18:15 平平无奇杨小兵 阅读(439) 评论(0) 推荐(0)

记一次oracle事务被锁,进程杀不掉 User session ID does not exist
摘要:首先 truncate table *; 报错: ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired 查看当前锁住的sid: select l.session_id,o.owner,o.objec 阅读全文

posted @ 2020-03-12 11:31 平平无奇杨小兵 阅读(1488) 评论(0) 推荐(0)