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'));