FREE is the DSN opposite of BIND: it deletes a package, plan, REST service, query hint, or stabilized dynamic statement from DB2 for z/OS. The subcommands are FREE PACKAGE, FREE PLAN, FREE QUERY, FREE SERVICE, and FREE STABILIZED DYNAMIC QUERY. This page covers wildcards, PLANMGMTSCOPE copies, authorization (BIND is not enough to free a package), and the difference between hints and stabilized dynamic SQL.
Like BIND and REBIND, FREE runs under TSO DSN or DB2I (except as noted for your release). Data sharing scope is group. Freeing an object on one member removes it for the whole group.
| Subcommand | What it removes |
|---|---|
| FREE PACKAGE | Package versions or PLANMGMT copies from catalog and directory |
| FREE PLAN | Application plans (not the packages they listed) |
| FREE QUERY | SYSQUERY* hint rows; purges matching dynamic cache entries |
| FREE SERVICE | Native REST service package (active copy) |
| FREE STABILIZED DYNAMIC QUERY | Stabilized dynamic SQL catalog rows and matching cache entries |
FREE PACKAGE deletes a version, all versions of a package, or whole collections. Catalog rows go away. The package-id becomes available for a new BIND PACKAGE. Phased-out copies are deleted as well. Authorization for the package name is removed only when no versions remain.
For the current copy, FREE waits until applications that are using the package finish. PLANMGMTSCOPE lets you free inactive copies without that wait.
1234567FREE PACKAGE(PAYROLL.PAYCALC.(V1)) FREE PACKAGE(PAYROLL.*) FREE PACKAGE(*.PAYCALC) FREE PACKAGE(LOCATIONX.COLL.PKG.(V2)) FREE PACKAGE(PAYROLL.PAYCALC) PLANMGMTSCOPE(INACTIVE) FREE PACKAGE(PAYROLL.PAYCALC) PLANMGMTSCOPE(PREVIOUS) FREE PACKAGE(PAYROLL.PAYCALC) INVALIDONLY(YES) PLANMGMTSCOPE(PREVIOUS)
| Value | Meaning |
|---|---|
| ALL | Entire package including copies (default). Not for trigger packages, SQL routines, or active native REST |
| INACTIVE | Previous, original, or eligible phased-out copies; OK while current copy runs |
| PREVIOUS | Only the previous copy |
| ORIGINAL | Only the original copy |
| PHASEOUT | Phased-out copies from plan management |
PLANMGMTSCOPE(ALL) is not supported for trigger packages, SQL routines, or native REST services. FREE PACKAGE of inactive REST copies is allowed; the active REST package is FREE SERVICE.
Authorization: ownership, BINDAGENT from the owner, PACKADM, SYSADM, SYSCTRL, or System DBADM. The BIND privilege on the package is not sufficient. That surprises people who can BIND REPLACE all day but cannot FREE.
FREE PLAN deletes application plans. It does not free the packages on the PKLIST. After FREE PLAN, a RUN or CAF OPEN using that plan name fails until you BIND PLAN again. EXECUTE grants on the plan disappear with the plan.
12FREE PLAN(PAYPLAN) FREE PLAN(*)
You need ownership of the plan, BINDAGENT from the owner, or SYSADM/SYSCTRL/System DBADM (BIND on the plan is not the documented FREE authority—match the Command Reference for your release, which lists ownership and system authorities similarly to packages). Do not FREE the plans your CICS region still names in RCT/DB2CONN.
FREE SERVICE deletes the application package that represents a Db2 native REST service, including the SYSIBM.DSNSERVICE association. Clients that POST to that service name get an error until you BIND SERVICE again. Versioning, if enabled, means you free a specific service version—check the NAME and VERSION operands on your function level.
1FREE SERVICE(PAYROLL.getEmp)
FREE QUERY removes rows from the catalog tables that BIND QUERY populated (SYSIBM.SYSQUERY, SYSQUERYPLAN, SYSQUERYOPTS) for one or more queries. If those statements sit in the dynamic statement cache, FREE QUERY purges them so the next PREPARE is a fresh prepare without the hint.
You identify queries by QUERYID from the catalog or by the matching text/schema rules documented for the subcommand. After a bad hint, FREE QUERY then BIND QUERY with a corrected DSN_USERQUERY_TABLE row is the cleanup path—not REBIND PACKAGE, unless the hint was package-scoped via OPTHINT.
Dynamic SQL can be stabilized so a prepared statement keeps a known access path across cache eviction (START DYNQUERYCAPTURE / catalog stabilization). FREE STABILIZED DYNAMIC QUERY removes those stabilized rows from the catalog and purges matching statements from the dynamic statement cache. Application compatibility changes, invalidation, or this FREE are how stabilized statements pick up new behavior.
Do not confuse this with FREE QUERY. Hints (BIND QUERY) are “use this path.” Stabilization is “keep this already-chosen path for this dynamic text.” Both can coexist; free the one you actually created.
FREE PACKAGE is throwing away a frozen meal (or just the leftover copies in the back of the freezer). You cannot throw away the meal someone is still eating unless you wait (ALL), but you can throw away yesterday’s extra copy (INACTIVE). FREE PLAN throws away the dinner ticket, not the meals on the shelf. FREE SERVICE throws away the QR-code meal. FREE QUERY peels off the sticky note that said “use this oven.” FREE STABILIZED DYNAMIC QUERY forgets a memorized shortcut for a sentence people type on the fly.
1. Does BIND privilege allow FREE PACKAGE?
2. What does PLANMGMTSCOPE(INACTIVE) free?
3. How do you free the active package of a native REST service?
4. What does FREE QUERY do besides catalog rows?
5. When are package EXECUTE privileges removed?