Neoview SQL Reference Manual (R2.5)
NULL clauses. If you omit the DEFAULT clause and specify NOT NULL, Neoview SQL
returns an error. For existing rows of the table, the added column takes on its default
value.
If you set the default to the datetime value CURRENT_DATE, CURRENT_TIME, or
CURRENT_TIMESTAMP, Neoview SQL uses January 1, 1 A.D. 12:00:00.000000 as the
default date and time for the existing rows.
For any row that you add after the column is added, if no value is specified for the column
as part of the add row operation, the column receives a default value based on the current
timestamp at the time the row is added.
[[CONSTRAINT constraint-name] column-constraint]
specifies a name for the column or table constraint. constraint must have the same
schema as table and must be unique among constraint names in its schema. If you omit
the schema portions of the name you specify in constraint, Neoview SQL expands
the constraint name by using the schema for table. See “Database Object Names”
(page 242).
If you do not specify a constraint name, Neoview SQL constructs an SQL identifier as the
name for the constraint in the schema for table. The identifier consists of the fully
qualified table name concatenated with a system-generated unique identifier. For example,
a constraint on table A.B.C might be assigned a name such as A.B.C_123..._01... .
column-constraint options:
CHECK (condition)
is a constraint that specifies a condition that must be satisfied for each row in the
table. See “Search Condition” (page 305). You cannot refer to the CURRENT_DATE,
CURRENT_TIME, or CURRENT_TIMESTAMP function in a CHECK constraint, and
you cannot use subqueries in a CHECK constraint. For information about the CHECK
constraint and string literals, see the Neoview Character Sets Administrator's Guide.
NOT NULL
is a column constraint that specifies that the column cannot contain nulls. If you omit
NOT NULL, nulls are allowed in the column. If you specify both NOT NULL and
NO DEFAULT, each row inserted in the table must include a value for the column.
See “Null” (page 283).
REFERENCES ref-spec NOT ENFORCED
specifies a REFERENCES column constraint. The maximum combined length of the
columns for a REFERENCES constraint is 2048 bytes.
ref-spec is:
referenced-table [(column-list)]
referenced-table is the table referenced by the foreign key in a referential
constraint. referenced-table cannot be a view. referenced-table cannot
be the same as table. referenced-table corresponds to the foreign key in
the table.
column-list specifies the column or set of columns in the referenced-table
that corresponds to the foreign key in table. The columns in the column list
associated with REFERENCES must be in the same order as the columns in the
column list associated with FOREIGN KEY. If column-list is omitted, the
referenced table's PRIMARY KEY columns are the referenced columns.
A table can have an unlimited number of referential constraints, and you can
specify the same foreign key in more than one referential constraint, but you must
define each referential constraint separately. You cannot create self-referencing
foreign key constraints.
NOT ENFORCED is required.
46 SQL Statements