SlideShare a Scribd company logo
University of Konstanz                                                                                 Information Systems
Databases & Information Systems Group                                                                          Assignments
Prof. M. H. Scholl / Jens Teubner / Svetlana Vinnik                                                         Winter 2003/04

                   Using the DB2 Command Line Interface
1      Configuring your Environment to Work with DB2
In order to use the DB2 command line interface, you need to extend your shell’s search path and set some
environment variables. The simplest way to do this is to source the script I provided you. Add this line to
the file .bashrc.username in your home directory.1

source /home/db2/db2user/db2env

    The changes become effective after your next login or in newly opened xterms. See if everything is okay
by typing in2

$ :::::::::
  type db2
db2 is /usr/IBMdb2/V7.1/bin/db2
$


2      Working With DB2
To start the DB2 command line interface, you type in

$ ::::
  db2
(c) Copyright IBM Corporation 1993,2000
Command Line Processor for DB2 SDK 7.1.0
... and some messages more ...

db2 =>

   You see the DB2 command prompt, db2 =>. At this command prompt, you can type in SQL queries
and some DB2 specific database commands. Exit the command line interface with

db2 => ::::::::::
       terminate
DB20000I The TERMINATE command completed successfully.
$

and you get your Unix shell prompt back.
   Unfortunately, the DB2 command prompt is not as convenient as the shell prompt you are used to. You’ll
find an alternative way to work with DB2 below, be patient.


2.1        Connecting to the Database
After you started the command line interface (CLI), you have to connect to a database, before you can
execute any SQL queries. The database for this course is called infosys, and you type in

db2 => :::::::::::::::::::::::::::::::::::::
       connect to infosys user username
Enter current password for username : (Enter your database password here)

     Database Connection Information
    1 Insteadof username use your Unix login. If the file does not exist yet, just create it.
    2 Do not type in the dollar sign ($). I always use the dollar sign to symbolize your shell’s command prompt. The wavy     :::
underlined parts are always those that you have to type in; the parts printed in regular typewriter font is the answer you receive
::::::::
from the system.
Database server             = DB2/LINUX 7.1.0
 SQL authorization ID        = USERNAME
 Local database alias        = INFOSYS

db2 =>
where username is your Unix login name. You will get your database password in the lecture. As in SQL,
all commands and identifiers are case-insensitive.
    Before you end your work with the DB2 database, you have to disconnect from the database:
db2 => :::::::::::::::::::::
       disconnect infosys
DB20000I The SQL DISCONNECT command completed successfully.
db2 =>
After that, you can exit the command line interface with terminate.

2.2     Executing SQL Queries
You can simply type in any SQL queries at the DB2 command prompt as long as you are connected to the
database. There are some DB2 specific things you need to know:

2.2.1    Schemata
In the lecture you saw simple SQL queries like SELECT * FROM Kurs. “Real” SQL (i. e. the lastest ANSI
standard), however, provides the mechanism of ‘schemata’. A schema can be seen as a ‘namespace’ or (in
Java terms) ‘package’. Different tables can exist with the same name in different schemata.
    Every table (in fact, every database object), that is not in your current schema, must be specified with
a fully qualified name. A database object is fully qualified by the schema name and a dot in front of the
object identifier, like nobody.kurs. (I put the ‘KursDB’ database into the ‘nobody’ schema.)
    Example:
SELECT *
  FROM nobody.Teilnehmer
  WHERE Ort = ’Ulm’
   If you know you’ll be working in a specific schema for a while, you can set your current schema for this
database session with
db2 => :::::::::::::::::::::::::::::::::::::
       set current schema = schema-name
From now on, the schema schema-name will be assumed if you do not fully qualify your database objects.
   Example:
db2 => :::::::::::::::::::::::::::::::
       set current schema = nobody
DB20000I The SQL command completed successfully.
db2 => :::::::::::::::::::::::::::::::::::::::::::::::::::::
       select * from kurs where titel = ’Datenbanken’

KURSNR TITEL
------ --------------------
I09    Datenbanken

  1 record(s) selected.

db2 =>

2.2.2    Your Own Schema
The current schema after logging in to the database is your personal schema that has the name of your
login name. In your personal schema you also have write access to the database, you can create tables,
insert and manipulate data, etc.
2.3     Statement Termination
Any (SQL) statement is executed as soon as you hit the Enter key. This is pretty convenient for DB2
commands or short SQL queries. The downside is that you can’t type in queries that span more than one
line.
    If you do not like this behavior, invoke the db2 command with the option -t. Any command now has to
be terminated by a semicolon (;). If you hit the Enter key without the semicolon, you’ll get a new line on
the DB2 command prompt, like this:

db2 => :::::::::
       select *
db2 (cont.) => ::::::::::::::::::::
                 from nobody.kurs;

You may make the option -t by setting the Unix environment variable DB2OPTIONS to ‘-t’ (e. g. in your
.bashrc.username file).


2.4     Getting Help
All the SQL commands are listed in the DB2 SQL Reference Manual that is available on the course website.
This should be your primary documentation if you have problems concerning SQL.
    Additionally there are several DB2 specific commands. These commands allow you to see which tables
exist in the database, get index definitions or other system information. You usually won’t need these
commands. If you are curious, there are two ways to get documentation:

    1. The DB2 Command Reference Manual is the reference to all these commands. Most of the commands
       that are listed there, however, will not be available to you, as they are intended for the database
       administrator. Some commands can be executed from the Unix command line, others from within the
       DB2 command line interface. You can find the Command Reference Manual on the course website.

    2. If you type in a question mark (?) within the command line interface, you’ll get a list of all DB2
       commands. You get specific help for a single command by typing in ‘? command-name ’. Don’t forget
       the space between the question mark and the command you want to have documented.


3     Working Efficiently with DB2
Working with the command line interface db2 can be tedious; there’s no command history or completion,
no syntax hilighting, etc. There are, however, some ways to make life with DB2 easier:

    • Work with an open editor in parallel. Edit your queries in a file that you have open in your favorite
      editor. To execute a query, simply use the copy/paste mechanism of your X11 system. Mark the
      query text in your editor and paste it into the command line interface with the middle mouse button.
      It is probably convenient to turn on the semicolon as a statement termination character for this (see
      above).

    • State your query on db2’s command line. The db2 utility has the ability to keep your database
      connection open during its invocations. As long as you haven’t terminated or disconnected, you
      can exit db2 and re-start it again without losing your database connection. To exit the db2 utility
      without closing your connection, use the command quit.
       If you state database commands on the shell command line when you invoke db2 these commands will
       be executed and db2 will quit immediately. The following session log demonstrates this feature.

       $ :::::::::::::::::::::::::::::::::::::::::::
         db2 "connect to infosys user teubner"
       Enter current password for teubner:

          Database Connection Information

        Database server             = DB2/LINUX 7.1.0
        SQL authorization ID        = TEUBNER
Local database alias         = INFOSYS

  $ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    db2 "select * from nobody.kurs where kursnr = ’G08’"

  KURSNR TITEL
  ------ --------------------
  G08    Grundlagen I

    1 record(s) selected.

  $ ::::
    db2
  (c) Copyright IBM Corporation 1993,2000
  Command Line Processor for DB2 SDK 7.1.0
  ...
  db2 => :::::::::::::::::::::::::::::::::::::
         select count(*) from nobody.kurs

  1
  -----------
            4

    1 record(s) selected.

  db2 => :::::
          quit
  DB20000I The QUIT command completed successfully.
  $ ::::::::::::::::::::::::::::
    db2 "disconnect infosys"
  DB20000I The SQL DISCONNECT command completed successfully.

  I started db2 here several times, sometimes with a query specified on the command line, once in
  interactive mode.
  Caution! Be careful with your shell’s command line expansion! If you do not properly quote your
  query (as seen above), you will get strange results. (If you don’t understand anything here, read it as
  “Always put your SQL query into double quotes (") when you specify it on the Unix command line.”)

• Use the db2batch utility. There’s a second utility from IBM, called db2batch. Intended to measure
  runtime statistics, you can execute a whole file with SQL queries in batch mode. In your query file,
  separate your queries with semicolons; comments start with two minus signs (--). See the DB2
  Command Reference Manual or invoke db2batch with the option -h to see the options available for
  the db2batch program.

More Related Content

PDF
SQL injection: Not Only AND 1=1 (updated)
Bernardo Damele A. G.
 
PDF
Expanding the control over the operating system from the database
Bernardo Damele A. G.
 
PDF
Got database access? Own the network!
Bernardo Damele A. G.
 
PDF
Windows command prompt a to z
Subuh Kurniawan
 
PDF
Operating System Lab Manual
Dwight Sabio
 
PDF
Advanced SQL injection to operating system full control (short version)
Bernardo Damele A. G.
 
PDF
Advanced SQL injection to operating system full control (short version)
Bernardo Damele A. G.
 
DOCX
Sql interview questions
nagesh Rao
 
SQL injection: Not Only AND 1=1 (updated)
Bernardo Damele A. G.
 
Expanding the control over the operating system from the database
Bernardo Damele A. G.
 
Got database access? Own the network!
Bernardo Damele A. G.
 
Windows command prompt a to z
Subuh Kurniawan
 
Operating System Lab Manual
Dwight Sabio
 
Advanced SQL injection to operating system full control (short version)
Bernardo Damele A. G.
 
Advanced SQL injection to operating system full control (short version)
Bernardo Damele A. G.
 
Sql interview questions
nagesh Rao
 

What's hot (8)

PDF
Tool Development 08 - Windows Command Prompt
Nick Pruehs
 
PPT
SQL200.3 Module 3
Dan D'Urso
 
PDF
Advanced SQL injection to operating system full control (slides)
Bernardo Damele A. G.
 
PDF
Operating system lab manual
Meerut Institute of Technology
 
PPT
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
Dan D'Urso
 
PPT
Ebook8
kaashiv1
 
PDF
Create user to_sysdba
fangjiafu
 
PDF
Sql tutorial-Structured query language
Mayank Bansal
 
Tool Development 08 - Windows Command Prompt
Nick Pruehs
 
SQL200.3 Module 3
Dan D'Urso
 
Advanced SQL injection to operating system full control (slides)
Bernardo Damele A. G.
 
Operating system lab manual
Meerut Institute of Technology
 
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
Dan D'Urso
 
Ebook8
kaashiv1
 
Create user to_sysdba
fangjiafu
 
Sql tutorial-Structured query language
Mayank Bansal
 
Ad

Similar to Db2 cli (20)

PDF
2022-Scripting_Hacks.pdf
Roland Schock
 
DOCX
Db2 v9 dba for linux taining in bangalore
Suvash Chowdary
 
PPT
Db2
yboren
 
PDF
A Tour to MySQL Commands
Hikmat Dhamee
 
PPT
MDI Training DB2 Course
Marcus Davage
 
PDF
Complete SQL in one video by shradha.pdf
rahulashu699
 
PPTX
DB2 Basic Commands - UDB
Srinimf-Slides
 
PPT
Mysql
Rathan Raj
 
DOC
IBM DB2 LUW/UDB DBA Training by www.etraining.guru
Ravikumar Nandigam
 
DOC
IBM DB2 LUW UDB DBA Online Training by Etraining Guru In Hyderabad
Ravikumar Nandigam
 
DOC
online training for IBM DB2 LUW UDB DBA
Ravikumar Nandigam
 
DOC
IBM DB2 LUW UDB DBA Training by www.etraining.guru
Ravikumar Nandigam
 
PPT
Introduction to Structured Query Language (SQL).ppt
JohnnySebastian4
 
PPT
Introduction to Structured Query Language (SQL) (1).ppt
ComputerScienceDepar6
 
PPT
Lec 1 = introduction to structured query language (sql)
Faisal Anwar
 
PPT
15925 structured query
Universitas Bina Darma Palembang
 
PDF
PT- Oracle session01
Karthik Venkatachalam
 
PDF
Intruduction to SQL.Structured Query Language(SQL}
IlgarKarimov3
 
PDF
Chapter – 6 SQL Lab Tutorial.pdf
TamiratDejene1
 
PDF
Od47 g formation-ibm-i-db2-and-sql-school
CERTyou Formation
 
2022-Scripting_Hacks.pdf
Roland Schock
 
Db2 v9 dba for linux taining in bangalore
Suvash Chowdary
 
Db2
yboren
 
A Tour to MySQL Commands
Hikmat Dhamee
 
MDI Training DB2 Course
Marcus Davage
 
Complete SQL in one video by shradha.pdf
rahulashu699
 
DB2 Basic Commands - UDB
Srinimf-Slides
 
Mysql
Rathan Raj
 
IBM DB2 LUW/UDB DBA Training by www.etraining.guru
Ravikumar Nandigam
 
IBM DB2 LUW UDB DBA Online Training by Etraining Guru In Hyderabad
Ravikumar Nandigam
 
online training for IBM DB2 LUW UDB DBA
Ravikumar Nandigam
 
IBM DB2 LUW UDB DBA Training by www.etraining.guru
Ravikumar Nandigam
 
Introduction to Structured Query Language (SQL).ppt
JohnnySebastian4
 
Introduction to Structured Query Language (SQL) (1).ppt
ComputerScienceDepar6
 
Lec 1 = introduction to structured query language (sql)
Faisal Anwar
 
15925 structured query
Universitas Bina Darma Palembang
 
PT- Oracle session01
Karthik Venkatachalam
 
Intruduction to SQL.Structured Query Language(SQL}
IlgarKarimov3
 
Chapter – 6 SQL Lab Tutorial.pdf
TamiratDejene1
 
Od47 g formation-ibm-i-db2-and-sql-school
CERTyou Formation
 
Ad

Recently uploaded (20)

PDF
Software Development Methodologies in 2025
KodekX
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PPTX
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
Software Development Methodologies in 2025
KodekX
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 

Db2 cli

  • 1. University of Konstanz Information Systems Databases & Information Systems Group Assignments Prof. M. H. Scholl / Jens Teubner / Svetlana Vinnik Winter 2003/04 Using the DB2 Command Line Interface 1 Configuring your Environment to Work with DB2 In order to use the DB2 command line interface, you need to extend your shell’s search path and set some environment variables. The simplest way to do this is to source the script I provided you. Add this line to the file .bashrc.username in your home directory.1 source /home/db2/db2user/db2env The changes become effective after your next login or in newly opened xterms. See if everything is okay by typing in2 $ ::::::::: type db2 db2 is /usr/IBMdb2/V7.1/bin/db2 $ 2 Working With DB2 To start the DB2 command line interface, you type in $ :::: db2 (c) Copyright IBM Corporation 1993,2000 Command Line Processor for DB2 SDK 7.1.0 ... and some messages more ... db2 => You see the DB2 command prompt, db2 =>. At this command prompt, you can type in SQL queries and some DB2 specific database commands. Exit the command line interface with db2 => :::::::::: terminate DB20000I The TERMINATE command completed successfully. $ and you get your Unix shell prompt back. Unfortunately, the DB2 command prompt is not as convenient as the shell prompt you are used to. You’ll find an alternative way to work with DB2 below, be patient. 2.1 Connecting to the Database After you started the command line interface (CLI), you have to connect to a database, before you can execute any SQL queries. The database for this course is called infosys, and you type in db2 => ::::::::::::::::::::::::::::::::::::: connect to infosys user username Enter current password for username : (Enter your database password here) Database Connection Information 1 Insteadof username use your Unix login. If the file does not exist yet, just create it. 2 Do not type in the dollar sign ($). I always use the dollar sign to symbolize your shell’s command prompt. The wavy ::: underlined parts are always those that you have to type in; the parts printed in regular typewriter font is the answer you receive :::::::: from the system.
  • 2. Database server = DB2/LINUX 7.1.0 SQL authorization ID = USERNAME Local database alias = INFOSYS db2 => where username is your Unix login name. You will get your database password in the lecture. As in SQL, all commands and identifiers are case-insensitive. Before you end your work with the DB2 database, you have to disconnect from the database: db2 => ::::::::::::::::::::: disconnect infosys DB20000I The SQL DISCONNECT command completed successfully. db2 => After that, you can exit the command line interface with terminate. 2.2 Executing SQL Queries You can simply type in any SQL queries at the DB2 command prompt as long as you are connected to the database. There are some DB2 specific things you need to know: 2.2.1 Schemata In the lecture you saw simple SQL queries like SELECT * FROM Kurs. “Real” SQL (i. e. the lastest ANSI standard), however, provides the mechanism of ‘schemata’. A schema can be seen as a ‘namespace’ or (in Java terms) ‘package’. Different tables can exist with the same name in different schemata. Every table (in fact, every database object), that is not in your current schema, must be specified with a fully qualified name. A database object is fully qualified by the schema name and a dot in front of the object identifier, like nobody.kurs. (I put the ‘KursDB’ database into the ‘nobody’ schema.) Example: SELECT * FROM nobody.Teilnehmer WHERE Ort = ’Ulm’ If you know you’ll be working in a specific schema for a while, you can set your current schema for this database session with db2 => ::::::::::::::::::::::::::::::::::::: set current schema = schema-name From now on, the schema schema-name will be assumed if you do not fully qualify your database objects. Example: db2 => ::::::::::::::::::::::::::::::: set current schema = nobody DB20000I The SQL command completed successfully. db2 => ::::::::::::::::::::::::::::::::::::::::::::::::::::: select * from kurs where titel = ’Datenbanken’ KURSNR TITEL ------ -------------------- I09 Datenbanken 1 record(s) selected. db2 => 2.2.2 Your Own Schema The current schema after logging in to the database is your personal schema that has the name of your login name. In your personal schema you also have write access to the database, you can create tables, insert and manipulate data, etc.
  • 3. 2.3 Statement Termination Any (SQL) statement is executed as soon as you hit the Enter key. This is pretty convenient for DB2 commands or short SQL queries. The downside is that you can’t type in queries that span more than one line. If you do not like this behavior, invoke the db2 command with the option -t. Any command now has to be terminated by a semicolon (;). If you hit the Enter key without the semicolon, you’ll get a new line on the DB2 command prompt, like this: db2 => ::::::::: select * db2 (cont.) => :::::::::::::::::::: from nobody.kurs; You may make the option -t by setting the Unix environment variable DB2OPTIONS to ‘-t’ (e. g. in your .bashrc.username file). 2.4 Getting Help All the SQL commands are listed in the DB2 SQL Reference Manual that is available on the course website. This should be your primary documentation if you have problems concerning SQL. Additionally there are several DB2 specific commands. These commands allow you to see which tables exist in the database, get index definitions or other system information. You usually won’t need these commands. If you are curious, there are two ways to get documentation: 1. The DB2 Command Reference Manual is the reference to all these commands. Most of the commands that are listed there, however, will not be available to you, as they are intended for the database administrator. Some commands can be executed from the Unix command line, others from within the DB2 command line interface. You can find the Command Reference Manual on the course website. 2. If you type in a question mark (?) within the command line interface, you’ll get a list of all DB2 commands. You get specific help for a single command by typing in ‘? command-name ’. Don’t forget the space between the question mark and the command you want to have documented. 3 Working Efficiently with DB2 Working with the command line interface db2 can be tedious; there’s no command history or completion, no syntax hilighting, etc. There are, however, some ways to make life with DB2 easier: • Work with an open editor in parallel. Edit your queries in a file that you have open in your favorite editor. To execute a query, simply use the copy/paste mechanism of your X11 system. Mark the query text in your editor and paste it into the command line interface with the middle mouse button. It is probably convenient to turn on the semicolon as a statement termination character for this (see above). • State your query on db2’s command line. The db2 utility has the ability to keep your database connection open during its invocations. As long as you haven’t terminated or disconnected, you can exit db2 and re-start it again without losing your database connection. To exit the db2 utility without closing your connection, use the command quit. If you state database commands on the shell command line when you invoke db2 these commands will be executed and db2 will quit immediately. The following session log demonstrates this feature. $ ::::::::::::::::::::::::::::::::::::::::::: db2 "connect to infosys user teubner" Enter current password for teubner: Database Connection Information Database server = DB2/LINUX 7.1.0 SQL authorization ID = TEUBNER
  • 4. Local database alias = INFOSYS $ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: db2 "select * from nobody.kurs where kursnr = ’G08’" KURSNR TITEL ------ -------------------- G08 Grundlagen I 1 record(s) selected. $ :::: db2 (c) Copyright IBM Corporation 1993,2000 Command Line Processor for DB2 SDK 7.1.0 ... db2 => ::::::::::::::::::::::::::::::::::::: select count(*) from nobody.kurs 1 ----------- 4 1 record(s) selected. db2 => ::::: quit DB20000I The QUIT command completed successfully. $ :::::::::::::::::::::::::::: db2 "disconnect infosys" DB20000I The SQL DISCONNECT command completed successfully. I started db2 here several times, sometimes with a query specified on the command line, once in interactive mode. Caution! Be careful with your shell’s command line expansion! If you do not properly quote your query (as seen above), you will get strange results. (If you don’t understand anything here, read it as “Always put your SQL query into double quotes (") when you specify it on the Unix command line.”) • Use the db2batch utility. There’s a second utility from IBM, called db2batch. Intended to measure runtime statistics, you can execute a whole file with SQL queries in batch mode. In your query file, separate your queries with semicolons; comments start with two minus signs (--). See the DB2 Command Reference Manual or invoke db2batch with the option -h to see the options available for the db2batch program.