What is a primary key in MySQL?
A primary key is a column (or group of columns) that uniquely identifies each row. It cannot be NULL and cannot repeat. A table can have only one primary key.
CREATE TABLE students (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50) NOT NULL
);
A primary key also gets an index automatically, so searches by it are fast. See MySQL Constraints.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |