列名是唯一正在改变的东西...... MySQL会重建那个索引吗?
答案 0 :(得分:1)
对于C-ISAM不会这么认为,对INNODB不确定。你尝试的时候会发生什么?
答案 1 :(得分:1)
create table t1(id int, name varchar(100));
alter table t11 add index name_idx(name);
mysql> show create table t11;
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
| t11 | CREATE TABLE `t11` (
`id` int(11) DEFAULT NULL,
`name` varchar(100) DEFAULT NULL,
KEY `name_idx` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
alter table t11 change column name name1 varchar(100);
mysql> show create table t11;
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| t11 | CREATE TABLE `t11` (
`id` int(11) DEFAULT NULL,
`name1` varchar(100) DEFAULT NULL,
KEY `name_idx` (`name1`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql会自动更改u的索引 并且不重建索引