VISUAL QUICKSTART GUIDE SQL Second Edition [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

VISUAL QUICKSTART GUIDE SQL Second Edition [Electronic resources] - نسخه متنی

Chris Fehily

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
توضیحات
افزودن یادداشت جدید


"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">








  • IBM DB2


    IBM DB2 Universal Database is a leading commercial DBMS. It supports very large databases and numbers of transactions. It runs on many operating systems and hardware platforms and is complex enough to require a full-time database administrator to run and maintain it.

    You can learn about DB2 products at www.ibm.com/db2. Click the Trials and Betas link to download a free trial edition. Several editions of DB2 are available; the Personal Edition is a free, single-user version.

    This book covers DB2 8. To determine which version of DB2 you're running, run the DB2 command-line command db2level.

    You can use the Command Center graphical tool or the db2 command-line processor (CLP) to run SQL programs.

    To use Command Center



    1.

    Start Command Center.

    This procedure varies by platform. In Windows, for example, choose Start > All Programs > IBM DB2 > Command Line Tools > Command Center. In Unix, use the command db2cctr.

    Alternatively, if Control Center is open, choose Tools > Command Center or click .

    2.

    Choose the command-type SQL Statements and DB2 CLP Commands.

    3.

    Click the Interactive tab if necessary.

    4.

    In the Database Connection box, click ; expand the object tree until you find the Databases folder; select a database; then click OK.

    5.

    To run SQL interactively, in the Command box, type or paste an SQL statement (

    Figure 1.18 ).

    Figure 1.18. A ready-to-run SELECT statement in Command Center.

    [View full size image]

    or

    To run an SQL script, click the Scripts tab; choose Script > Import; navigate to and select the script file; then click OK.

    6.

    Click or press Ctrl+Enter.

    or

    Choose Interactive > Execute or Script > Execute.

    Interactive-SQL results appear in the Results tab (

    Figure 1.19 ). SQL-script results appear in the box below the Script box.

    Figure 1.19. The results of the SELECT statement.


    For technical reasons involving parent and child processes, (only) Microsoft Windows users must start the db2 command-line processor with a special preliminary step.

    To start the db2 command-line processor in Windows


      Tips

      • You must use the DB2 CLP window for all db2 commands (described next). If you try to run db2 at a normal Windows command prompt, DB2 responds with the error "Command line environment not initialized."

      • In the DB2 CLP window, change (cd) your working directory if necessary before you run db2 commands.

      To use the db2 command-line processor interactively



      1.

      At a command prompt, type


      db2 -t

      and then press Enter. The -t option tells db2 that a semicolon (;) terminates statements.

      The db2 => prompt appears.

      2.

      At the db2 prompt, type


      connect to

      dbname ;

      and then press Enter.

      dbname is the name of the database to use.

      3.

      Type an SQL statement. The statement can span multiple lines. Terminate it with a semicolon and then press Enter to display the results (

      Figure 1.20 ).

      Figure 1.20. The same SELECT statement in db2 interactive mode.


      Tip

      • Alternatively, you can avoid the db2 => prompt by typing commands and SQL statements right on the command-line. For example:


        db2 connect to books
        db2 SELECT * FROM authors

        If you omit the -t option, as here, don't terminate commands and SQL statements with a semicolon.

      To use the db2 command-line processor in script mode



      1.

      At a command prompt, type:


      db2 connect to

      dbname

      dbname is the name of the database to use.

      2.

      At a command prompt, type:


      db2 -t -f sql_script

      sql_script is a text file containing SQL statement(s) and can include an absolute or relative pathname. The -t option tells db2 that a semicolon (;) terminates statements.

      3.

      Press Enter to display the results (

      Figure 1.21 ).

      Figure 1.21. The same SELECT statement in db2 script mode.


      Tips

      • In step 2, add the -v option if you want to echo the contents of

        sql_script in the output.

      • Two alternative script utilities are db2sql92 and db2batch.

      To exit the db2 command-line utility


        To show db2 command-line options



    • / 169