Universal Database (netDB2) Introductory GuideUsing Keys in SQLKey is a set of columns that you can use to identify or access a particular row or rows. A key consists of more than one column is called a composite key. The different types of keys are: UNIQUE KEYS A unique key is defined to have two similar values in any of the tuple values. The columns of a unique key cannot contain null values. This constraint is implemented while programming or inserting data using the "update" and "insert" clauses. There can be multiple unique keys in a database. Unique keys are optional and can be defined in CREATE TABLE or ALTER TABLE statements. PRIMARY KEYS A primary key is a unique key that defines the table. A table cannot have more than one primary key, and the columns of a primary key cannot contain null values. Primary keys are optional and can be defined in CREATE TABLE or ALTER TABLE statements. FOREIGN KEYS A foreign key is specified in the definition of a referential constraint. A table can have zero or more foreign keys. Foreign keys are optional and can be defined in CREATE TABLE statements or ALTER TABLE statements. |