I have 100,000 rows to delete in DB2. I use Hibernate (HQL) something like delete from than query.executeQuery()
.
Is it possible in HQL to limit the number of rows to delete? For example:
query.setMaxRowTodelete(100); // this is just an example.
query.executeQuery();
If you wanted to delete a number of rows within a range, you can use the AND operator with the BETWEEN operator. DELETE FROM table_name WHERE column_name BETWEEN value 1 AND value 2; Another way to delete multiple rows is to use the IN operator.
If you need to use TOP to delete rows in a meaningful chronological order, you must use TOP together with an ORDER BY clause in a subselect statement.
Saddly, you can not limit with HQL and query.setMaxResults(number)
won't work with UPDATE
s or DELETE
s. Your options are:
WHERE someid IN (id1, id2, ..., id100)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With