I found the solution here:
http://db2commerce.com/2014/09/02/db2-basics-executing-a-script-of-sql/
A file of pure SQL should look more like:
connect to sample;
create table....;
alter table ....;
create index ....;
insert into ....;
Note the lack of the “db2″ at the beginning of each line. Note also that each line terminates in a semicolon(;). The semicolon is the delimiter in this example. Since the semicolon is the default delimiter, you could execute the above file using:
db2 -tvmf filename.sql |tee filename.sql.out
Finally, you might have a file that uses an alternate delimiter. This is required when working with certain triggers and stored procedures. In the case of an alternate delimiter, the file might look like this:
connect to sample@
create table....@
alter table ....@
create index ....@
insert into ....@
That file would be executed using:
db2 -td@ -vmf filename.sql |tee filename.sql.out
Basic Command Line Options for DB2
There are several command line options, I used above. Here is the breakdown of these options I use most frequently:
-
t – terminated – the statements are terminated with a delimiter. The default delimiter is the semi-colon
-
d – delimiter – the default delimiter is being overriden, and db2 uses the character immediately following d as the delimiter.
-
v – verbose – the statement will be echoed in output prior to the result of the statement. This is extremely useful when reviewing output or troubleshooting failed statements
-
m – prints the number of lines affected by DML
-
f – file – indicates that db2 should execute statements from a file, with the filename specified one space after the f.
There are plenty of other interesting command line options available in the DB2 Knowledge Center: http://www-01.ibm.com/support/knowledgecenter/SSEPGG_10.5.0/com.ibm.db2.luw.admin.cmd.doc/doc/r0010410.html?cp=SSEPGG_10.5.0%2F3-5-2-0-2&lang=en