ASA SQL User's Guide
Designing Your Database
Designing the database table properties
Although the data type of a column restricts the values that are allowed in that column (for example, only numbers or only dates), you may want to further restrict the allowed values.
You can restrict the values of any column by specifying a CHECK constraint. You can use any valid condition that could appear in a WHERE clause to restrict the allowed values. Most CHECK constraints use either the BETWEEN or IN condition.
For more information about valid conditions, see Search conditions. For more information about assigning constraints to tables and columns, see Ensuring Data Integrity.
The sample database has a table called Department, which has columns named dept_id, dept_name, and dept_head_id. Its definition is as follows:
Column | Data Type | Size | Null/Not Null | Constraint |
---|---|---|---|---|
dept_id | integer | — | not null | None |
dept_name | char | 40 | not null | None |
dept_head_id | integer | — | null | None |
If you specify NOT NULL, a column value must be supplied for every row in the table.