AlterTableStudentADD(AddressVarchar(25),PhoneINT,EmailVarcha"/> AlterTableStudentADD(AddressVarchar(25),PhoneINT,EmailVarcha">

Home >Database >Mysql Tutorial >How can we add multiple columns to an existing MySQL table using a single command?

How can we add multiple columns to an existing MySQL table using a single command?

王林
王林forward
2023-09-13 15:29:02679browse

我们如何使用单个命令向现有 MySQL 表添加多个列?

We can also add multiple columns to an existing table with the help of ALTER command. Its syntax is as follows -

Syntax

Alter table table-name ADD (column-name1 datatype, column-name2 datatype,… column-nameN datatype);

Example

In the following example, with the help of ALTER command, the "Address", "Phone" and "E-mail" columns Add to "Students" table'.

mysql> Alter Table Student ADD(Address Varchar(25), Phone INT, Email Varchar(20));
Query OK, 5 rows affected (0.38 sec)
Records: 5 Duplicates: 0 Warnings: 0

The above is the detailed content of How can we add multiple columns to an existing MySQL table using a single command?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete