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 个以前曾经存在过。有没有简单的方法来解决这个问题?(使用 InnoDB 表)
另一个使用自动递增主键的好理由。这样,行就不会完全重复。
可能最快的方法是将数据复制到另一个表中,截断第一个表,然后重新插入:
create temporary table tmp as select distinct * from test; truncate table test; insert into test select * from tmp;
insert作为一个小提示:在几乎所有情况下,我建议在语句中使用完整的列列表。这是可选的一种情况。毕竟,您将所有列放在另一个表中,稍后再将它们放回语句中。
insert