db2-Tools & Scripting

Embed Size (px)

Citation preview

  • 8/10/2019 db2-Tools & Scripting

    1/22

    IBM Software Group

    2005 IBM Corporation

    Lesson 3: Tools & ScriptingPart 1 of 2

    (DB2 on Campus Lecture Series)

    Raul F. Chong

    IBM Toronto Laboratory

  • 8/10/2019 db2-Tools & Scripting

    2/22

    IBM Software Group | DB2 Information Management Software

    2

    Agenda

    Introduction

    Control CenterCommand Editor

    Command Window / CLP

    Task Center

    Journal

    Health CenterScripting

  • 8/10/2019 db2-Tools & Scripting

    3/22

    IBM Software Group | DB2 Information Management Software

    3

    Agenda

    Introduction

    Control CenterCommand Editor

    Command Window / CLP

    Task Center

    Journal

    Health CenterScripting

  • 8/10/2019 db2-Tools & Scripting

    4/22

    IBM Software Group | DB2 Information Management Software

    4

    DB2:The bigPicture DB2 Environment

    SQL/XML, XqueryStatements

    create bufferpool

    create tablespace

    create table

    alter bufferpool

    alter tablespace

    alter table

    selectinsert

    update

    delete

    ...

    DB2 System Commands

    db2set

    db2startdb2stop

    db2ilist

    db2icrt

    db2idrop

    ...

    DB2 CLP Commands

    db2 update dbm cfg

    catalog db list node directory

    create database

    list applications

    list tablespaces

    ...

    xquery < >

    Command Line ToolsCommand Editor

    Command Line Processor

    Command Window

    Development Tools

    DB2 Developer Workbench

    Project Deployment Tool

    General Administration Tools

    Control Center

    Journal

    License Center

    Replication Center

    Task Center

    InformationInformation Center

    Check for DB2 Updates

    Monitoring Tools

    Event Analyzer

    Health Center

    Indoubt Transaction Manager

    Memory VisualizerActivity Monitor

    Setup Tools

    Configuration Assistant

    Configure DB2 .Net Data Provider

    Default DB2 Selection Wizard

    First Steps

    Register Visual Studio Add-ins

    DB2 ToolsDB2 Commands & SQL/XML,Xquery Statements

    Port

    Database Manager

    Configuration

    File (dbm cfg)

    Instance 'myinst'

    Database

    Configuration

    File (db cfg)

    Database MYDB1

  • 8/10/2019 db2-Tools & Scripting

    5/22

    IBM Software Group | DB2 Information Management Software

    5

    DB2 ToolsStart Programs IBM DB2 ...

  • 8/10/2019 db2-Tools & Scripting

    6/22

    IBM Software Group | DB2 Information Management Software

    6

    Agenda

    Introduction

    Control CenterCommand Editor

    Command Window / CLP

    Task Center

    Journal

    Health CenterScripting

  • 8/10/2019 db2-Tools & Scripting

    7/22

    IBM Software Group | DB2 Information Management Software

    7

    Control Center

    The main DB2 administration tool

    The Control Center allows you to:

    create, modify and manage databases

    Manage database objects (tables, indexes, etc.)Launch the other GUI tools

  • 8/10/2019 db2-Tools & Scripting

    8/22

    IBM Software Group | DB2 Information Management Software

    8

    Launching Control Center for the First Time The first time Control Center is launched, you are asked to choose what

    view you would like to use

    The choice of view determines what types of options and database objects

    are exposed

  • 8/10/2019 db2-Tools & Scripting

    9/22

    IBM Software Group | DB2 Information Management Software

    9

    Launching the Control Center Navigating through the Windows Startmenu

    By executing db2ccon a command prompt

    By clicking the Control Center icon in the toolbar of any of the other

    DB2 GUI tools

    From the DB2 icon in the Windows system tray

    Right click on the green DB2 iconand select the DB2 Control Centermenu option

  • 8/10/2019 db2-Tools & Scripting

    10/22

    IBM Software Group | DB2 Information Management Software

    10

    Control Center

    Object Tree

    Pane

    Object Listing

    Pane

    Object Details

    Pane

  • 8/10/2019 db2-Tools & Scripting

    11/22

    IBM Software Group | DB2 Information Management Software

    11

    Changing to Control Centers Advanced View

    Control Center > Tools (menu) > CustomizeControl Center > (select) Advanced

  • 8/10/2019 db2-Tools & Scripting

    12/22

    IBM Software Group | DB2 Information Management Software

    12

    Advanced Control Center View

    Note theAdditionalDatabaseObjects

  • 8/10/2019 db2-Tools & Scripting

    13/22

    IBM Software Group | DB2 Information Management Software

    13

    Agenda

    Introduction

    Control CenterCommand Editor

    Command Window / CLP

    Task Center

    Journal

    Health CenterScripting

  • 8/10/2019 db2-Tools & Scripting

    14/22

    IBM Software Group | DB2 Information Management Software

    14

    Command Editor

    Using Command Editor, you can execute DB2 commands and SQL, analyze

    the execution plan of an SQL statement, and view/update query result sets You can launch Command Editor several ways:

    As a standalone application

    Navigate through the Windows Start Menu

    START -> PROGRAMS -> IBM DB2 -> COMMAND LINE TOOLS ->

    COMMAND EDITOR From a command prompt, type db2ce

    From the Control Center, click the Command Editor icon on the Control Center

    Toolbar

    From the Tools menu in Control Center

  • 8/10/2019 db2-Tools & Scripting

    15/22

    IBM Software Group | DB2 Information Management Software

    15

    Command Editor (continued)

    Embedded within the Control Center

    Right click on the SAMPLE database icon in the Control Centers Object Tree pane

    and select the Querymenu item

    Any time a queryable object is selected (database, table, etc.), you can launch the

    Command Editor by clicking the Querylink in the Control Centers Object Detail pane

    Input area

    Output area

    Database currentlyconnected to

    Character used todelimit the end of aSQL statement or

    DB2 command

    Back to Control

    Center view

    Command Editor

    view selected

    Add a databaseconnection

  • 8/10/2019 db2-Tools & Scripting

    16/22

    IBM Software Group | DB2 Information Management Software

    16

    Command Editor Add (database connection) Dialog

    A database connection must exist in order to submit any SQL statements

    You can inherit the connection from Control Center (by launching Command

    Editor in embedded mode) or by clicking theAddbutton in Command Editor

    Valid OS user ID andpassword

    Select a databaseconfigured on the system

    Check this box to usethe ID and password

    of user currentlylogged in to theoperating system

  • 8/10/2019 db2-Tools & Scripting

    17/22

    IBM Software Group | DB2 Information Management Software

    17

    Command Editor Commands Tab

    Runs the command(Can also use theCTRL+Enter shortcut)

    Runs the command andgenerates an access plan(more on this later)

    Generates an accessplan without running thecommand (more on thislater)

  • 8/10/2019 db2-Tools & Scripting

    18/22

    IBM Software Group | DB2 Information Management Software

    18

    The SQL Assist Wizard

    SQL Assist Wizard

    can also be launchedfrom the Selectedmenu item

  • 8/10/2019 db2-Tools & Scripting

    19/22

    IBM Software Group | DB2 Information Management Software

    19

    SQL Assist Wizard

    Sections of theSQL Query.

    The queryconstructed so far.

  • 8/10/2019 db2-Tools & Scripting

    20/22

    IBM Software Group | DB2 Information Management Software

    20

    Show SQL Button

    Most of the GUI tools/wizards allow you to see the actual command or

    SQL statement that is created as a result of using the tool/wizard to

    perform an action

    This is very handy for:

    Learning SQL syntax

    Saving the statement to a file (or the Windows clipboard) for later use

    can be later imported directly into Command Editor

  • 8/10/2019 db2-Tools & Scripting

    21/22

    IBM Software Group | DB2 Information Management Software

    21

    Quicklab #4 Populating the EXPRESS Databaseusing scripts

    In this QuickLab, you will create a simpleinstallation script for the EXPRESS database and itsobjects

    Refer to the QuickLab #4 instructions

  • 8/10/2019 db2-Tools & Scripting

    22/22

    IBM Software Group | DB2 Information Management Software

    22

    To be continued

    Please see Part 2 of 2 ofthis lesson