Table Column Element

Function:

A table column element completely defines a base table column.

Invocation:

This is part of the table element and of the alter add element (ALTER TABLE Statement).

Syntax:

table_column_element.bmp
 

column_identifier

A valid identifier for a column and must conform to the rules specified earlier in Identifiers and Column Specification.

data_type

Specifies the data type of the column according to the rules specified below in SQL Data Types and Adabas Data Types.  

column_constraint_element

Optional. Specifies constraints such as UNIQUE, NOT NULL, PRIMARY KEY, etc. See Column Constraint Element.

column_index_element

Optional. Specifies an index for a column.  See Column Index Element.

column_physical_element

Optional. Describes the Adabas-specific information for each column, such as the short name, suppression, etc. See Column Physical Element.

 

Description:

The table column element specifies one column of a table with the attributes of this column (examples of attributes are constraints and indexes).

For each column, the column identifier and the data type definition are minimum requirements for the CREATE TABLE, CREATE CLUSTER or ALTER TABLE statements.

The column identifier must be a valid Adabas short name, else it is required to specify the Adabas short name (part of column physical element).

By default, all columns that do not have the explicit attribute NOT NULL, have implicitly the attribute NULL. There are two exceptions:

In CREATE TABLE DESCRIPTION and CREATE CLUSTER DESCRIPTION statements, any unspecified attributes that belong to the underlying Adabas field are automatically generated.

 

Limitations:

The column identifier must be unique within a table.

The following must be unique within a schema:

If a CREATE TABLE or CREATE CLUSTER statement is issued, then a table may only contain 926 columns. For CREATE TABLE DESCRIPTION and CREATE CLUSTER DESCRIPTION statements this limitation is lifted; you may specify elements of a PE or MU in a rotated format.

If a column has a Character data type and a precision greater than 253 characters, then the following must be true:

You cannot combine the following attribute pairs:

The table below shows which parts of table column element are optional for which statements.

 

Statement

Data Type Definition

Column Constraint Element

Column Index Element

Column Default Element

Column Physical Element

Create Table

Create Cluster

Mandatory

Optional

Optional

Optional

Optional (1)

Create Table

Description

Create Cluster

Description

Optional

Optional

Optional

Optional

Optional (2)

Alter Table

Mandatory

Optional (3)

Optional

Optional

Optional (4)

 

(1) The SHORTNAME specification is not allowed in this statement.

(2) The SHORTNAME specification is mandatory for this statement.

(3) The NOT NULL attribute is allowed when combined with either DEFAULT ADABAS or SUPPRESSION.

(4) The only attributes allowed in this statement are NULL and SUPPRESSION.

 

ANSI Specifics:

The following elements are not part of the standard:

Adabas SQL Gateway Specifics:

None.

 

Example:

The following example creates one column of the base table CRUISE.

 

CREATE TABLE cruise

  (cruise_id NUMERIC(8) INDEX cruise1 NOT NULL UNIQUE);

 

Access to the underlying Adabas ISN is available via the pseudo column ISN_tablename, i.e. ISN_cruise.