1. Home
  2. MySQL Tutorials
  3. MySQL ALTER Table

MySQL ALTER Table

As the word alter implies literarily, it also applies in the MySQL context. The ALTER TABLE statement is applicable in a scenario where you intend to alter or change the name of an already existing table or the name of its field. Also, the ALTER TABLE statement when used with commands such as “ADD”, “MODIFY” or “DROP”, results in the creation of certain features.

For instance, the ADD command when used with the ALTER TABLE statement will
result in an additional table column.

Syntax:

ALTER TABLE table_name ADD new_column_name column_definition;

In the same vein, to modify the definition of a column, the MODIFY command is used along with the ALTER TABLE statement.

Syntax:

ALTER TABLE table_name MODIFY new_column_name column_definition;

Lastly, ALTER TABLE statement coupled with DROP command will drop column
names into a table.

Syntax:

ALTER TABLE table_name DROP COLUMN column_name;

 

 

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.