What is the statement for deleting a column in MySQL?

To remove a column from a MySQL table, you can use the ALTER TABLE statement with the DROP COLUMN clause. Here is the syntax for deleting a column:

ALTER TABLE 表名

DROP COLUMN 列名;

In this case, you need to replace the table name with the name of the table containing the column you want to delete, and replace the column name with the name of the column you want to delete.

Please note that deleting a column will permanently remove the column and its associated data from the table, so be sure to back up or confirm the data is backed up before performing this operation.

If you need to delete multiple columns, you can use multiple DROP COLUMN clauses in a row, or separate multiple column names with commas. For example:

ALTER TABLE 表名

DROP COLUMN 列1,

DROP COLUMN 列2;

This will delete multiple columns from the table at once.

bannerAds