如何将 phpMyAdmin SQL Dump 的查询转换为 SQL Server 清晰的查询
我已经开展了一个小项目,该项目已经发展了当前的数据库。应用程序是用php编写的,数据库是mysql。
我正在重写应用程序,但我仍然需要维护数据库的结构和数据。我收到了一个 sql 转储文件。当我尝试在 sql server management studio 中运行它时,我收到许多错误。我想知道有什么办法可以将 sql 脚本从创建的 phpMyAdmin 转储文件转换为 tsql?
有什么想法吗?
I have undertaken a small project which already evolved a current database. The application was written in php and the database was mysql.
I am rewriting the application, yet I still need to maintain the database's structure as well as data. I have received an sql dump file. When I try running it in sql server management studio I receive many errors. I wanted to know what work around is there to convert the sql script from the phpMyAdmin dump file that was created to tsql?
Any Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
phpMyAdmin 是 MySQL 数据库的前端。转储数据库可以通过多种格式完成,包括SQL脚本代码,但我猜你的问题是你使用的是SQL Server,而T-SQL与MySQL不同。
编辑:我看到原始发帖者意识到了这一点(帖子上没有 MySQL 标签)。我的建议是以 CSV 格式(例如)重新转储数据库,并通过批量插入导入,例如,对于单个表,
如果数据库不是太大并且只有几个表,这应该可以正常工作。
顺便说一句,您确实遇到了比运行脚本更多的问题:数据类型的映射绝对不容易。
这是一篇关于迁移 MySQL 的文章 -> SQL Server 通过 DTS 导入/导出向导,如果您的数据库很大(并且您仍然可以访问,即不仅可以转储),这可能是一个好方法。
phpMyAdmin is a front-end for MySQL databases. Dumping databases can be done in various formats, including SQL script code, but I guess your problem is that you are using SQL Server, and T-SQL is different from MySQL.
EDIT: I see the original poster was aware of that (there was no MySQL tag on the post). My suggestion would be to re-dump the database in CSV format (for example) and to import via bulk insert, for example, for a single table,
This should work fine if the database isn't too large and has only few tables.
You do have more problems than making a script run, by the way: Mapping of data types is definitely not easy.
Here is an article about migration MySQL -> SQL Server via the DTS Import/Export wizard, which may well be a good way if your database is large (and you still have access, ie, not only have the dump).
Tsql 和 Mysql 之间的语法相差不是一百万英里,您可能可以通过反复试验以及一系列查找和替换来重写它。
更好的选择可能是安装 mysql 和 mysqlconnector,并使用 dubp 文件恢复数据库。
然后,您可以在 SQL 服务器上创建链接服务器并执行一系列查询,如下所示:
The syntax between Tsql and Mysql is not a million miles off, you could probably rewrite it through trial and error and a series of find and replaces.
A better option would probably be to install mysql and mysqlconnector, and restore the database using the dubp file.
You could then create a Linked Server on the SQL server and do a series of queries like the following:
MySQL 的 mysqldump 实用程序可以为其他系统生成某种程度上兼容的转储。例如,使用
--兼容=mssql
。此选项不保证与其他服务器的兼容性,但可能会防止大多数错误,从而减少您手动更改的时间。MySQL's
mysqldump
utility can produce somewhat compatible dumps for other systems. For instance, use--compatible=mssql
. This option does not guarantee compatibility with other servers, but might prevent most errors, leaving less for you to manually alter.