A primary key is used to uniquely identify each row in a table. When more than one fields are used as a primary key , the key is called a composite key. You can create primary keys in two ways using CREATE TABLE and ALTER TABLE statements. ALTER TABLE ADD UNIQUE or PRIMARY KEY provide a shorthand method of defining a primary key composed of a single column.
If PRIMARY KEY is specified in the definition of column C, the effect is the same as if the PRIMARY KEY (C) clause were specified as a separate clause.
None of the fields that are part of the primary key can contain a null value. To create a primary key in a table , you use the PRIMARY KEY constraint. Typically, you create a primary key for a table when you create that table. In addition, you can add a primary key to a table after the fact by using the ALTER TABLE statement.
If you need to primary key constraint to a table after the fact, simply use the alter table command. Oracle PRIMARY KEY constraint examples. Here the primary key column gets a meaningful name (pk_my_status) instead of a system generated primary key name.