[ Home | Contact ]

SQL: Visual QuickStart Guide, 3rd Edition

SQL 3/e cover

Creating the Sample Database - IBM DB2 8.x

To create books in IBM DB2 8.x:

  1. Start Control Center.

    This procedure varies by platform. In Windows, for example, choose Start > All Programs > IBM DB2 > General Administration Tools > Control Center. In Unix or Linux, use the command db2cc.

  2. In the left pane, expand the object tree until you find the Databases folder.

    Control Center's object tree lets you display and work with system and database objects.

  3. Right-click the Databases folder; then choose Create > Database Using Wizard from the pop-up menu.

    The Create Database wizard opens.

    Control Center
  4. On the Name page, type books in the Database Name box; specify a destination; then click Finish.

    (The default settings are fine for the sample database; there's no need to step through the entire wizard.)

    A progress box appears while DB2 creates the database.

    Name page
  5. Click No in the message box that appears when DB2 finishes creating the database.

    The new database books appears in the Databases folder in Control Center.

  6. Open a command prompt (shell), type
    db2sql92 -d books -f books_db2.sql
    and then press Enter. The -f option specifies the name of the SQL file. You can include an absolute or relative pathname (see the "Pathnames" sidebar in "Running SQL Programs" in Chapter 1). You can add the option -a user[/password] to connect to the database as a specific user.

    db2sql92 displays the results. Ignore the messages about undefined names (nonexistent tables) — they're caused by the script's DROP TABLE statements, which you'll need to rerun books_db2.sql later to restore the tables to their original states.

    db2sql92
  7. To run SQL scripts and interactive statements against books, see "IBM DB2" in Chapter 1.

Tips