SlideShare uma empresa Scribd logo
1 de 4
Baixar para ler offline
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.

Mais conteúdo relacionado

Mais procurados

Create user to_sysdba
Create user to_sysdbaCreate user to_sysdba
Create user to_sysdba
fangjiafu
 

Mais procurados (8)

Tool Development 08 - Windows Command Prompt
Tool Development 08 - Windows Command PromptTool Development 08 - Windows Command Prompt
Tool Development 08 - Windows Command Prompt
 
SQL200.3 Module 3
SQL200.3 Module 3SQL200.3 Module 3
SQL200.3 Module 3
 
Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)
 
Operating system lab manual
Operating system lab manualOperating system lab manual
Operating system lab manual
 
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
 
Ebook8
Ebook8Ebook8
Ebook8
 
Create user to_sysdba
Create user to_sysdbaCreate user to_sysdba
Create user to_sysdba
 
Sql tutorial-Structured query language
Sql tutorial-Structured query languageSql tutorial-Structured query language
Sql tutorial-Structured query language
 

Semelhante a Db2 cli

Step by step_linux_guide
Step by step_linux_guideStep by step_linux_guide
Step by step_linux_guide
vinod31dec
 
Shared Coursework in Cyber Security Instructions Manual .docx
Shared Coursework in Cyber Security Instructions Manual .docxShared Coursework in Cyber Security Instructions Manual .docx
Shared Coursework in Cyber Security Instructions Manual .docx
edgar6wallace88877
 
Db2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallsDb2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfalls
sam2sung2
 
Administering computer accounts and resources in active directory
Administering computer accounts and resources in active directoryAdministering computer accounts and resources in active directory
Administering computer accounts and resources in active directory
Kavinda Prabhath
 
introtomongodb
introtomongodbintrotomongodb
introtomongodb
saikiran
 

Semelhante a Db2 cli (20)

Db2exc guide 952_mac_x86_64
Db2exc guide 952_mac_x86_64Db2exc guide 952_mac_x86_64
Db2exc guide 952_mac_x86_64
 
2022-Scripting_Hacks.pdf
2022-Scripting_Hacks.pdf2022-Scripting_Hacks.pdf
2022-Scripting_Hacks.pdf
 
Step by step_linux_guide
Step by step_linux_guideStep by step_linux_guide
Step by step_linux_guide
 
Shared Coursework in Cyber Security Instructions Manual .docx
Shared Coursework in Cyber Security Instructions Manual .docxShared Coursework in Cyber Security Instructions Manual .docx
Shared Coursework in Cyber Security Instructions Manual .docx
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database Deployments
 
S3 l3 db2 environment - instances
S3 l3   db2 environment - instancesS3 l3   db2 environment - instances
S3 l3 db2 environment - instances
 
Lotusphere 2007 AD505 DevBlast 30 LotusScript Tips
Lotusphere 2007 AD505 DevBlast 30 LotusScript TipsLotusphere 2007 AD505 DevBlast 30 LotusScript Tips
Lotusphere 2007 AD505 DevBlast 30 LotusScript Tips
 
Ibm db2 case study
Ibm db2 case studyIbm db2 case study
Ibm db2 case study
 
Nodejs Session01
Nodejs Session01Nodejs Session01
Nodejs Session01
 
Db2 tutorial
Db2 tutorialDb2 tutorial
Db2 tutorial
 
Sql server
Sql serverSql server
Sql server
 
Db2
Db2Db2
Db2
 
Oracle to MySQL DatabaseLink
Oracle to MySQL DatabaseLinkOracle to MySQL DatabaseLink
Oracle to MySQL DatabaseLink
 
Db2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallsDb2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfalls
 
lab56_db
lab56_dblab56_db
lab56_db
 
lab56_db
lab56_dblab56_db
lab56_db
 
Administering computer accounts and resources in active directory
Administering computer accounts and resources in active directoryAdministering computer accounts and resources in active directory
Administering computer accounts and resources in active directory
 
Sq lite module5
Sq lite module5Sq lite module5
Sq lite module5
 
introtomongodb
introtomongodbintrotomongodb
introtomongodb
 
202202 SUGUKI UNIX X Command Tips and Tricks
202202 SUGUKI UNIX X Command Tips and Tricks202202 SUGUKI UNIX X Command Tips and Tricks
202202 SUGUKI UNIX X Command Tips and Tricks
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

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.