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

发布于 2024-07-28 22:57:09 字数 451 浏览 1 评论 0原文

我正在重新开发一个最初使用 SQL Server 2005、ASP.NET 和 ASP.NET 的 Web 应用程序及其基础结构。 Windows 2003 到 LAMMP(当然是 memcached 的额外 M)堆栈,并且由于架构经过大量重构(有充分的理由这样做),我必须编写一个自定义迁移应用程序。

问题是 InnoDB 主键 + 外键约束阻碍了我将数据插入 MySQL/InnoDB 表的能力。 我已经尝试过使用 DISABLE KEYS & FOREIGN_KEY_CHECKS 方法并暂时删除主数据库上的自动增量,或者在尝试进行其中一项更改(例如 DISABLE KEYS)时抛出错误,因为它在 InnoDB 中不受支持,或者尝试删除某个列上的主键分配空表或迁移应用程序在表为空时输入记录时抛出错误,提示键已存在。 除了先删除所有钥匙然后再把它们放回去(我认为这也会给我带来地狱)之外,还有什么可以做的吗?

谢谢!

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.

The problem is the InnoDB primary + foreign key constraints are hindering my ability to insert the data into its MySQL/InnoDB tables. 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. 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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

怀里藏娇 2024-08-04 22:57:09

事实证明这有效:

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

插入记录......

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";

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";
梦毁影碎の 2024-08-04 22:57:09

我更喜欢使用第三方应用程序来迁移我的数据,当我将 MS SQL 迁移到 Foxpro 时,我使用数据加载器,它工作得很好,并且它几乎可以迁移任何数据库。

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

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.

Download Free : http://www.dbload.com

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文