is there any tools could help to convert innoDB table into NDB table for mysql cluster?
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 ha开发者_高级运维ve to do it by manual for each FK?
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.)
- Create an empty array/list/whatever,
$foreign_keys
- Issue
SHOW TABLES
- For each table displayed:
- Issue
SHOW CREATE TABLE tablename
- Do a regular expression search for
/CONSTRAINT `(.+)` FOREIGN KEY/
- For each match,
- add the details of the foreign key on the same line to your array
$foreign_keys
; - issue a
DROP FOREIGN KEY
statement
- add the details of the foreign key on the same line to your array
- Issue
- For each table, issue
ALTER TABLE tablename ENGINE=NDB
- For each entry in your array
$foreign_keys
, issue aCREATE TRIGGER
statement
Perhaps 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.
精彩评论