mysql 截断归档表
我有一个带有存档存储引擎的表,我想清除它。由于引擎定义的原因,delete
和 truncate
都不起作用。但是除了删除整个表并重新创建它之外,还有其他方法吗?
I have a table with the archive storage engine and I would like to clear it. Neither delete
, nor truncate
will work because of the engine definition. But is there any other way than dropping the whole table an recreating it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
另一种解决方法是将其更改为 BLACKHOLE 表,然后将其更改回来。
Another workaround would be to change it to be a BLACKHOLE table, then change it back.
请参阅 Bug #15558 truncate 不会清除存档存储引擎表上的表
基本上,设计师希望它能以这种方式工作。对该错误的修复是当您尝试对使用 ARCHIVE 存储引擎存储的表使用 truncate 时返回错误。
唯一的解决方法是删除并重新创建表。
See Bug #15558 truncate doesn't clear table on archive storage engine tables
Basically, the designers wanted it to work that way. The fix to that bug was to make it return an error when you try to use truncate on a table stored with the ARCHIVE storage engine.
The only workaround is to DROP and the re-CREATE the table.
DELETE 或 BLACKHOLE 解决方案在大表上速度很慢。最快的解决方案:
像the_table一样创建表the_table2;删除表the_table;将表 the_table2 重命名为 the_table;
DELETE or BLACKHOLE solutions are slow on big tables. The fastest solution:
create table the_table2 like the_table; drop table the_table; rename table the_table2 to the_table;