MySQL

How to Drop NOT NULL Constraint in MySQL

In this tutorial, we are going to see how to drop not null constraint in MySQL. To remove the constraint NOT NULL for a column in MySQL, use the statement ALTER TABLE … MODIFY and reformulate the column definition by removing the NOT NULL attribute.
 

Syntax:

Here is the syntax to remove the constraint NOT NULL for a column in MySQL

ALTER TABLE tableName MODIFY columnName VARCHAR(255);

 

 

Example :

Here is an example to remove the constraint NOT NULL for the column “Name” of the “Employee” table:

ALTER TABLE Employee MODIFY Name VARCHAR(20);

To make sure you don’t miss anything, you can use the statement SHOW CREATE TABLE to display the full definition of the column:

SHOW CREATE TABLE Employee;

 

mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *