Entering content frame

Key Definition (key_definition) Locate the document in its SAP Library structure

A key definition (key_definition) in a CREATE TABLE statement or an ALTER TABLE statement defines the key of a base table. The key definition is introduced by the keywords PRIMARY KEY.

Syntax

<key_definition> ::= PRIMARY KEY (<column_name>,...)

Example

CREATE TABLE person (
  cno FIXED(4),
  firstname CHAR(7),
  name CHAR(7),
  account FIXED(7,2),
PRIMARY KEY (cno))

SQL statement for creating a person table with a one-column primary key for the column 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 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.

See also:

Restrictions for SQL Statements

 

Leaving content frame