Answer: The NOT NULL Constraint
Find a detailed explanation of how to set up the NOT NULL constraint.
We'll cover the following...
We'll cover the following...
Solution
The solution is given below:
MySQL
/* Modifying the column EmpName to be NOT NULL */ALTER TABLE EmployeesMODIFY COLUMN EmpName VARCHAR (100) NOT NULL;/* Modifying the column Salary to be NOT NULL */ALTER TABLE EmployeesMODIFY COLUMN Salary DECIMAL (10,2) NOT NULL;/* Describe the structure of the table */DESC Employees;
Explanation
The explanation of the solution code is given below:
Lines 2–3: The
ALTER TABLEmake changes to an already existingEmployeestable. TheMODIFY COLUMNmodifies the columnEmpNamecolumn to beNOT NULL.Lines 6–7: The
ALTER TABLEmake changes to an already existingEmployeestable. TheMODIFY COLUMNmodifies the columnSalarycolumn to beNOT NULL.Line 10:
DESCelaborates the ...