Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The new MySQL5.7 feature changes the index name without locking the table

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

MySQL5.7 does not lock the table when changing the index name. The test procedure is as follows:

Click (here) to collapse or open

Mysql > select count (*) from T_USER_INFO

+-+

| | count (*) |

+-+

| | 7147528 |

+-+

Click (here) to collapse or open

Mysql > select version ()

+-+

| | version () |

+-+

| | 5.7.18-log |

+-+

Click (here) to collapse or open

Mysql > show create table T_USER_INFO\ G

* * 1. Row *

Table: T_USER_INFO

Create Table: CREATE TABLE `Tunable USERINFO` (

`NAME` varchar (50) DEFAULT NULL

`PHONE` varchar (50) DEFAULT NULL

`CARD_ ID`varchar (50) DEFAULT NULL

KEY `USER_ name` (`USER_ name`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8

1 row in set (0.00 sec) now open two windows and enter the MySQL command line at the same time

Window one:

Click (here) to collapse or open

Mysql > alter table T_USER_INFO rename index idx_user_info_name to idx_user_info_nm; window 2:

Click (here) to collapse or open

Mysql > select * from T_USER_INFO where user_name='rz19930119'; executes the statement that changes the index name first, and executes the second query before the statement finishes. The query statement can be executed normally before the index name is changed.

Conclusion: 1. MySQL5.7 changing the index will not lock the table (although this is a chicken rib feature, because the index name is generally not changed).

2. MySQL5.7 adds the syntax of alter table tablename rename index idxname1 to idxname2. In versions prior to 5.7, the index name can only be changed by deleting it before creating it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report