Column Constraint Declarations

Column constraints restrict the values that can be legally stored in a column. The clauses used to do this are shown following in the syntax portion.

col_constraint:
        [CONSTRAINT constraint_name] col_constraint_type
col_constraint_type:
        [NOT] NULL | key_spec
    |   refs_spec

Components

constraint_name Optional name for a column constraint.
NULL The column is allowed to contain null values. This is the default constraint and is not required. For more information on NULL values, refer to the NULL Values section.
NOT NULL The column is not allowed to contain null values. This means that either a default clause must be specified for the column (of course, DEFAULT NULL is not allowed) or a value for the column must always be specified in an INSERT statement on the table. For more information on NULL values, refer to the NULL Values section.
key_spec Indexes can be defined to allow for fast navigation or to guarantee no duplicate entries depending on the index type. For more information, refer to the Key (Index) Specification section.
refs_spec References (foreign indexes) can be defined to allow for fast navigation based on relationship or to validate a correct range of data values for a given field or column. For more information, refer to the Foreign Key (References) Specification section.