If it helps, here is a sample with some different stuff. Note logging
commands inside script file, and semicolon delimited commands. The
snapshot table function runs only after v8 and above.
Contents of a file named script1.sql follow:
--Comment line here using 2 dashes
Update command options using l on script1.log r on script1.rpt;
--do a select
select * from schema1.tab1 where col1='value1';
--get some space usage numbers for tablespaces
SELECT substr(tablespace_name,1,15) TSName,
(sum(used_pages))*page_size/1024 KB_Used,
(sum(usable_pages - used_pages))*page_size/1024 KB_Free,
page_size Page_size
FROM TABLE(SNAPSHOT_TBS_CFG('',-1)) AS SNAPSHOT_TBS_CFG
group by tablespace_name,page_size
order by 2;
--last line commented, too
and run this file like this, in a db2cmd window (if you are on a pc), or
run on a db server at command prompt that has a db2 environment defined:
db2 -tf script1.sql
J. Bart Coffman
-----Original Message-----
From: Bora Prandip [mailto:db2udbdba-ezmlmshield- Sent: Wednesday, May
31, 2006 4:54 AM
To: LazyDBA Discussion
Subject: RE: How to run a SQL script ...
The very basic command is:
db2 -f<input_file>
And if you want the output in a file:
db2 -f<input_file> -z<output_file>
-----Original Message-----
From: B1B2
[mailto:db2udbdba-ezmlmshield-.[Email address protected]
Sent: Wednesday, May 31, 2006 3:15 PM
To: LazyDBA Discussion
Subject: How to run a SQL script ...
Hi all,
Very new to DB2 and am already tasked to write a script .... can someone
tell me what command to run to execute a SQL script from DB2>. That is,
if I need to run a script like SELECT X FROM TABLE that is saved in a
file, how do I run that via DB2 ....
Just want to know the basics for a start, unfortunately not enough to do
RTFM at the moment ...
Thanks in advance ..
******* Confidentiality Notice *******
This email, its electronic document attachments, and the contents of its website linkages may contain confidential health information. This information is intended solely for use by the individual or entity to whom it is addressed. If you have received this information in error, please notify the sender immediately and arrange for the prompt destruction of the material and any accompanying attachments.
DB2 & UDB email list listserv db2-l LazyDBA home page