delete a where (col1,col2,col3,col4) in ( select col1,col2,col3,col4 from b where exists(select 1 from a where col1=b.col1 and col2=b.col2 and col3=b.col3 and col4=b.col4) )//对a表建立索引(col1,col2,col3,col4)
学习,学习。 俺从来都不考虑速度,汗ing
信息不全面阿 说得仔细点 表关系什么的 exists in严重影响速度
信息不全面阿 说得仔细点 表关系什么的 exists in严重影响速度
快速删除表中记录!!! TRUNCATE TABLE 表名 TRUNCATE TABLE a where exists (select 1 from b where a.col1=b.col1 and a.col2=b.col2 and a.col3=b.col3 and a.col4=b.col4)
为什么不考虑索引?对这个sql太重要了!
where (col1,col2,col3,col4) in (
select col1,col2,col3,col4 from b
where exists(select 1 from a where col1=b.col1 and col2=b.col2 and col3=b.col3 and col4=b.col4)
)//对a表建立索引(col1,col2,col3,col4)
俺从来都不考虑速度,汗ing
说得仔细点
表关系什么的
exists in严重影响速度
说得仔细点
表关系什么的
exists in严重影响速度
TRUNCATE TABLE 表名
TRUNCATE TABLE a
where exists
(select 1 from b where a.col1=b.col1 and a.col2=b.col2 and a.col3=b.col3 and a.col4=b.col4)
WHERE exists
(SELECT l FROM b
WHERE (b.coll, b.col2, b.col3, b.col4) = any
(SELECT a.col1, a.col2, a.col3, a.col4 FROM a);
供参考。