MySQL DatabaseLesson 55Free preview
MySQL Primary Key
This lesson is part of MySQL · All levels
Summary
A PRIMARY KEY is a column (or a combination of columns) that is the unique identity of each row in a table. The property is always UNIQUE and NOT NULL, so no two rows should have the same primary key value. The combination of AUTO_INCREMENT with the primary key makes the new line numbering automatic.
Key points
- The primary key is unique and not simultaneous.
- A table can only have one primary key, even if it can consist of several columns.
- The primary key combines several columns called the composite primary key
- Added with the Add Primary Key or live at CREATE TABLE
- Primary key becomes a foreign key reference on another table
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.