Top Banner

of 36

DB2Demo Program Guide

Apr 07, 2018

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/6/2019 DB2Demo Program Guide

    1/36

    DB2 DatabaseDemonstration Program Version 9.5

    Installation and Quick Reference Guide

    George BaklarzDB2 Worldwide Technical Sales Support

    IBM Toronto Laboratory

  • 8/6/2019 DB2Demo Program Guide

    2/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007 IBM ii

    DB2 Demonstration Program Version 9.5 Usage Guide

    This document contains proprietary information of IBM. It is provided under a licenseagreement and is protected by copyright law. The information contained in this

    publication does not include any product warranties, and any statements provided inthis manual should not be interpreted as such.

    When you send information to IBM, you grant IBM a nonexclusive right to use ordistribute the information in any way it believes appropriate without incurring anyobligation to you.

    Copyright International Business Machines Corporation 1997 - 2008. All rightsreserved. US Government Users Restricted Rights Use, duplication or disclosurerestricted by GSA ADP Schedule Contract with IBM Corp.

    Credits

    Material in this document was prepared by the DB2 Worldwide Pre-sales Supportgroup.

  • 8/6/2019 DB2Demo Program Guide

    3/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM i

    Legal NoticesThis page may contain other proprietary notices and copyright information, the termsof which must be observed and followed.

    INFORMATION IN THIS DEMONSTRATION IS PROVIDED "AS IS" WITHOUT WARRANTY OFANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, ORNON-INFRINGEMENT. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIEDWARRANTIES, SO THE ABOVE EXCLUSION MAY NOT APPLY TO YOU.

    Information in this demonstration may contain technical inaccuracies or typographicalerrors. Information may be changed or updated without notice. IBM may also makeimprovements and/or changes in the products and/or the programs described in thisinformation at any time without notice.

    Information IBM publishes in this demonstration may contain references or crossreferences to IBM products, programs and services that are not announced oravailable in your country. Such references do not imply that IBM intends to announcesuch products, programs or services in your country. Consult your local IBM businesscontact for information regarding the products, programs and services which may beavailable to you.

    IN NO EVENT WILL IBM BE LIABLE TO ANY PARTY OR ANY DIRECT, INDIRECT, SPECIALOR OTHER CONSEQUENTIAL DAMAGES FOR ANY USE OF THIS DEMONSTRATION,INCLUDING, WITHOUT LIMITATION, ANY LOST PROFITS, BUSINESS INTERRUPTION, LOSSOF PROGRAMS OR OTHER DATA ON YOUR INFORMATION HANDLING SYSTEM OR

    OTHERWISE, EVEN IF WE ARE EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCHDAMAGES.

  • 8/6/2019 DB2Demo Program Guide

    4/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM ii

    Copyright and Trademark information

    Disclaimer and Trademarks

    This presentation may contain other proprietary notices and copyright information, the termsof which must be observed and followed. Information concerning non-IBM products wasobtained from the suppliers of those products, their published announcements, or otherpublicly available sources. IBM has not tested those products and cannot confirm the accuracyof performance, compatibility, or any other claims related to non-IBM products. Questions onthe capabilities of non-IBM products should be addressed to the suppliers of those products.

    All statements regarding IBMs future direction or intent are subject to change or withdrawalwithout notice, and represent goals and objectives only. This information may containexamples of data and reports used in daily business operations. To illustrate them ascompletely as possible, the examples include the names of individuals, companies, brands,and products. All of these names are fictitious, and any similarity to the names and addresses

    used by an actual business enterprise is entirely coincidental.

    Trademarks

    The following terms are trademarks or registered trademarks of other companies and havebeen used in at least one of the pages of the presentation:

    The following terms are trademarks of International Business Machines Corporation in theUnited States, other countries, or both: AIX, AS/400, DataJoiner, DataPropagator, DB2, DB2Connect, DB2 Extenders, DB2 OLAP Server, DB2 Universal Database, Distributed RelationalDatabase Architecture, DRDA, eServer, IBM, IMS, iSeries, MVS, Net.Data, OS/390, OS/400,PowerPC, pSeries, RS/6000, SQL/400, SQL/DS, Tivoli, VisualAge, VM/ESA, VSE/ESA,

    WebSphere, z/OS, zSeries

    Microsoft, Windows, Windows NT, Windows XP, Windows Vista, and the Windows logo aretrademarks of Microsoft Corporation in the United States, other countries, or both.

    Intel and Pentium are trademarks of Intel Corporation in the United States, other countries,or both.

    UNIX is a registered trademark of The Open Group in the United States and other countries.

    Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the UnitedStates, other countries, or both.

    Other company, product, or service names may be trademarks or service marks of others.

    Copyright IBM Corporation 2008. All rights reserved.

  • 8/6/2019 DB2Demo Program Guide

    5/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM iii

    Table of Contents

    DB2 Demonstration Program Version 9.5 Usage Guide.......................................................... 2Legal Notices................................................................................................................................. 1

    Copyright and Trademark information..................................................................................... 2Disclaimer and Trademarks.................................................................................................... 2Trademarks................................................................................................................................ 2

    Introduction .................................................................................................................................. 1DB2 Certification.......................................................................................................................... 2Installation Requirements .......................................................................................................... 4Installing the DB2DEMO Program............................................................................................... 5

    Installation File......................................................................................................................... 5Setup and Installation of the Program ................................................................................. 5Advanced Installation ............................................................................................................ 10Uninstalling the Demonstration........................................................................................... 11

    Support..................................................................................................................................... 11Using the DB2DEMO Program.................................................................................................... 12

    Starting the Program ............................................................................................................. 12Overview of the Panels ......................................................................................................... 14Scripting Panel........................................................................................................................ 15SQL Input Window .................................................................................................................. 20SQL Output Window ............................................................................................................... 28Performance Monitoring ....................................................................................................... 30

    DB2DEMO Program Credits........................................................................................................ 31

  • 8/6/2019 DB2Demo Program Guide

    6/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 1

    Introduction

    Now that you've installed DB2, you probably want to know what it can do. TheDB2DEMO program lets you explore the various features of DB2, including:

    SQL Features:

    o Referential Integrityo Domains and Constraintso Triggerso Recursive SQLo Outer Joins

    Advanced Object-Relational Features:

    o Large Object Support (BLOBs)o User-defined Typeso User-defined Functionso Table functionso Row-types and Typed Tableso Reference Typeso SQL PL Stored Procedure Language

    XML Support

    o SQL/XML Functionso XML Data typeo XQuery Language Extensions

    Business Intelligence Features:

    o Star Schema supporto Multi-dimensional Analysiso Dynamic Bitmap indexeso Automatic Summary Tableso Compressiono Table Partitioning

    Manageability

    Performance

    This demo lets you try out many of these features of DB2, including showing you someof the administrative and performance features. The only thing you need to do ischeck that you have requirements and then install the code!

  • 8/6/2019 DB2Demo Program Guide

    7/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 2

    DB2 Certification

    For additional help on using DB2, or getting certified on DB2, you may want to look atThe DB2 9 for Linux, UNIX, and Windows DBA Guide, Reference, and ExamPrep, Sixth Edition, ISBN 013185514, by George Baklarz and Paul Zikopoulos.

    This book is a complete guide to the IBMs relational database servers, known as DB2.DB2 is available on many operating systems, and the book has been written to coverthe version available on Linux, UNIX, and Windows. Any significant differences in theimplementation of DB2 on various operating systems are highlighted.

    If you are planning to become certified, or you would simply like to understand thepowerful new DB2 database servers from IBM, then this book is a great resource.

    The book is divided into four parts:

    Part 1 Introduction to DB2 (Chapters 14).

    Installing and configuring DB2 servers and clients are covered in Chapters 24.

    Part 2 Using SQL (Chapters 510).

    The Structured Query Language (SQL) is discussed in Chapter 5, 6, and 7.Chapter 8 covers the new pureXML capabilities, while Chapter 9 discusses theSQL PL programming language. Database concurrency is discussed inChapter 10.

    Part 3 DB2 Database Administration (Chapters 1114).

    Creating a DB2 database and its related table spaces is covered in Chapter 11.

  • 8/6/2019 DB2Demo Program Guide

    8/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 3

    The common administration tasks are discussed in Chapters 12 and 13.Database monitoring and performance considerations are discussed inChapter 14.

    Part 4 Developing Applications with DB2 (Chapters 1516).

    An introduction to application development for DBAs is given in Chapter 15.Chapter 16 deals with some of the DBA activities that are related to applicationdevelopment. Not all of the material in these chapters is necessary for you topass your certification test, but it will definitely help you when applications gointo production.

    This book can be used as a self-study guide to help you prepare for the DB2certification exams, or as a guide to DB2 on the Linux, UNIX, and Windows platforms.The DB2DEMO program, along with the book, are great tools for helping you learn DB2and obtaining your DB2 Certification!

    For more details on the DB2 certification program, visit www.ibm.com/certify.

  • 8/6/2019 DB2Demo Program Guide

    9/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 4

    Installation Requirements

    This program is meant to be used for demonstrating the functionality of the DB2 UDBV9 product. In order to use this program, you need the following configuration:

    Windows Operating System (Windows 2000/XP/2003/Vista ) Browser (Internet Explorer, Firefox, or any suitable browser) Access to a DB2 system with the SAMPLE database

    Your workstation or laptop should have a minimum of 384M of memory to runWindows and DB2, although more than 512M is ideal. The DB2DEMO program itselfneeds approximately 3MB of disk space for the program and help files, but this cangrow to 20MB to hold the sample tables that are created during the demonstration.

    The program will work with DB2 Version 7+, but not all features will work if you use a

    down-level server. In addition to having a DB2 server available, the SAMPLE databasemust be created beforehand, otherwise the program will not be able to run any of theexamples. The SAMPLE database is normally created as part of the First Steps programafter the DB2 installation is complete. If you need to create the sample database, usethe db2sampl command.

    While the SAMPLE database is the default database used by the DB2DEMO program,any database can be accessed by the program on all of the DB2 supported platforms,including:

    AIX HP SUN Linux (all platforms) Windows 2000, Windows XP, Windows 2003 iSeries (DB2 Connect Required) z/OS (DB2 Connect Required)

    Although the database can reside on one of these machines, the actual client (demo)must run on Windows 2000/XP/2003/Vista. For details on how to do this, please seethe installation procedure section.

    Note: The DB2DEMO program can also be used against other DB2 databases in yourenvironment, but many of the examples are strictly for the DB2 on the Linux, UNIX,and Windows platforms.

  • 8/6/2019 DB2Demo Program Guide

    10/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 5

    Installing the DB2DEMO Program

    Installation File

    The DB2DEMO installation program consists of only one file that contains theexecutable along with all of the supporting files required to run the program. The filename is the same whether you downloaded this program from the internet or found iton a CD-ROM:

    DB2DEMOSETUP.EXE - Installation program for the DB2DEMO program

    Before beginning the installation, make sure that you have about 10M of disk spaceavailable (half of this is temporary space that will be released when the installation iscomplete).

    Setup and Installation of the Program

    From within the directory that you found the DB2DEMOSETUP program (either the CD-ROM or on your hard drive), you double-click your left mouse button on this file name,or execute it from a command line:

    C:\DOWNLOADS>DB2DEMOsetup.exe

    After clicking on the DB2DEMOSETUP program, there will be some temporary

    messages displayed while the program unpacks some files, and then you will bepresented with the first installation screen:

  • 8/6/2019 DB2Demo Program Guide

    11/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 6

    Make sure that you have exited any programs that may be currently running (just tobe on the safe side) and the hit OK to continue on to the next step.

    The next screen gives you the copyright and legal information for the program. Pleaseread it and say "YES" to continue:

  • 8/6/2019 DB2Demo Program Guide

    12/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 7

    The next screen that appears is the directory screen:

  • 8/6/2019 DB2Demo Program Guide

    13/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 8

    Select a drive and directory to place the DB2DEMO program into. By default, thename of the directory is called C:\Program Files\DB2DEMO and it is placed on the C:drive. The above example shows how the installation directory can be changed.

    Use the Drives and Directories list boxes to change the value of the field to point to

    the installation directory you want. When you are ready to go, hit the NEXT button. Atthis point in time, the installation program will ask you for the Program Group thatthe DB2DEMO program will be placed into:

    Once you have selected the group name, the program will confirm the installationinformation:

  • 8/6/2019 DB2Demo Program Guide

    14/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 9

    Once you hit the continue button, the program will begin copying files:

  • 8/6/2019 DB2Demo Program Guide

    15/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 10

    When copying is complete, the final completion box will be displayed:

    Depending on which operating system you were installing on, you may be asked toreboot the machine, or be given an option to try out the demo program or look at theadditional README information that is supplied with the program. You can also startup DB2DEMO by going into the DB2DEMO group and selecting the DB2DEMO icon fromthe DB2DEMO group (or whatever you called it) and clicking on it:

    To see how the program works, check out the section on running the program. If youwant to run the DB2DEMO program against another server, please read theinstructions on customization.

    Advanced Installation

    The SAMPLE database can be installed on any server supported by DB2. The programthat creates that sample database is called db2sampl and can be found in thesqllib\bin directory on your server. When you install the database on a differentmachine, you still need to use the DB2DEMO program on Windows 2000 or WindowsXP, but the data will be on the server instead of the local machine.

  • 8/6/2019 DB2Demo Program Guide

    16/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 11

    In order to install this on a different server, you need to be very familiar with DB2commands and the security of the machine you are working on. The steps required torun this demo against a different server are:

    1. Install DB2 on the server operating system

    2. Create a privileged userid that can administer the DB2 system3. Create the sample database on the system4. Create a userid on this system that can be used to connect from the remote

    system5. Set up the Windows client so that the SAMPLE database has been catalogued

    properly. This includes installing the DB2 Client Application Enabler code onthe workstation. Without this code, the demonstration program cannot run.

    Once the installation is complete, you should be able to run the DB2DEMO programfrom the client and connect to the remote SAMPLE database.

    Uninstalling the DemonstrationTo uninstall the DB2DEMO program, use the Add/Delete panel within the Servicesgroup to delete the application:

    Select the DB2 Demonstration program and the various files will be deleted. Thedirectory may not be deleted if you have personalized any of the files.

    SupportWe've tried to think of everything, but occasionally things go wrong. If you have aproblem with the demonstration code, please send us a note with your email address,name and a description of the problem. We can be reached at [email protected].

  • 8/6/2019 DB2Demo Program Guide

    17/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 12

    Using the DB2DEMO Program

    Starting the Program

    To start the demonstration program, go either to a command or use Windows explorerto start the DB2DEMO program in the DB2DEMO directory (or wherever you chose toplace it).

    Or you can run it from a command line:

    DB2DEMO [filename.sql] {option1=value option2=value ...}

    Once you have started the program, you will see the introduction screen:

    The default database for the connection is SAMPLE. The DB2Demo scripts will be

    automatically loaded once you hit CONNECT. In the event that the program cannotconnect to the database, it will issue an error message asking whether or not DB2should be started:

  • 8/6/2019 DB2Demo Program Guide

    18/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 13

    Selecting yes will attempt to start the local DB2 instance (remote instances are notsupported). If no is pressed, the program will return to the connection panel. You canchoose a different database from the list, or adjust your userid and password and tryconnecting again. If you press CANCEL, the DB2DEMO.SQL script will be loaded andthen the main DB2DEMO screen displayed. Note that no SQL will run until asubsequent connection to a database is established.

    A number of brief messages will display, and finally the demonstration screen will bedisplayed.

    Note: The program will use a number of defaults to start up:

    password= userid= database="SAMPLE" file="DB2DEMO.SQL" font="Tahoma" fontsize="8" schema=(userid if blank) sqllib="c:\program files\ibm\sqllib" or DB2PATH value if set instance="DB2" or DB2INSTANCE value if set

    If the DB2DEMO.SQL file cannot be found, the program will not display an errormessage. Instead, it will only show the SQL window.

  • 8/6/2019 DB2Demo Program Guide

    19/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 14

    Overview of the Panels

    The demonstration program is divided into two major panels. On the far left-handside is the scripting panel which contains:

    SQL Commamds (scripts) Help

    This scripting panel can be moved and resized independently from the SQL panel.Note that this panel is optional and does not need to be shown in order to use the SQLpanel.

    The right section of the demonstration program contains the SQL panel. The panel canbe divided into 4 parts:

    SQL Input Error Messages Output Status Indicator

    The SQL panel can be resized and moved around independent of the scripting panel.Finally, there is a toolbar on the top of the SQL panel that allows you to change theoperation of the program.

  • 8/6/2019 DB2Demo Program Guide

    20/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 15

    In addition to these screens, there are a number of windows which will be displayeddepending on what you are doing:

    Performance Monitor Graphing/Plotting Menu

    XML/Long string display

    The following section describes the function of each of the windows found in theScripting panel.

    Scripting Panel

    The window is only shown when the DB2DEMO script (or any other script) is loadedinto the program.

    The top section of the scripting panel contains various DB2 scripts that demonstratefeatures of the program. The bottom section contains any help information associatedwith the example.

  • 8/6/2019 DB2Demo Program Guide

    21/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 16

    Command Window

    The command window contains all of the examples of SQL that are demonstrated inthe DB2Demo program. By default, the DB2Demo program will automatically execute

    the SQL found in the command window when you click on an item. If you want tostop automatic execution, change the auto run option in the SQL panel.

    In order to execute one of the sample SQL commands, you need to click on one of thesections shown in the SQL Example. If you click on a [+] sign, it will expand to showthe various SQL commands:

    When you click on an SQL command, it will have the SQL statements in the exampleplaced into the SQL Input window and executed immediately if the Auto run option isset. You can change this behavior if you want to read about the SQL before it getsexecuted (see the Auto run option). If you click on the [-] when the list is alreadyopened, it will close up again into a single item.

    Clicking on any of the items in command window will also refresh the SQL informationbox.

  • 8/6/2019 DB2Demo Program Guide

    22/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 17

    Usually this box will contain information on the command that is being executed. Youcan use the scroll bars to go up and down to see what the SQL is trying to accomplish.

    When the SQL executes, the DB2 Input message window will change to "Running" andthen be updated with any error codes. Always take a look at this window todetermine what the status of the SQL is.

    Refresh

    There are two buttons found at the top of the Script panel: Refresh and Search. TheRefresh option is the first of the two buttons: . This button will reload the entireset of scripts that are currently in the panel. You can use this button to collapse all ofthe examples lists, or after having found some scripts with the search button. Theother reason for using the refresh button is to reload examples that you have

    modified.

    Right-clicking on an example line will display the contents of that script in theNotepad editor:

  • 8/6/2019 DB2Demo Program Guide

    23/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 18

    You can make changes to the script and save it back to disk. However, the changeswill not be reflected in the script that is found in the DB2DEMO program until youpress the refresh button.

    Search

    The Search option is found next to the refresh button:

    This button allows you find all of the scripts (examples) in the current set of SQLstatements that have the keyword that you are looking for:

    When a search term is entered, the set of commands in the command window isexpanded to show the individual examples that have the keyword in the descriptionline. For instance, the normal command window looks similar to the following screen:

    The search field is filled in with "union" and the find button pressed.

  • 8/6/2019 DB2Demo Program Guide

    24/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 19

    This will result in the command window being modified to show the first example with"union" in the description highlighted:

    The search field turns green to indicate that a value was found. In addition tohighlighting the example, the help panel gets updated, along with the SQL window.The actual SQL does not get executed, as normally would be case if you clicked on anexample. Subsequent values of the keyword can be found by continuing to hit theFIND button on the search panel. The program will continue to search the scripts untilit can longer find the keyword.

    In the event that a keyword cannot be found, the field will turn red:

  • 8/6/2019 DB2Demo Program Guide

    25/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 20

    SQL Input Window

    The DB2 Input window is used to display and execute commands. You can enter anySQL or XQuery in this input window and then hit the RUN key to execute it. Note thatXQuery commands must always start with XQUERY in order for DB2 to properlyexecute it.

    Near the bottom of this screen is the message panel which gets updated with statusinformation:

    If you want additional error information, click anywhere in the status box and a largererror description will be displayed:

  • 8/6/2019 DB2Demo Program Guide

    26/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 21

    Note that the larger error message is only available when running with DB2 9 andgreater.

    At the top of the SQL Input window are a number of buttons.

    The buttons (from LEFT to RIGHT) are:

    Run SQL

    When you hit the Run SQL button it will submit the SQL to DB2 to execute.The types of SQL that you can execute from this program are:

    UPDATE, INSERT, DELETE, CREATE, DROP, DECLARE, VALUES, GRANT,REVOKE, WITH, XQUERY

    You cannot run a LOAD, CONNECT or any utility from this screen. Generally,most SQL will run. The worst that can happen is you get an error messageback from DB2!

    To enter a SQL statement in this window, place the cursor in the input areaand click with the LEFT mouse button, and then start typing. You canseparate multiple SQL commands by placing a ";" at the end of eachstatement:

    select * from employee;select * from department;

    Occasionally you need to use a different delimiter. Triggers and SQL PLstored procedures make use of the semi-colon (;) as a delimiter betweenmultiple statements. In order to support this form of SQL, you cansubstitute a "#", "$", or "@" sign instead.To do this, use the "#" as the first character of your SQL statement andalways place that same character at the beginning of each of your SQLstatements in that block. For instance:

    #select * from employee#select * from department

    When you hit the RUN SQL button, the message window will change toRUNNING and then will show the final message when the SQL is complete.

    If there is any OUTPUT from a command, the OUTPUT window will beupdated. This output window allows both horizontal and vertical scrolling ofdata. Note that output in columns is limited to stop excessive data frombeing returned on SELECT statements.

  • 8/6/2019 DB2Demo Program Guide

    27/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 22

    By default, DB2Demo limits the number of rows returned by any answer setto 1,000. If the maximum row count is exceeded, the program will issue awarning message:

    By pressing YES, the program will return all rows back to the program. Ifthere are a large number of rows in the answer set, this could take a longtime. An additional message is displayed at 10,000 rows, just in case youchange your mind!

    There are additional Non-SQL commands that you can issue in this window:

    o %VIEW SELECT ...

    This command will let you view a field in the database that is largerthan 255 characters. The field is extracted from the SELECT statementand then placed into a separate window.

    o Other commands

    More advanced commands can be found in the Advanced Programmingsection in the online documentation. These additional commands letyou load new scripts into the program, run operating system commands,create menus and a variety of other tasks.

    Load Script

    The Load Script button will load a new SQL file into the DB2Demo program.When you want to load a new set of SQL commands, click on the File buttonand then select the file you want to load from the menu (next page):

  • 8/6/2019 DB2Demo Program Guide

    28/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 23

    When you hit the LOAD button, the file will be loaded into thedemonstration program. If you don't want to change the current set of SQL,just click on the cancel button.

    If the file contains valid DB2DEMO scripts, the SCRIPT panel will getupdated. If the program cannot determine the type of file, it will place thecontents of the file into the SQL input area.

    Clear SQL

    The Clear button clears all SQL from the input area.

    Clear and Paste

    The Clear and Paste button will clear the contents of the current SQL

    window and place the contents of the clipboard into it. If you don't want toclear the contents of the existing window, you should use the standardWindow shortcuts - Cntl-Insert and Shift-Insert to cut and paste.

    Show last command (5)

    The re-cycle button with a 5 in the middle tells the program to retrieve thelast SQL command issued. It keeps a list of the last 5 commands that weretyped in.

    Explain SQL

    DB2 has the Visual Explain facility which gives you a graphical snapshot ofthe way a transaction will run in the database engine. Unfortunately, thisutility can only be invoked directly through the Control Center! Instead ofusing the graphical explain, this button will invoke a textual explain facilitywhich will display a character (text) representation of how a statement will

  • 8/6/2019 DB2Demo Program Guide

    29/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 24

    execute. While not as detailed as a Visual Explain, it can give you somevaluable insight into how the statement will execute.

    Consider the following SQL statement in an SQL window:

    Here is the corresponding explain output:

    Plot Performance

    By clicking on this button, the command in the SQL input window will beexecuted 20 times and the response time plotted in a graph. See the sectionon Performance for more information.

  • 8/6/2019 DB2Demo Program Guide

    30/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 25

    Connect

    If you want to connect to a different database, select the Connectionoption. This will bring up the following screen:

    When you hit the Connect button the program will attempt to connect tothe database using the userid and password that you have supplied. If youdo not supply a userid or password, your default userid will be used as partof the connection.

    Autorun On/Off

    When you click on an example in the SCRIPT panel, it will have the SQLstatements in the example placed into the SQL Input window and executedimmediately if the Autorun button is set. You can change this behavior ifyou want to view the SQL before it gets executed. Pressing the key willchange it to the stop icon .

    Font Size

    If you want to increase the font size, click on the Font Size button. The sizeof the font will increase from a size of 8 points up to 20 points inincrements of 2. Once you click past 20 points, it will go back down to 8points. To change the font size to something outside this range, see theFont button.

  • 8/6/2019 DB2Demo Program Guide

    31/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 26

    Font Type

    The fonts used by the program are controlled by this menu. When pressed,a panel will appear that gives the user the opportunity to change the size ofthe font and the type of font used in the SQL input window:

    Column Width

    By default, the column width is limited to a maximum of 15 characters. Thisvalue can be changed to 20, 25, 30, or cycled back to 10 and then 15. Thecolumn width in the output window can be manually changed by draggingthe line between columns to either the right or left. If the column valuesare too big to display, the column will be highlighted in light blue. In order

    to view the entire value of the column, either expand the size of thecolumn or click on the value you want to view. This will place the value ofthe column into a separate window.

    Column Auto-Complete

    The Column Auto-complete feature automatically spells out column nameswhen a period is pressed after a table name. By default this feature is on.To turn it off, click on the button and it will change to the off setting .

    When typing in a SELECT statement, if the program detects a table name, it

    will attempt to automatically complete the column names for you. Forinstance, the following screen shows the table name EMPLOYEE typed intothe SQL input window:

    Once a period (.) is typed after the EMPLOYEE table name, the first columnname in the table is appended after the period.

  • 8/6/2019 DB2Demo Program Guide

    32/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 27

    Hitting the period (.) again will cycle through the list of all of the columnsin the EMPLOYEE table. The next column is shown:

    Hitting the ESCAPE key will cause the field to disappear and the EMPLOYEEtable name remain with the period behind it:

    As the remainder of the SQL statement is being built, a period at any timewill result in the next column in the table being placed into the SQL text:

    If you need to type in a real period (for a decimal number for instance), usea zero before the decimal point (0.4 instead of .4). You can also press theESCAPE button and the decimal will remain without a column name.

    Hitting the ESCAPE key will cause the field to disappear and the EMPLOYEEtable name remain with the period behind it:

    As the remainder of the SQL statement is being built, typing a period at anytime will result in the next column in the table being placed into the SQLtext:

    If you need to type in a real period (for a decimal number for instance), use

    a zero before the decimal point (0.4 instead of .4). You can also press theESCAPE key and the decimal will remain without a column name.

    In addition to using the period to step through all of the column names, youcan also key in the first letter of the column to quickly display it on thescreen. For instance, returning to the original example of EMPLOYEE. Thefirst column displayed is EMPNO:

  • 8/6/2019 DB2Demo Program Guide

    33/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 28

    Typing the letter "s" or "S" will result in the display changing to SEX:

    Pressing "s" again will change this to SALARY:

    If a letter cannot be found in the column names, nothing will be displayed.You can still press ESCAPE to back out the period and type other characters.

    Trace statements off Trace statements on

    Clicking on the Trace statements button will open up an additional window.

    This window will contain information on every SQL statement executed,including the SQL text and the return code for the statement. This windowcan be used to retrieve old commands (rather than using the Recyclebutton). For more information on the trace window, see the onlinedocumentation.

    SQL Output Window

  • 8/6/2019 DB2Demo Program Guide

    34/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 29

    The SQL Output panel shows the results of the query done in the SQL Input window.To resize a column, click on the column separator on the title line (columndescriptions) and move it to the right or left. This will re-size the individual column.

    If one of the columns is too large to display on the screen (shown in light blue), you

    can left click on the column to have the value placed into a separate window. Forinstance, many of the XML examples produce strings that are too long to display in anormal window. The DB2Demo program has the ability to format the XML to make iteasier to read. For instance, the following panel contains an SQL statement thatcreates a large XML string:

    This SQL results are shown below:

    This does not lend itself well to understanding the structure of the resulting XML! By

    clicking on the large character column, DB2Demo will format it into a separatewindow that is easier to view:

  • 8/6/2019 DB2Demo Program Guide

    35/36

    DB2 Database Demonstration Program Version 9.5

    Copyright 2007, 2008 IBM 30

    Performance Monitoring

    The performance screen is used to see how fast SQL transactions run. To use thisperformance chart, first execute an SQL command in the SQL Input window. Then,click on the performance button to start the performance graph.

    When you click on this button, the SQL found in the SQL Input window will run 20times (no output is displayed during multiple executions) and the performance will becharted.

    Note that the plot shows the number of milliseconds taken to execute the commandand the number at the top right-hand corner is the average execution time of thecommand.

    To stop a performance plot, click on the plot itself. To close the Performance screen,click on the close button at the top of the panel.

  • 8/6/2019 DB2Demo Program Guide

    36/36

    DB2 Database Demonstration Program Version 9.5

    DB2DEMO Program CreditsThis program and documentation was compiled and created by:

    George Baklarz

    DB2 Worldwide Presales Technical SupportIBM Toronto LaboratoryMarkham, ON, CANADA

    I hope you enjoy using this demonstration package, and if you have any questions orcomments, please send them to me at:

    [email protected]

    Thank-you for your time in trying out the DB2 Database Product!