The HISTORY and RUNCMD Commands
The HISTORY command lets you access the contents of a
cache, which, by default, holds up to twenty 20 recently run commands in the
same interactive DB2 CLP session. The commands are returned with corresponding
sequence numbers that show the order in which the commands were run. The most
recently run command is listed last.
The size of the command history cache can be controlled
using the DB2_CLPHISTSIZE DB2 registry variable. The range of
permissible values is 1 to 500, inclusive. If you set this variable to a value
that is outside of this range, the DB2 UDB CLP will use the default size of 20.
The syntax of the HISTORY command is shown below:
For example, note the order in which the commands in the
following session were entered:
In the command cache, they are assigned sequence numbers as
db2 connect to sample 
db2 select * from staff where dept = 20 
db2 connect reset 
db2 create database Melnyk 
You can verify this by entering the HISTORY command:
You can use the REVERSE keyword to reverse the order
in which the commands are listed:
You can run any command in the command cache using the RUNCMD
command. The syntax of this command is shown below:
The following example shows you how to run a command from
If the <num> option is not specified, the
default behavior is to run the most recent command.
The command history does not persist from session to
session; if you leave the prompt, the history is lost. If you start two
separate interactive CLP sessions, each session's command history is stored in
a separate cache.