开发者

Does MySQL rebuild a column's index, if the column is renamed?

开发者 https://www.devze.com 2023-02-22 05:16 出处:网络
The column name is the only thing that is changing... will MySQL rebuild that开发者_StackOverflow index?create table t1(id int, name varchar(100));

The column name is the only thing that is changing... will MySQL rebuild that开发者_StackOverflow index?


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 will auto change the indexes for u and does not rebuild index


Wouldn't have thought so for C-ISAM, not sure about INNODB. What happens when you try it?

0

精彩评论

暂无评论...
验证码 换一张
取 消