SQL table definition

Informix®

Informix supports primary key, unique, foreign key, default and check constraints.

The constraint naming syntax is different in Informix and most other databases: Informix expects the constraint name after the constraint definition:

CREATE TABLE emp (
  ...
  emp_code CHAR(10) UNIQUE CONSTRAINT pk_emp,
  ...
)
While other SQL database brands require to specify the constraint name before the constraint definition:
CREATE TABLE emp (
   ... 
   emp_code CHAR(10) CONSTRAINT pk_emp UNIQUE, 
   ...
)

IBM® DB2®

IBM DB2 supports primary key, unique, foreign key, default and check constraints.

Constraint naming

The constraint naming clause must be placed before the constraint specification.

The database interface does not convert constraint naming expressions when creating tables from BDL programs. Review the database creation scripts to adapt the constraint naming clauses for DB2.

Primary keys

Like Informix, DB2 creates an index to enforce PRIMARY KEY constraints (some RDBMS do not create indexes for constraints). Using CREATE UNIQUE INDEX to define unique constraints is obsolete (use primary keys or a secondary key instead).

DB2 primary key constraints do not allow NULLs; make sure your tables do not contain NULLs in the primary key columns.

Unique constraints

Like Informix, DB2 creates an index to enforce UNIQUE constraints (some RDBMS do not create indexes for constraints).

DB2 unique constraints do not allow NULLs; make sure your tables do not contain NULLs in the unique columns.

Foreign keys

Both Informix and DB2 support the ON DELETE CASCADE option.

Check constraints

The check condition may be any valid expression that can be evaluated to TRUE or FALSE,including functions and literals. You must verify that the expression is not Informix-specific.

Null constraints

Informix and DB2 support NOT NULL constraints, but Informix does not allow you to give a name to NOT NULL constraints.