Show TOC

Key Definition (key_definition)Locate this document in the navigation structure

Use

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.

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

Examples

SQL Tutorial, Primary Key

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 LOB 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.