BIGINT is Db2 for z/OS’s 8-byte binary integer type. When INTEGER’s roughly ±2.1 billion range is not enough—high-volume keys, long-lived counters, or integrations that already use 64-bit integers—BIGINT is the exact whole-number type to use. This page covers range and storage, design choices, overflow and promotion, and COBOL host-variable mapping notes.
BIGINT is a binary integer with 63 bits of magnitude plus a sign. Each value occupies 8 bytes in the row. The range is enormous for business counting, but it is still finite—applications that generate keys without a plan can eventually hit limits in theory, though INTEGER usually hits first in real systems.
| Item | Detail |
|---|---|
| SQL name | BIGINT |
| Storage | 8 bytes |
| Minimum | −9,223,372,036,854,775,808 |
| Maximum | +9,223,372,036,854,775,807 |
| Category | Exact binary integer |
123456CREATE TABLE EVENT_LOG ( EVENT_ID BIGINT NOT NULL, EVENT_TS TIMESTAMP NOT NULL, PAYLOAD_LEN INTEGER, PRIMARY KEY (EVENT_ID) );
BIGINT doubles storage versus INTEGER for every row and index entry that includes the column. If the business maximum will never approach two billion, INTEGER (or SMALLINT) is clearer and leaner. Do not use BIGINT for money—use DECIMAL with an appropriate scale.
123456Quick chooser (whole numbers only): Fits in −32768…32767? -> SMALLINT Fits in ±2.1e9? -> INTEGER Needs up to ±9.22e18? -> BIGINT Needs fractional digits? -> DECIMAL / DECFLOAT / float types
BIGINT can still overflow—multiplying two huge BIGINT values may exceed ±9.22×10¹⁸. Narrowing casts are a more common beginner trap: assigning a BIGINT host value to an INTEGER column, or CAST(big AS INTEGER), fails when the value does not fit.
1234567-- Promote INTEGER operands before multiplying if product may exceed INTEGER SELECT BIGINT(a) * BIGINT(b) AS PRODUCT FROM METRICS; -- Narrowing cast: fails if EVENT_ID > 2147483647 SELECT CAST(EVENT_ID AS INTEGER) AS EVENT_INT FROM EVENT_LOG;
In mixed expressions, Db2 promotes numeric types according to documented precedence. INTEGER and BIGINT together typically yield BIGINT-scale results for the wider calculation path. Mixing BIGINT with DECIMAL or DECFLOAT shifts you into decimal/floating rules—including scale and rounding. Prefer explicit CAST when the result type matters for a column assignment or host variable.
The scalar function BIGINT(expression) converts a value to BIGINT when the conversion is legal. Use it to document intent in views and SELECT lists.
BIGINT needs an 8-byte binary host field. A common pattern (verify against your shop standard) is:
12345678901 WS-EVENT-ID PIC S9(18) USAGE COMP-5. EXEC SQL SELECT EVENT_ID INTO :WS-EVENT-ID FROM EVENT_LOG WHERE EVENT_TS >= :WS-FROM-TS FETCH FIRST 1 ROW ONLY END-EXEC.
long, C long long, and similar 64-bit types align conceptually with BIGINT across DDF applicationsINTEGER is a big toy chest. BIGINT is an even bigger toy chest—almost a whole closet. Both only hold whole toys, not broken half-toys. If you try to pour the closet into the smaller chest, toys spill everywhere (overflow). If your counting game might go past what the chest can hold, start with the closet (BIGINT) instead of upgrading in a panic later.
1. How many bytes does Db2 BIGINT use?
2. BIGINT is most appropriate when:
3. What is the approximate maximum BIGINT value?
4. Casting a BIGINT larger than 2,147,483,647 to INTEGER will:
5. A typical COBOL host variable for BIGINT uses: