Recording a DB2 Session


There are several methods for creating a typescript to turn in for your programming assignments.


cut & paste

A really simple way is to cut and paste your window's output, and then save it in a file. That is, if you have such windowing capabilities.


script (UNIX)

One can use the UNIX command script to record all the interactions with the terminal (also known as the shell or loosly window). The script command records everything typed to and printed to that shell ("window"). The syntax for the command is

% script [ -a ] [ filename ]

Everything afterwards is written that file which you specified and named (filename). If you do not specify a file name, script saves by default into a file named typescript (in the directory where you were when you started script). The -a option allows you to append the session to filename, rather than rewriting it. To end the recording, type exit. For more information about script, check the man page.


Running DB2 from the command line

One can create a file containing one's SQL commands, have DB2 execute the SQL commands in the file and redirect DB2's response (the standard output) to a file. For example, typing

% db2 -tvf sql_file > out

at your UNIX prompt will execute the SQL commands written in filename (which should exist in your current directory), and will redirect the ouput to the file named out.