Creating tables with columns based on distinct types

After you define distinct types, you can start creating tables with columns based on distinct types.

Before you begin

For the list of privileges required to define distinct types, see the CREATE DISTINCT TYPE statement.

For the list of privileges required to create tables, see the CREATE TABLE statement.

Procedure

To create a table with columns based on distinct types:

  1. Define a distinct type:
       CREATE DISTINCT TYPE t_educ AS SMALLINT WITH COMPARISONS 
  2. Create the table, naming the distinct type, T_EDUC as a column type.
       CREATE TABLE employee
         (empno CHAR(6) NOT NULL,
          firstnme VARCHAR(12) NOT NULL,
          lastname VARCHAR(15) NOT NULL,
          workdept CHAR(3),
          phoneno CHAR(4),
          photo BLOB(10M) NOT NULL,
          edlevel T_EDUC)
         IN RESOURCE
    To further understand the application of tables, see the following examples of table creation based on sample business cases: