How to delete multiple columns in MySQL?
To delete multiple columns in MySQL, you can use the DROP COLUMN clause in the ALTER TABLE statement. Here are the steps for deleting multiple columns.
- Confirm the table name of the field you want to delete.
- Specify the table name where you want to delete a field using the ALTER TABLE statement.
- Use the DROP COLUMN clause and specify the name of the field to be deleted, separating multiple field names with commas.
- By executing the ALTER TABLE statement, you can delete multiple columns.
Here is an example:
ALTER TABLE 表名
DROP COLUMN 字段名1,
DROP COLUMN 字段名2,
DROP COLUMN 字段名3;
Please replace the “table name” in the example with the actual table name, and replace “field name 1”, “field name 2”, “field name 3” with the field names to be deleted. By executing the above SQL statement, multiple fields can be deleted.