Background documentationColumn Definition (column_definition) Locate this document in the navigation structure

 

A column definition (column_definition) defines a column in a table. The name and data type of each column are defined by the column name (column_name) and data type (data_type). The column names must be unique within a base table.

Structure

Syntax Syntax

  1. <column_definition> ::=
      <column_name> <data_type> [<column_attributes>]
    | <column_name> <domain_name> [<column_attributes>]
End of the code.
Explanation

If the column attribute (column_attributes) [PRIMARY] KEY is specified, the CREATE TABLE statement must not contain a key definition.

A column definition may only consist of a column name (column_name) if a QUERY expression (query_expression) is used in the CREATE TABLE statement.

<domain_name>

If a column name (column_name) and domain name (domain_name) (in other words, the name of a value range) are specified, the domain name must identify an existing domain. The data type and the length of the domain are assigned to the specified column. If the domain has a CONSTRAINT definition, the effect is the same as if the corresponding CONSTRAINT definition were specified in the column attribute of the column definition.

NOT NULL Columns

Columns which are part of the key, or for which NOT NULL was defined, are called NOT NULL columns. A NULL value cannot be inserted in these columns.

  • Mandatory columns: NOT NULL columns for which a DEFAULT specification has not been declared as a column attribute are called mandatory columns. Whenever rows are inserted, values must be specified for these columns.

  • Optional columns: Columns that are not mandatory are referred to as optional columns. A value does not have to be specified when a row is inserted in these columns. If a DEFAULT specification exists for the column, the DEFAULT value is entered in the column. If there is no DEFAULT specification, a NULL value is entered in the column.