如何将 mssql 脚本转换为 mysql

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20108380/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 19:28:48  来源:igfitidea点击:

How to convert mssql script to mysql

mysqlsqlsql-server

提问by nazar_art

I tried to convert script from MS SQL Server to MySql.

我试图将脚本从 MS SQL Server 转换为 MySql。

I couldn't find any convenience approach to do this conversion.

我找不到任何方便的方法来进行这种转换。

I tried this MS SQL Server to MySQL Conversiononline converter but it has a lot of mistakes at syntax.

我试过这个MS SQL Server to MySQL Conversion在线转换器,但它在语法上有很多错误。

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTITY(1,1) NOT NULL,
`address` varchar(255) NOT NULL,
`date_added` datetime N' at line 2

Here is content of the file that I need to convert pastebin - script

这是我需要转换pastebin的文件内容- 脚本

  • Does any better way to make this conversion but without installing special tool exist?
  • 有没有更好的方法来进行这种转换但不安装特殊工具?

回答by tommy_o

You don't just "convert" TSQL to SQL code for MySQL. You need to know the different datatypes, column constraints, etc. You hit the first of many roadblocks: MySQL uses AUTO_INCREMENTinstead of SQL Server's IDENTITY field constraint.

您不只是将 TSQL“转换”为 MySQL 的 SQL 代码。您需要了解不同的数据类型、列约束等。您遇到了许多障碍中的第一个:MySQL 使用AUTO_INCREMENT而不是 SQL Server 的 IDENTITY 字段约束。

EDIT: There are utilities, but you should still understand what the changes are, as they'll affect many things (including performance and future development against the DB). Duplicate of several other posts (dead link removed).

编辑:有实用程序,但您仍然应该了解更改是什么,因为它们会影响很多事情(包括性能和针对 DB 的未来开发)。其他几个帖子的重复(删除了死链接)。

回答by Alan Hickman

The converter at http://burrist.com/mstomy.phpruns a set of regexps to do the conversion – the regexps list isn't exhaustive and can be modified as required. I've added a couple of extra lines to the standard regexps and it now creates a working version of your script up to the point you start inserting data (it only does tha structure not the data). Hope this is of interest.

http://burrist.com/mstomy.php 上的转换器运行一组正则表达式来进行转换——正则表达式列表并不详尽,可以根据需要进行修改。我在标准正则表达式中添加了几行额外的行,现在它会创建脚本的工作版本,直到您开始插入数据为止(它只构建结构而不是数据)。希望这是有趣的。

Cheers sql-hub.com

干杯 sql-hub.com

回答by R M Shahidul Islam Shahed

I used this online tools and its absolutely fine. http://www.sqlines.com/online

我使用了这个在线工具,它绝对没问题。 http://www.sqlines.com/online