<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->A.id = B.aid = C.aid = D.aid = E.aid = F.aid = G.aid
现在要把id为1的数据在所有表中全部删除
刚开始写的循环删除 但执行效率太慢了
有没有更好的办法使效率更高
------解决方案-------------------- delete from A where id=1; delete from B where aid=1; ......................... ------解决方案--------------------
------解决方案-------------------- 在所有表的 aid 上建索引 在循环中逐个操作
如果都是 InnoDB 类型表 那么在除 A 外的表的 aid 上建 A.id 的外键 只 delete from A where id=1 即可
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn