1) ADD a column in the table
Syntax:
ALTER TABLE table_name
ADD new_column_name column_definition
[ FIRST | AFTER column_name ];
Parameters
table_name: It specifies the name of the table that you want to modify.
new_column_name: It specifies the name of the new column that you want to add to the table.
column_definition: It specifies the data type and definition of the column (NULL or NOT NULL, etc).
FIRST | AFTER column_name: It is 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.
Example:
In this example, we add a new column “cus_age” in the existing table “cus_tbl”.
Use the following query to do this:
ALTER TABLE cus_tbl
ADD cus_age varchar(40) NOT NULL;
Output:
See the recently added column:
SELECT* FROM cus_tbl;
Output: