---
title: "How DB2 Keeps Logs for Changes to Tables"
description: "When changes are made to the data in tables, subsequently changing the table space and index spaces, DB2 writes one or more records to its log so that a blackout of the changes can be performed if the..."
url: https://srinimf.com/2015/09/17/how-logging-happens-in-db2-when-createinsert-and-delete/
date: 2015-09-17
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2015/09/pexels-photo-3756168.jpeg?fit=1880%2C1253&ssl=1
categories: ["DB2"]
tags: ["DB2 Logging tips"]
type: post
lang: en
---

# How DB2 Keeps Logs for Changes to Tables

When changes are made to the data in tables, subsequently changing the table space and index spaces, [DB2 writes](http://www.indeed.com/jobs?q=Mainframe&indpubnum=6634974704162507)one or more records to its log so that a blackout of the changes can be performed if the unit of work fails. DB2 can also use this information to reapply changes that may have been lost when recovering to a previous point in time.

Related[Logging in IMS DB: A Complete Guide to Audit Trail Records](https://srinimf.com/2016/09/30/3-strong-reasons-why-logging-in-ims-db-needed/)

## The primary purpose of the active log is to record all changes—inserts, updates, and deletes—made to DB2 objects.

- **The DML statements are recorded in the log as follows:**
  - INSERT: Entire after-image of the record is logged; called a redo record
  - DELETE: The before-image is recorded; called an undo record
  - UPDATE: Both the before and after images—undo and redo record—are recorded

*Related*: **[Complete SQL database Training](http://click.linksynergy.com/link?id=yYOcxCqEbGo&offerid=323058.488750&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fsqldatabase%2F)**

## Log Entries

**Each log record has its own unique identifier.** In a parallel sysplex DB2 data sharing environment, it is known as the LRSN (log record sequence number). When you are operating in a non-data sharing environment, this number is known as the log RBA, or the offset of the record in the log from the beginning of the log. In a data sharing environment, the **LRSN helps** to track the sequence of events that happen over multiple members in the data sharing group.

Each member has its own log; if multiple members are making updates to the same data, the logs must be merged during a recovery. Because the LRSN is unique across the sysplex, this type of merging is possible.

*Related:* [Data warehousing and Teradata basics](http://click.linksynergy.com/link?id=yYOcxCqEbGo&offerid=323058.250310&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fintroduction-to-data-warehouse-and-teradata-basics%2F)

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2015%2F09%2F17%2Fhow-logging-happens-in-db2-when-createinsert-and-delete%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2015%2F09%2Fpexels-photo-3756168.jpeg%3Ffit%3D1200%252C800%26ssl%3D1&description=How%20DB2%20Keeps%20Logs%20for%20Changes%20to%20Tables)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2015/09/17/how-logging-happens-in-db2-when-createinsert-and-delete/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2015/09/17/how-logging-happens-in-db2-when-createinsert-and-delete/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2015/09/17/how-logging-happens-in-db2-when-createinsert-and-delete/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2015/09/17/how-logging-happens-in-db2-when-createinsert-and-delete/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20How%20DB2%20Keeps%20Logs%20for%20Changes%20to%20Tables&body=https%3A%2F%2Fsrinimf.com%2F2015%2F09%2F17%2Fhow-logging-happens-in-db2-when-createinsert-and-delete%2F&share=email)
-

### Like this:

Like Loading…
