脚本相关(需要使用但是不经常使用的脚本,自己记录下增强记忆,后面需要是可以直接查找)

1、查询登录用户下的所有表占用空间:
select segment_name "表名" , segment_type "类型" , sum(bytes)/1024/1024 "占用空间(MB)" from dba_extents where 1=1 and 
segment_type="table" group by segment_name,segment_type order by "占用空间(MB)" desc ;
2、oracle中case when then 相关字段用法(),每个渠道的提交数据量
select 
    case t.salechl
        when '01' then '个险'
        when '02' then '团险'
        when '03' then '银保'
        when '06' then '综合'
        when 'Z' then '内勤'
        else '' --除了上面的归类,其余的都属于else一类 
        end as "渠道",count(1) as "数量" -- as 后面是别名
    from dztb_mit.t_prt_application t 
    where t.applyno in(select * from dztb_mit.t_contract a where a.main_proc='3' and a.proc_node='1' and a.proc_status='2' 
    and t.create_time>to_date('20240801','yyyyMMdd')) group by t.salechl ;

3、oracle修改clob类型字段里面的某些数据值(该方法比4的一个方法好一点,不会因为数据过大被切割,不需要些存储过程)

-- 把 字段 result_Json 里面的某个值替换成其他的值 
update t_prt_app t set t.result_Json=( select replace(a.result,'替换前的值','替换后的值') from t_prt_app a where a.policyuuid='984949444'  ) where t.policyuuid='984949444' ;

4 、oracle中使用存储过程循环修改clob字段里面的值(注:如果clob里面存储的字节大于了varcahr2能够存储的大小,就会导致clob里面的数据被切割,丢失部分数据,所以最好提前对数据做个备份)

DECLARE
    resultJson clob;
    resultJsonVarcharBefore varchar2(32767);
    resultJsonVarcharAfter varchar2(32767);
BEGIN
 
    for st in( select x.apply_no from t_prt_application x where x.riskCode='ADDTAB' order by x.create_time desc )loop -- 循环语句
    
    select result_Json into resultJson from t_prt_application  t where t.apply_no=st.apply_no ;
    resultJsonVarcharBefore := DBMS_LOB.SUBSTR(resultJson,32767,1);--32767是clob字段最大存储字节数量
    resultJsonVarcharAfter := replace(resultJsonVarcharBefore ,'需要被替换的字符串','替换完成后的字符串');
    resultJson := resultJsonVarcharAfter ;
    
update t_prt_application t set t.result_json = resultJson where apply_no =st.apply_no ;
end loop;
end;
/

5、备份数据(将某几条数据写在备份表中)

create table t_prt_app_1 as select * from t_prt_app where policyuid in('983838','232155','542343');

6、将A表数据插入B表(A、B表结构完全一样--备份表数据重新插入原表)

insert into t_prt_app(select * from t_prt_app_1 where applyno in('4848484','43243','5654654'));

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sheclockes

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值