Displaying the contents of a bind file using the db2bfd tool
There are times when it is beneficial to examine the contents of a DB2 bind file.
For example, a vendor might supply an executable and bind file and you might want to see what kinds of SQL statements the application might execute. Also, consider the case where an errant application is deleting data from a table that is supposed to remain read-only but you aren’t sure which application is responsible.
By examining the bind files for all of the applications that run against the database, you might be able to find a DELETE statement against the table in question and from there dig further into the application’s logic to determine what is going wrong.
The db2bfd tool can be used to display these kinds of thing as well as some other
information.
Execute the tool without any parameters to see its usage.
C:\>db2bfd
Usage: db2bfd [ [-b] [-h] [-s] [-v] ] <filespec>
Where: <filespec> is a V7 or V8 bind file
Options:
-b = display bind file header
-h = display this information
-s = display SQL statements
-v = display host variable declarations
Example 1: Use db2bfd -s to see the SQL statements contained in the db2sampl.bnd file
On Windows operating systems:
db2bfd -s %DB2PATH%\bnd\db2sampl.bnd
(where %DB2PATH% is a variable that determines where DB2® is installed)
On UNIX:
db2bfd -s $HOME/sqllib/bnd/db2sampl.bnd
(where $HOME is the home directory of the instance owner)
Next, use the -v option to see the corresponding host variables that would have been defined in the source code for db2sampl:
On Windows operating systems:
db2bfd -v %DB2PATH%\bnd\db2sampl.bnd
(where %DB2PATH% is a variable that determines where DB2® is installed)
On UNIX:
db2bfd -v $HOME/sqllib/bnd/db2sampl.bnd
(where $HOME is the home directory of the instance owner)