O'Reilly logo

SQL: Visual QuickStart Guide by Chris Fehily

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Specifying a Primary Key with PRIMARY KEY

I described primary keys in “Primary Keys” in Chapter 2, but I’ll review the basics here:

  • A primary key uniquely identifies each row in a table.

  • No two rows can have the same primary-key value.

  • Primary keys don’t allow nulls.

  • Each table has exactly one primary key.

  • A primary key is a column or a set of columns. A simple primary key comprises a single column; a composite primary key comprises multiple columns.

  • In a composite key, values can be duplicated within one column, but each combination of values from all the key’s columns must be unique.

  • A table can have more than one combination of columns that uniquely identify its rows; each combination is a candidate key. The database designer picks one of the candidate ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required