Site icon TestingDocs.com

MySQL MODIFY COLUMN clause

Overview

We can alter a column definition is to use a MODIFY COLUMN clause. We must specify the name of the column that you want to change, followed by its new definition

Syntax

The general syntax for the statement is a follows:

ALTER TABLE <table_name> MODIFY COLUMN <column_name> <new_definition>

We have to define the column attributes explicitly in the new definition. For example, if we want to disallow NULL in the column, the column definition provided for MODIFY COLUMN must include the NOT NULL attribute, even if the column was originally defined with NOT NULL. This is true for other column attributes as well. If you do not specify them explicitly, the new definition will not carry them from the old column definition.

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

For more information on MySQL Database:

https://www.mysql.com/

Exit mobile version