简体   繁体   English

SQL Server迁移到带有InnoDB键和约束问题的重构MySQL

[英]SQL Server Migration To Refactored MySQL w/ InnoDB Key & Constraint Issues

I am redeveloping a web application and its infrastructure originally using SQL Server 2005, ASP.NET & Windows 2003 to a LAMMP (extra M for memcached of course) stack and since the schema is heavily refactored (with very good reason to do so) I must write a custom migration app. 我最初使用SQL Server 2005,ASP.NET和Windows 2003将Web应用程序及其基础结构重新开发为LAMMP(当然,对于memcached来说,则为M)堆栈,并且由于架构被大量重构(这样做的理由非常充分),我必须编写一个自定义迁移应用。

The problem is the InnoDB primary + foreign key constraints are hindering my ability to insert the data into its MySQL/InnoDB tables. 问题是InnoDB主键和外键约束阻碍了我将数据插入其MySQL / InnoDB表的能力。 I have already tried using DISABLE KEYS & FOREIGN_KEY_CHECKS methods and temporarily removing the auto-increment on the primary with it either throwing an error when try to make one of these changes such as the DISABLE KEYS since it is unsupported in InnoDB or trying to remove the primary key assignment on a column in an empty table or the migration app throwing errors saying key already exists when entering a record when the table is empty. 我已经尝试使用DISABLE KEYS和FOREIGN_KEY_CHECKS方法并临时删除主数据库上的自动增量,因为在InnoDB中不受支持,尝试进行这些更改之一(例如DISABLE KEYS)时会抛出错误,或者尝试删除在空表中的列上进行主键分配,或者迁移应用程序引发错误,表明在表为空时输入记录时键已经存在。 Is there anything else that can be done beyond this besides removing all keys first and putting them back afterwards (which I assume will give me hell too)? 除了首先删除所有密钥然后再将它们放回去之外,还有其他事情可以做吗(我想这也会给我带来麻烦)?

Thanks! 谢谢!

Turns out this works: 证明这可行:

ALTER TABLE `site_oltp`.`members` MODIFY COLUMN `id` INT(11) NOT NULL;
SET FOREIGN_KEY_CHECKS = 0, UNIQUE_CHECKS = 0;

insert records.... 插入记录...。

ALTER TABLE `site_oltp`.`members` MODIFY COLUMN `id` INT(11) NOT NULL AUTO_INCREMENT;

ALTER TABLE `site_oltp`.`members` AUTO_INCREMENT = (LAST_ID_GOES_HERE + 1);

SET FOREIGN_KEY_CHECKS = 1, UNIQUE_CHECKS = 1";

I prefer a third party applpications for migrating my data, i use data loader when i was migrating MS SQL to Foxpro it work great, and it can migrate almost any database. 我更喜欢使用第三方应用程序迁移数据,当我将MS SQL迁移到Foxpro时,我使用数据加载器,它的工作原理非常好,并且几乎可以迁移任何数据库。

Download Free : http://www.dbload.com 免费下载: http : //www.dbload.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM