MySQL 到 SQL Server 的迁移

发布于 2024-11-24 15:40:44 字数 175 浏览 1 评论 0 原文

我有一个充满数据的 mysql 数据库,我需要保留这些数据,但要迁移到 SQL Server 2008。

我知道数据应该从头到尾、表到表去哪里,但我不知道如何移动数据。我浏览过网络,但似乎有一些“解决方案”需要您下载并运行。如果可能的话,我宁愿自己做一些编写脚本或代码的事情。

有人可以推荐最好的方法吗?

I have a mysql database full of data which I need to keep but migrate to SQL Server 2008.

I know end to end where the data should go, table to table but I have no idea how to go about moving the data. I've looked around the web but it seems there are 'solutions' which you have to download and run. I'd rather if possible do something myself in terms of writing scripts or code.

Can anyone recommend the best way to do this please?

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

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

发布评论

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

评论(5

柳絮泡泡 2024-12-01 15:40:44

这里有几个选项:

  • 在 sql server 端,您可以使用名为 链接服务器。这将允许您为 sql server 编写从 mysql 表返回数据的 sql 代码。您可以使用它来构建 INSERT 或 SELECT INTO 语句。
  • 您可以为 mysql 编写查询将数据导出为 csv,然后使用 sql server 的 BULK INSERT 功能高效导入 csv 数据。
  • 您可以使用 Sql Server 集成服务来设置从 mysql 转移数据。

无论您选择哪一个,索引、外键、触发器、存储过程和安全性等非数据工件都必须手动移动。

You have several options here:

  • On the sql server side, you can set up a connection to your old mysql db using something called a linked server. This will allow you to write sql code for sql server that returns data from the mysql tables. You can use this to build INSERT or SELECT INTO statements.
  • You can write queries for mysql to export your data as csv, and then use the BULK INSERT features of sql server to efficiently import the csv data.
  • You can use Sql Server integration services to set move the data over from mysql.

Regardless of which you choose, non-data artifacts like indexes, foreign keys, triggers, stored procedures, and security will have to be moved manually.

小瓶盖 2024-12-01 15:40:44

您是否尝试过 MSFT 的名为 SQL Server Migration Assistance for MySQL 的工具???
https://www.microsoft.com/download/en/details.aspx ?id=1495

Have you tried tool from MSFT called SQL Server Migration Assistance for MySQL ???
https://www.microsoft.com/download/en/details.aspx?id=1495

颜漓半夏 2024-12-01 15:40:44

尝试本教程,从 Mysql 迁移到 SQL Server 非常容易,并且如前面提到的那样简单

http://www.codeproject.com/Articles/29106/Migrate-MySQL-to-Microsoft-SQL-Server

谢谢

Try this tutorial it is very easy to perform migration to SQL Server from Mysql and is straightforward as mentioned

http://www.codeproject.com/Articles/29106/Migrate-MySQL-to-Microsoft-SQL-Server

Thanks

音盲 2024-12-01 15:40:44

您可以使用 SQL Server 标准版附带的导入/导出向导。

使用 ODBC 数据源从 MySQL 选择“数据源”。注意:您需要首先安装 MySQL 的 ODBC 驱动程序(ODBC 连接器) 。然后,选择您的 SQL Server 目标。选择所有表,然后启动它。您将需要手动添加主键、外键以及索引。

更自动化的方法是使用 SQL Server Migration Assistant for MySQL,也是免费的。它的优点是自动为您重新创建关系和索引。可能是你最好的选择。

You can use the Import/Export Wizard that comes with SQL Server Standard Edition.

Select your 'data source' from MySQL using the ODBC data source. Note: You will need to first install the from ODBC driver for MySQL (ODBC Connector). Then, select your SQL Server destination. Select all tables, and fire it up. You will need to add your primary and foreign keys, and indexes manually.

A bit more automated means would be by using the SQL Server Migration Assistant for MySQL, also free. It has the benefit of recreating the relationships and indexes automatically for you. Probably your best bet.

风吹短裙飘 2024-12-01 15:40:44

我以前做过一次。首先,您可以使用 odbc mysql 连接器将 mssql 服务器连接到 mysql 服务器

http://dev.mysql.com/downloads/connector/

连接建立后可以编写数据库过程,就像它是两个 mssql 数据库一样。可能最简单的方法是编写一些 sql 批处理脚本,包括一个游标,您可以在其中运行表的每一行,并根据字段决定将来需要该字段的位置。

光标示例:http://www.mssqltips.com/tip.asp ?提示=1599

如果您决定使用光标,您可以使用参数来提高性能。我特别记得 FORWARD_ONLY 参数给了我很大的提升。

I did it once, some time ago. First you could couple your mssql server to the mysql server using the odbc mysql connector

http://dev.mysql.com/downloads/connector/

After the connection is made you can write you database procedure as you would if it were two mssql db's. Probably easiest to write some sql batch scripts including a cursor where you run through every every row of a table an decide on a field basis where you will need the field in the future.

example of a cursor: http://www.mssqltips.com/tip.asp?tip=1599

If you decide to go with the cursor, you can play with the parameter to increase performance. I especially remember the FORWARD_ONLY parameter giving a big boost.

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