更改大表中的mysql字段名称 [英] Change mysql field name in a huge table

查看:83
本文介绍了更改大表中的mysql字段名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含 2100 万行的表.我必须更改其中一个行名称.当我尝试查询alter table company change id new_id int(11)"时;查询永无止境.

I have a table with 21 million row.I have to change one of the row name.When I try with the query "alter table company change id new_id int(11)"; query never ends.

有没有简单的方法可以改变mysql大表的字段名?

Is there a simple way to change big mysql table's field name?

推荐答案

使用 pt-online-schema-change 进行长时间运行的 ALTER TABLE 更改,而不会将自己锁定在表之外.

Use pt-online-schema-change to make long-running ALTER TABLE changes, without locking yourself out of the table.

http://www.percona.com/doc/percona-toolkit/pt-online-schema-change.html

完成更改通常需要更长的时间,但您仍然可以在表执行其工作时对其进行读取和写入.

It usually takes longer to complete the change, but you can still read from and write to the table while it's doing its work.

您还可以收听作者的网络研讨会,讨论其工作原理及其一些注意事项:

You can also listen to a webinar from the author, talking about how it works and some of its caveats:

http://www.percona.com/webinars/2012-05-02-zero-downtime-schema-changes-in-mysql

这篇关于更改大表中的mysql字段名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆