How to Alter Table in SQL?

MySQL ALTER statement is used when you want to change the name of your table or any table field. It is also used to add or delete an existing column in a table. The ALTER statement is always used with “ADD”, “DROP” and “MODIFY” commands according to the situation.

For adding column in table follow the steps below:

Syntax:

The syntax to add a column in a table in MySQL (using the ALTER TABLE statement) is:

ALTER TABLE table_name ADD new_column_name column_definition [ FIRST | AFTER column_name ];

  • table_name: The name of the table to modify.
  • new_column_name: The name of the new column to add to the table.
  • column_definition: The datatype and definition of the column (NULL or NOT NULL, etc).
  • FIRST | AFTER column_name: Optional. It tells MySQL where in the table to create the column. If this parameter is not specified, the new column will be added to the end of the table.