IBM Books

Administration Getting Started


Step 1. Creating a Table

Before you can create a table, you must ensure that a table space exists and that it has sufficient free space. See "Adding an Additional Table Space".

The following example shows you how to use the Create Table SmartGuide. (Or, you can use the Create Table window instead.) To create a table:

  1. From the Control Center, click mouse button 2 on the Tables folder, and select Create -> Table using SmartGuide from the pop-up menu. The Create Table SmartGuide opens.

    Figure 17. Create Table SmartGuide


    * Figure SQLK0CTL not displayed.

    The SmartGuide steps you through the task of creating a table, including naming it, selecting, ordering, and editing columns, selecting table spaces, and selecting a primary key. It provides you with templates for columns which you can use as is or modify. The basic steps are described below. Click on Help at any time if you are unsure how to complete a step.

  2. Identify the schema and a name for the new table.

    A schema provides a logical classification of objects in a database. When a table is created, it is assigned to a schema. See "Creating a Schema".

    Before creating your own objects, you need to consider whether you want to assign them all to the default schema (identified by your user ID) or to a separate schema that logically groups them. In many cases, using a different schema name is very beneficial.

  3. Select columns for your table. The SmartGuide provides sample column definitions.

    1. Select a column list to see the available columns. Use the Edit Lists push buttons to change column defaults to add your own columns to the lists.

    2. Use the > push button to move an available column to the Columns to create list.

    You can now either select Done, or continue on to edit the details of your selected columns with the Edit lists push button.

  4. Optional: Edit column definitions for the new table.

    Choose the order in which you want the columns to appear when the data in the table is listed.

  5. Optional: Define a primary key for the new table.

    Although this step is optional, it is recommended that you define a primary key because table access is quicker if each row can be uniquely identified. A primary key is necessary in order to support updates from many ODBC applications. When you choose a column as the primary key, the database checks each new row for a unique value in that column, rejecting any duplicates. Primary keys are described in "Step 3. Enforcing Business Rules for Data". (To create a foreign key, use the Create Table or Alter Table window. You can invoke these windows by clicking with mouse button 2 on a table icon in the Control Center's object tree and selecting the appropriate action from the pop-up menu. Foreign keys are described in "Step 3. Enforcing Business Rules for Data".)

  6. Optional: Choose space for storing the table data.

  7. Click on the Done push button to create the table.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]