A key definition in a
CREATE TABLE statement or an ALTER TABLE statement defines the key in a base table. The key definition is introduced by the keywords PRIMARY KEY.Syntax
<key_definition> :: PRIMARY KEY (<column_name>,...)
column_nameSQL statement for creating a
person table with a one-column primary key for the column cno:CREATE TABLE person (cno FIXED(4), firstname CHAR(7), name CHAR(7), account FIXED(7,2), PRIMARY KEY (cno))
Rows are inserted in the same way as in a base table without a key definition. Double entries for the customer number, however, are rejected.
Explanation
The column name must identify a column in the base table. The specified column names are key columns in the table.
A key column must not identify a column of the data type
LONG and is always a NOT NULL column. The database system ensures that no key column has a NULL value and that no two rows of the table have the same values in all key columns.The sum of the internal lengths of the key columns must not exceed 1024 characters.