REBIND is how you give DB2 for z/OS a second look at SQL that is already bound. The DSN subcommands are REBIND PACKAGE, REBIND PLAN, and REBIND TRIGGER PACKAGE. You do not pass a new DBRM. You re-optimize, change options, refresh an invalid package after a dropped index, or SWITCH back to a saved copy. This page covers when to rebind versus bind, wildcards, APREUSE/APCOMPARE, PLANMGMT, and basic versus advanced triggers.
| What changed | Typical command |
|---|---|
| SQL in the program changed | BIND PACKAGE ACTION(REPLACE) from the new DBRM |
| New index, RUNSTATS, or you want a new access path | REBIND PACKAGE (optionally APREUSE/APCOMPARE) |
| Need a different ISOLATION or QUALIFIER | REBIND PACKAGE with the new options |
| Plan PKLIST must add a collection | REBIND PLAN ... PKLIST(...) |
| Bad access path after rebind, copies exist | REBIND PACKAGE SWITCH(PREVIOUS) or SWITCH(ORIGINAL) |
Automatic rebind (subsystem parameter) can kick in when an invalid package runs. Many shops set that off so access paths do not change in the middle of the night without a change record. Prefer an explicit REBIND window with EXPLAIN(YES) or EXPLAIN(ONLY).
REBIND PACKAGE rebinds application packages other than basic trigger packages. You can change any bind option that BIND PACKAGE accepts. Identify the package as location.collection.package.(version). Omit location for the local server.
12345678910DSN SYSTEM(DB2A) REBIND PACKAGE(PAYROLL.PAYCALC.(V1)) - EXPLAIN(YES) ISOLATION(CS) - PLANMGMT(EXTENDED) APREUSE(WARN) END REBIND PACKAGE(PAYROLL.*) REBIND PACKAGE(*.*) REBIND PACKAGE(*.DEBIT) REBIND PACKAGE(SNTERSA.GROUP1.PROGA.(V1)) ENABLE(BATCH)
Wildcards: *.* is all versions of all local packages you are allowed to rebind. LEDGER.* is everything in that collection. *.DEBIT is the empty-string version of DEBIT in every collection. Asterisks are not valid for remote packages—spell the location, collection, package, and version.
Authorization is the BIND privilege on the package, ownership, BINDAGENT from the owner, PACKADM, or SYSADM/SYSCTRL/System DBADM. You only rebind packages you are authorized for when you use *.
After a weekend REBIND that regresses a statement, SWITCH(PREVIOUS) is faster and safer than guessing bind options. FREE PACKAGE PLANMGMTSCOPE(INACTIVE) later reclaims the unused copies.
| Option | Meaning |
|---|---|
| APREUSE(NONE) | Choose access paths freely (no reuse requirement) |
| APREUSE(WARN) | Try to reuse; continue if some statements cannot |
| APREUSE(ERROR) | Reuse must succeed or the statement/package fails the rebind |
| APCOMPARE(NONE|WARN|ERROR) | Compare new versus old paths; warn or fail on change |
| APREUSESOURCE | CURRENT, PREVIOUS, or ORIGINAL copy to reuse from |
Db2 ignores APREUSE for a package last bound before DB2 9; RELBOUND in SYSPACKAGE / SYSPACKCOPY tells you the release. Rebind once accepting path changes, then you can reuse. EXPLAIN(YES) or EXPLAIN(ONLY) with APREUSE(ERROR) and APCOMPARE(WARN) is a common “show me what would change” pattern. APREUSE(WARN) plus APCOMPARE(WARN) can succeed even when reuse fails if Db2 happens to pick the same path again.
REBIND PLAN updates plan-level options. The usual reason is the package list.
12REBIND PLAN(PLANA) PKLIST(GROUP1.*) MEMBER(ABC) REBIND PLAN(PLANA) NOPKLIST
MEMBER on REBIND PLAN is the same deprecated compatibility path as BIND PLAN: avoid it for new work. You can still change ISOLATION, CACHESIZE, CURRENTSERVER, and other plan options. Authorization is ownership, BIND on the plan, BINDAGENT, or a system authority.
REBIND TRIGGER PACKAGE rebinds a package for a basic trigger. Identify basic triggers by a blank SQLPL column in SYSIBM.SYSTRIGGERS. Advanced triggers (SQL PL) use REBIND PACKAGE, not this command.
Reasons to rebind a trigger package: a new index, RUNSTATS, a dropped dependent object that marked the package invalid, or a small set of options (CURRENTDATA, DESCSTAT, EXPLAIN, ISOLATION, RELEASE, APPLCOMPAT, time-sensitive flags, CONCURRENTACCESSRESOLUTION, PLANMGMT, APREUSE, APCOMPARE, SWITCH). REBIND TRIGGER PACKAGE(*) affects only basic trigger packages you are authorized to rebind. A successful rebind marks the package valid.
123REBIND TRIGGER PACKAGE(HR.EMP_SAL_TRIG) EXPLAIN(YES) ISOLATION(CS) PLANMGMT(EXTENDED) APREUSE(WARN)
BIND is cooking a new meal from a new recipe card. REBIND is tasting last week’s frozen meal again with a better oven (new statistics) or a different timer (isolation). APREUSE is saying “use the same oven rack as last time.” SWITCH is pulling the backup meal from the freezer labeled PREVIOUS when the new baking tastes wrong. Trigger packages are meals the database cooks by itself when someone touches a table; basic ones have a smaller kitchen and their own REBIND command.
1. When do you REBIND PACKAGE instead of BIND PACKAGE?
2. What does APREUSE(ERROR) do?
3. How do you drop a plan’s package list on REBIND PLAN?
4. Which command rebinds a basic trigger package?
5. What does SWITCH(PREVIOUS) do on REBIND PACKAGE?