2) Add multiple columns in the table
Syntax:
ALTER TABLE table_name
ADD new_column_name column_definition
[ FIRST | AFTER column_name ],
ADD new_column_name column_definition
[ FIRST | AFTER column_name ],
…
;
Example:
In this example, we add two new columns “cus_address”, and cus_salary in the existing table “cus_tbl”. cus_address is added after cus_surname column and cus_salary is added after cus_age column.
Use the following query to do this:
ALTER TABLE cus_tbl
ADD cus_address varchar(100) NOT NULL
AFTER cus_surname,
ADD cus_salary int(100) NOT NULL
AFTER cus_age ;
See the recently added columns:
- SELECT* FROM cus_tbl;