Contact
QR code for the current URL

Story Box-ID: 1283051

mip Management Informations Partner GmbH Fürstenrieder Straße 267 81377 München, Germany http://www.mip.de
Contact Ms Gabriela von Bargen +49 89 58939431

Db2 Stored Procedure zum effizienten Löschen aus Db2 Tabellen

In der Datenbankadministration von Db2 Tabellen und auch in der Anwendungsentwicklung wird immer häufiger die Anforderung gestellt, dass sehr große Datenbanken (> 10 Mio Rows) aus historisch gewachsenen row-basierten Tabellen zu löschen sind.

(PresseBox) (München, )
Lösungsansätze und Optimierungen

Herausforderung beim Löschen großer Db2 Tabellen

In der Regel sind solche historisch gewachsenen row-basierten Tabellen normale Db2 Tabellen ohne irgendwelche oder mit nicht zur Löschung passenden Partitionierungstechniken. D.h. die zu löschende Datenmenge muss mit DELETE-Statements gelöscht und im Transaktionslog protokolliert werden. Ein einzelnes DELETE-Statement zum Löschen der Rows endet nicht selten im SQL Error SQL0964C „The transaction log for the database is full“.

Natürlich könnte man die Tabelle in eine neue Tabelle mit LOAD FROM CURSOR umladen und nur die nicht zu löschenden Zeilen laden. Das bedeutet aber nach dem LOAD eine Downtime, um die bisherige mit der neuen Tabelle zu synchronisieren (bis auf die zu löschenden Zeilen) und auf den bisherigen Tabellennamen umzubenennen.

Bisheriger Ansatz mit Commit-Zählung

Es gab bereits einen Ansatz, solche Löschungen mit einer Db2 Stored Procedure umzusetzen (Quelle).

Diese Stored Procedure arbeitet mit dem Syntax-Element FETCH FIRST x ROWS ONLY beim SELECT-Statement, das für den DELETE verwendet wird: 

Db2 Stored Procedure zum effizienten Löschen aus Db2 Tabellen - Ihr Datenspezialist - mip GmbH in München

Website Promotion

Website Promotion
The publisher indicated in each case (see company info by clicking on image/title or company info in the right-hand column) is solely responsible for the stories above, the event or job offer shown and for the image and audio material displayed. As a rule, the publisher is also the author of the texts and the attached image, audio and information material. The use of information published here is generally free of charge for personal information and editorial processing. Please clarify any copyright issues with the stated publisher before further use. In case of publication, please send a specimen copy to service@pressebox.de.
Important note:

Systematic data storage as well as the use of even parts of this database are only permitted with the written consent of unn | UNITED NEWS NETWORK GmbH.

unn | UNITED NEWS NETWORK GmbH 2002–2026, All rights reserved

The publisher indicated in each case (see company info by clicking on image/title or company info in the right-hand column) is solely responsible for the stories above, the event or job offer shown and for the image and audio material displayed. As a rule, the publisher is also the author of the texts and the attached image, audio and information material. The use of information published here is generally free of charge for personal information and editorial processing. Please clarify any copyright issues with the stated publisher before further use. In case of publication, please send a specimen copy to service@pressebox.de.