有两个客户基本信息表:需要将该两个客户基本信息表信息同步。现状:两个客户基本信息表都有重复的数据,可以不去更新重复的数据。
需求:通过p_customer_temp表更新custbaseinfo表数据,条件:通过 p_customer_temp表的cardid 匹配custbaseinfo表。
我的SQL语句:
select count(1) from p_customer_temp pc1 where exists
(select 1 from ( select cardid from p_customer_temp pct where pct.cardid is not null and pct.flag ='1' group by cardid having count(cardid) =1 ) pc2 where pc1.cardid = pc2.cardid)
and not exists (select 1 from custbaseinfo cust where exists(select 1 from custbaseinfo cust1 where cust1.crednum = cust.crednum)
and pc1.cardid = cust.crednum group by cust.crednum having count(cust.crednum)>1 )
求精辟的SQL语句!!!求优化!!!
需求:通过p_customer_temp表更新custbaseinfo表数据,条件:通过 p_customer_temp表的cardid 匹配custbaseinfo表。
我的SQL语句:
select count(1) from p_customer_temp pc1 where exists
(select 1 from ( select cardid from p_customer_temp pct where pct.cardid is not null and pct.flag ='1' group by cardid having count(cardid) =1 ) pc2 where pc1.cardid = pc2.cardid)
and not exists (select 1 from custbaseinfo cust where exists(select 1 from custbaseinfo cust1 where cust1.crednum = cust.crednum)
and pc1.cardid = cust.crednum group by cust.crednum having count(cust.crednum)>1 )
求精辟的SQL语句!!!求优化!!!
解决方案 »
- 请给一个用explain plan优化SQL语句的示范例子
- oracle的序列问题
- oracle游标底层的查询机制问题,各位大哥帮帮忙!
- oracle服务和监听都使用断口1521,二者区别?
- 红帽+oracle 11g:数据库安装用户可以conn usr/pwd;同一个dba组的用户连接时报ora-12547:tns:lost contact
- sql查询
- oracle自定义函数(里面用了游标),大家帮看下哪里错了
- plsql 能用Cursor作In参数么?
- 调用这样的存储过程,为什么说我得参数不对?请大家多多指教!
- ORACLE出现错误警告,导致无法连接:oracle instance jh - can not allocate log , archival required
- 两个应用系统通过“中间表”进行数据交互,该如何设计?
- Oracle Net Configuration Assistant 失败(急!!!!!!)
有时候要从数据库本身入手 索引 分区 临时表 少一些连接查询
并不是一条SQL都得到结果的方法就是好方法
begin
insert into t1
select * from t2
when exception then
null;
end;