Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 2 个 mySQL 表(表 Master 和表 Backup)有些行被复制到备份表,有些则没有......
现在我需要从主表中删除所有行,这些行在备份表中可用单个查询,因为大约。两个表中都有 700k+ 行
就像是:
DELETE FROM master_table WHERE id IN (SELECT id FROM backup_table)
当然,它需要 id 字段上的唯一键才能工作
我建议这样做:
DELETE m FROM master_table m JOIN backup_table b ON b.id = m.id
IN对这么多行使用子句必然会出现性能问题。
IN