How is the “add column” functionality used in MySQL?
In MySQL, the ADD COLUMN statement is used to add a new column to a table.
The grammar is as follows:
ALTER TABLE table_name
ADD COLUMN column_name column_definition;
In which table_name is the name of the table where the column is to be added, column_name is the name of the column to be added, and column_definition is the definition specifying the data type and other properties of the column.
For example, to add a new column named “age” of integer data type in a table called “employees”, you can use the following statement:
ALTER TABLE employees
ADD COLUMN age INT;
Please note that the ADD COLUMN statement can only be used on existing tables, and multiple columns cannot be added in the same statement. If you wish to add multiple columns, you will need to execute separate ADD COLUMN statements for each one.