具体逻辑如下:A表中有300W数据 B表中有70W数据A表的字段有usercode username等等字段 B表中只有usercode字段现在要删除A表中的70W数据(删除条件是:参照B表中的70W数据来进行条件删除)
解决方案:
我写了一个这样的SQL语句:delete from A where usercode in (select usercode from B) 但删除A表中的70W数据 速度非常之慢 无法忍受还行大家帮忙看看 有什么样的SQL语句 可以速度快些~~谢谢!
解决方案:
我写了一个这样的SQL语句:delete from A where usercode in (select usercode from B) 但删除A表中的70W数据 速度非常之慢 无法忍受还行大家帮忙看看 有什么样的SQL语句 可以速度快些~~谢谢!
delete from A where exists select usercode from A,B
where a.usercode = b.usercode
)
delete from A where exists select usercode from A,B
where a.usercode = b.usercode
)
delete from A
where exists (select 1 from A, B where a.usercode = b.usercode)
发重了,上面少括号
上面的语句 貌似不行呢~~
再提示一点的是,最后插回原表时,用insert into <原表> select * from <新创建表>
不要整个删完在提交
commit