Previous Topic: Data TypesNext Topic: Example 2


Example 1

Some examples of using the CREATE TABLE statement are:

Create a table with the following specifications:

  1. Authorization ID: JOE

    The example assumes that JOE is the default authorization ID in effect when the statement is executed. In this case, it is not necessary to specify the authorization ID.

  2. Table name: DEPTTBL
  3. Column names: DEPTNO, DEPTNAME, MGRNBR, ADMDEPT
  4. Data type: CHAR for all columns
  5. Area name: CASQLDEFAULT

    The default area name is specified, although it is not necessary. If you do not specify an area name, the table is automatically placed in the default area. You must specify the area name if you want to place the table in an area other than the default.

    EXEC SQL
          CREATE TABLE DEPTTBL
               (DEPTNO CHAR(2),
                DEPTNAME CHAR(24),
                MGRNBR CHAR(6),
                ADMDEPT CHAR(2))
          IN CASQLDEFAULT
    END-EXEC