如何有效地从DB2中的表中删除所有行 [英] How to efficiently remove all rows from a table in DB2
问题描述
我有一张桌子有五十万行,我想删除所有的行。
I have a table that has something like half a million rows and I'd like to remove all rows.
如果我做简单的从tbl
中删除,事务日志将会填满。我不关心这种情况下的交易,我不想在任何情况下回滚。我可以在许多事务中删除行,但是有没有更好的方法?
If I do simple delete from tbl
, the transaction log fills up. I don't care about transactions this case, I do not want to rollback in any case. I could delete rows in many transactions, but are there any better ways to this?
如何有效地从DB2中的表中删除所有行?我可以禁用此命令的事务,还是有特殊命令来执行此操作(如 truncate ?
How to efficiently remove all rows from a table in DB2? Can I disable the transactions for this command somehow or is there special commands to do this (like truncate in MySQL)?
在我删除了这些行之后,我将用类似数量的新数据重新填充数据库。 >
After I have deleted the rows, I will repopulate the database with similar amount of new data.
推荐答案
似乎以下命令在较新版本的DB2中工作。
It seems that following command works in newer versions of DB2.
TRUNCATE TABLE someschema.sometable IMMEDIATE
这篇关于如何有效地从DB2中的表中删除所有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!