Check out example codes for "MySQL Primary Key". It will help you in understanding the concepts better.

Code Example 1

Typically, you define the primary key for a table in the CREATE TABLE statement.

If the primary key has one column, you can use the PRIMARY KEY constraint as a column constraint:

CREATE TABLE table_name(
    primary_key_column datatype PRIMARY KEY,

Code Example 2

# Adding primary key to existing table
ALTER TABLE table_name ADD PRIMARY KEY(primary_key_id)

Code Example 3

ALTER TABLE tableName MODIFY COLUMN id INT; /* First you should drop auto increment */
ALTER TABLE tableName DROP PRIMARY KEY; /* Dop primary key */
ALTER TABLE tableName ADD PRIMARY KEY (new_id); /* Set primary key to the new column */
ALTER TABLE tableName MODIFY COLUMN new_id INT AUTO_INCREMENT; /* Set auto increment to the new primary key */

Code Example 4

ALTER TABLE tbl_quiz_attempt_master

Learn ReactJs, React Native from