有没有任何工具可以帮助将 innoDB 表转换为 mysql 集群的 NDB 表?
有没有什么工具可以帮助将innoDB表转换为NDB表? 我想要一个工具帮助通过触发器替换所有外键。 我是否必须为每个 FK 手动执行此操作?
is there any tools could help to convert innoDB table into NDB table?
I want a tool help to replace all foreign key by trigger.
Should I have to do it by manual for each FK?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道是否有工具可以让你做到这一点。
您始终可以用[您最喜欢的脚本语言]编写脚本来执行此操作。
它的工作方式如下:(
注意。我假设每个表都是 InnoDB 并且您想要转换所有表。我还假设您的数据库中没有视图。如果您有视图,那么您必须发出
SHOW相反,仅处理表类型表明它不是视图的那些行,而且,这不会消除与外键关联的索引 - 如果您需要手动执行此部分。不再需要所有索引。另外,在执行任何操作之前备份数据库!尽管这是不言而喻的。)
$foreign_keys
SHOW TABLES
SHOW CREATE TABLE表名
/CONSTRAINT `(.+)` FOREIGN KEY/ 进行正则表达式搜索
$foreign_keys
;DROP FOREIGN KEY
语句ALTER TABLE tablename ENGINE=NDB
$foreign_keys
,发出 < code>CREATE TRIGGER 语句也许实际上有一些工具可以为您完成此操作,但另一方面,如果您不想手动执行此操作,这可能是您需要执行的操作。
I don't know if there are tools to let you do this.
You could always write a script in [your favourite scripting language] to do it.
It would work like:
(NB. I assume that every table is InnoDB and that you want to convert all of them. I also assume that there are no views in your db. If you have views then you have to issue
SHOW FULL TABLES
instead and treat only those rows for which the table type indicates that it is not a view. Also, this will not get rid of the indexes associated to foreign keys - you would need to do this part manually if you didn't want all of the indexes any more. Also, back up your database before you do anything! Although that goes without saying.)$foreign_keys
SHOW TABLES
SHOW CREATE TABLE tablename
/CONSTRAINT `(.+)` FOREIGN KEY/
$foreign_keys
;DROP FOREIGN KEY
statementALTER TABLE tablename ENGINE=NDB
$foreign_keys
, issue aCREATE TRIGGER
statementPerhaps there actually are tools out there that will do it for you, but on the other hand this might be what you need to do if you don't want to do it manually.