Answer: The PRIMARY KEY Constraint
Find a detailed explanation of how to apply primary key constraint on a table.
Solution
The solution is given below:
Press + to interact
MySQL
/* The query to modify the existing table's settings */ALTER TABLE EmployeesMODIFY EmpID INT AUTO_INCREMENT PRIMARY KEY;/* Retrieve the structure of the table */DESC Employees;
Explanation
The explanation of the solution code is given below:
Line 2: The
ALTER TABLEquery modifies a table. TheMODIFYclause specifies which column to modify. TheAUTO_INCREMENTsets the column to increase the number automatically when a new row is added. Finally,PRIMARY KEYsets the column to beNOT NULL, and it will be used as a primary key.Line 5: The
DESC...
Ask