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?

王林
Release: 2023-09-13 15:29:02
forward
740 people have browsed it

我们如何使用单个命令向现有 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);
Copy after login

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
Copy after login

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 of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template