How Does Fivetran Calculate the tbl_id
Value in the HVR Enroll File for Db2 for LUW?
Question
The HVR enroll file displays a tbl_id
value, for example, 720901
, for a specific table. However, this value doesn't match any value visible in Db2 for LUW. How does Fivetran calculate the tbl_id
value in the HVR enroll file?
Environment
- HVR 6
- Source: Db2 for LUW
Answer
We calculate the tbl_id
value in the HVR enroll file by combining the following two identifiers from the Db2 for LUW database:
tbspaceid
: The tablespace ID where the table resides.tbl_id
: The unique identifier for the table within the database.
We convert these values into hexadecimal (HEX) format, concatenate them, and then convert the result into a single decimal number, which we store as the tbl_id
value in the enroll file.
Example calculation
To understand the calculation, do the following:
- Start with the
tbl_id
from the enroll file. For example,720901
. - Convert this value from decimal to HEX. For example,
720901
converts toB0005
in HEX format. - Split the HEX value into two parts:
- The first portion,
000B
, represents thetbspaceid
. - The second portion,
0005
, represents thetbl_id
.
- The first portion,
- Convert each part back to decimal:
000B
in HEX converts to11
in decimal, which is thetbspaceid
value.0005
in HEX converts to5
in decimal, which is thetbl_id
value.
For this example, the enroll file’s tbl_id
value of 720901
corresponds to:
tbspaceid=11
tbl_id=5
Reverse calculation
You can calculate the enroll file’s tbl_id
value from known tbspaceid
and tbl_id
values by doing the following:
- Convert the
tbspaceid
andtbl_id
to HEX format. For example, thetbspaceid
value11
converts to000B
in HEX, and thetbl_id
value5
converts to0005
in HEX. - Join the two HEX values into a single string. For example, combining
000B
and0005
results in000B0005
. - Convert the joined HEX string back to decimal. For example,
000B0005
in HEX converts to720901
in decimal.