MySQL 删除列时会同时删除索引

https://dev.mysql.com/doc/refman/5.6/en/alter-table.html#alter-table-add-drop-column

源文档如下

Adding and Dropping Columns

Use ADD to add new columns to a table, and DROP to remove existing columns. DROP col_name is a MySQL extension to standard SQL.

To add a column at a specific position within a table row, use FIRST or AFTER col_name. The default is to add the column last.

If a table contains only one column, the column cannot be dropped. If what you intend is to remove the table, use the DROP TABLE statement instead.

If columns are dropped from a table, the columns are also removed from any index of which they are a part. If all columns that make up an index are dropped, the index is dropped as well.

猜你喜欢

转载自blog.csdn.net/lbh199466/article/details/88109115