我可以使用 pt-online-schema-change 来更改主键吗? [英] Can I use pt-online-schema-change to change a primary key?

查看:44
本文介绍了我可以使用 pt-online-schema-change 来更改主键吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑使用 pt-online-schema-changeALTER 表的主键(将其从一列更改为复合主索引).这样做有什么限制吗?文档声明

I'm considering using pt-online-schema-change to ALTER a primary key (changing it from one column, to a composite primary index) of a table. Are there any limitations to doing this? The documentation states

在大多数情况下,除非主键或UNIQUE INDEX 存在于表中.有关详细信息,请参阅 --alter.

In most cases the tool will refuse to operate unless a PRIMARY KEY or UNIQUE INDEX is present in the table. See --alter for details.

推荐答案

好吧,不要那样做.在没有单列唯一索引的表上运行 pt-online-schema-change 可能会导致数据丢失.请参阅此处的 #3:http://www.pythian.com/blog/important-caveats-when-using-pt-online-schema-change/

Well, don't do that. Running pt-online-schema-change on a table w/o a single column unique index, may result in a loss of data. See #3 here: http://www.pythian.com/blog/important-caveats-when-using-pt-online-schema-change/

这篇关于我可以使用 pt-online-schema-change 来更改主键吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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