简体   繁体   English

如何有效地从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. 我有一个有五十万行的表,我想删除所有行。

If I do simple delete from tbl , the transaction log fills up. 如果我delete from tbl执行简单delete from tbl ,则事务日志会填满。 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? 我可以在许多交易中删除行,但有没有更好的方法呢?

How to efficiently remove all rows from a table in DB2? 如何有效地从DB2中的表中删除所有行? Can I disable the transactions for this command somehow or is there special commands to do this (like truncate in MySQL)? 我可以以某种方式禁用此命令的事务,或者是否有特殊命令来执行此操作(如MySQL中的截断 )?

After I have deleted the rows, I will repopulate the database with similar amount of new data. 删除行后,我将使用相似数量的新数据重新填充数据库。

似乎以下命令适用于较新版本的DB2。

TRUNCATE TABLE someschema.sometable IMMEDIATE  

To truncate a table in DB2, simply write: 要在DB2中截断表,只需写:

alter table schema.table_name activate not logged initially with empty table

From what I was able to read, this will delete the table content without doing any kind of logging which will go much easier on your server's I/O. 从我能够阅读的内容来看,这将删除表格内容而不进行任何类型的日志记录,这将使您的服务器的I / O更加容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM