1
ALTER TABLE table_name DROP COLUMN field1, field2

Как удалить несколько столбцов из таблицы за один запрос?

1 ответ 1

4

Вы почти угадали. Надо вот так:

ALTER TABLE table_name
DROP Column1, DROP Column2

Источник: https://dev.mysql.com/doc/refman/5.7/en/alter-table.html

Multiple ADD, ALTER, DROP, and CHANGE clauses are permitted in a single ALTER TABLE statement, separated by commas. This is a MySQL extension to standard SQL, which permits only one of each clause per ALTER TABLE statement. For example, to drop multiple columns in a single statement, do this:

ALTER TABLE t2 DROP COLUMN c, DROP COLUMN d;

1

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.