MySQL

How to Change the Data Type for a Column in MySQL

In this tutorial, we are going to see how to change the data type for a column in MySQL. The ALTER TABLE statement is used to add, remove or modify columns in an existing table. Here is the Syntax to change the data type for a column in MySQL table:

ALTER TABLE tableName
    MODIFY columnName type
      [ FIRST | AFTER columnName ];

 

 

How to Change the Data Type for a Column in MySQL

The following query will change the data type for the column “address” to be of type varchar(100) and force the column to allow NULL values.

ALTER TABLE users
  MODIFY address varchar(100) NULL;
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 *