Fujitsu J2X0-2273-01EN Server User Manual


 
Example:
Sample table constraint specification for a group of columns
The STOCK table for which the unique constraint of this example has been specified cannot have rows such as [3]
and [4] in Figure: Sample data that violates the unique constraint. Rows [3] and [4] in Figure: Sample data that violates
the unique constraint violate the unique constraint because they both have 123 as the ITMNO and they both have
REFRIGERATOR as the PRODUCT. Rows [1] and [2] do not violate the unique constraint because the ITMNO values
differ even though the PRODUCT value is the same. Similarly, rows [5] and [6] and rows [7] and [8] do not violate the
unique constraint. If the unique constraint were specified only for the ITMNO column, then rows [3] and [4] and rows
[5] and [6] in Figure: Sample data that violates the unique constraint would violate the unique constraint.
[Figure: Sample data that violates the unique constraint]
PRIMARY KEY
One or a combination of columns used for determining that a row in a table is unique is called a primary key. The
value specified for primary keys must be unique for each row in a table. The specification format is as follows.
NOT NULL must already be specified in the column definition for any column for which PRIMARY KEY is specified.
PRIMARY KEY can only be specified once within a table definition.
The next example specifies the unique constraint related to the ITMNO column of the STOCK table as a table
constraint.
Example:
Sample unique constraint specification for the ITMNO column as a table constraint
40