DDL Primary key
DDL Primary key
Primary key is -
- Uniquely identified column which is used to identify the row uniquely is known as primary key.
- Primary key can be defined during the CREATE TABLE or ALTER TABLE.
- Primary keys definition is optional in CREATE TABLE or ALTER TABLE.
- Primary key is unique key and cannot contain NULL values.
- Primary key can be only one column or more than one column.
- The index on Primary key is called as Primary index.
- If primary key is created on the specific table, the primary index will be automatically created by DB2.
Rules -
- No duplicates are allowed under primary key.
- Only one designated primary key can be available in a table.
- Null values or junk values are not allowed under primary key.
Syntax -
PRIMARY KEY(Column1, column2…)