Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Primary keys - the basics
7. Primary keys - summary
Single-column primary keys
Multicolumn primary keys
Auto-increment columns and sequences


Good! Again, we failed to add the new row. The database won't let us add a NULL value as the primary key.

So, to sum up what we've learned so far:

  1. the primary key always must have a value, it can't be a NULL,
  2. there can only be one row with a given primary key value.

In the next parts of the course, you will find out that we use the primary key to refer to the table from other tables.

It is worth noting that when we create a primary key, an index is also created. It is a data structure which facilitates data selection and sorting in the table. Indexes are outside the scope of this course, but they are an important part of database design.


Click the Next exercise button to continue.