MySQL 和 SQL 的 .sql 文件是否不同?
我有一个 .sql 文件,我想将其加载到 MySQL 数据库中。我不知道它是从哪个数据库(MySQL 或 MS-SQL)创建的。
现在,我尝试将该文件导入 MySQL 数据库。导入和执行该文件时显示错误。
Q1。所以,我的问题是MySQL和MS-SQL生成的.sql文件是否不同?
注意:我使用SQLYog软件(MySQL的图形界面)来导入文件。
这是错误:
查询: 创建表
广告
(id
bigint(20) NOT NULL auto_increment,city_id
int(11) NOT NULL,类型
文本整理utf8_bin NOT NULL,town
文本整理 utf8_bin NOT NULL,地址
文本整理utf8_bin NOT NULL,价格
文本整理utf8_bin NOT NULL,info
文本整理 utf8_bin NOT NULL,link
文本整理 utf8_bin NOT NULL,hasImage
int(11) NOT NULL,语言
varchar(2) 整理 utf8_bin NOT NULL,time_added
varchar(255) 整理 utf8_bin NOT NULL, 主键(id
) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCRMENT=1
错误发生于:2009-09-08 17:41:01 线路号:35 错误代码:1050 - 表“ads”已存在
查询: 创建表
广告
(id
bigint(20) NOT NULL auto_increment,city_id
int(11) NOT NULL,类型
文本整理utf8_bin NOT NULL,town
文本整理 utf8_bin NOT NULL,地址
文本整理utf8_bin NOT NULL,价格
文本整理utf8_bin NOT NULL,info
文本整理 utf8_bin NOT NULL,link
文本整理 utf8_bin NOT NULL,hasImage
int(11) NOT NULL,语言
varchar(2) 整理 utf8_bin NOT NULL,time_added
varchar(255) 整理 utf8_bin NOT NULL, 主键(id
) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCRMENT=1
错误发生于:2009-09-08 17:41:21 线路号:35 错误代码:1050 - 表“ads”已存在
查询: 创建表
广告
(id
bigint(20) NOT NULL auto_increment,city_id
int(11) NOT NULL,类型
文本整理utf8_bin NOT NULL,town
文本整理 utf8_bin NOT NULL,地址
文本整理utf8_bin NOT NULL,价格
文本整理utf8_bin NOT NULL,info
文本整理 utf8_bin NOT NULL,link
文本整理 utf8_bin NOT NULL,hasImage
int(11) NOT NULL,语言
varchar(2) 整理 utf8_bin NOT NULL,time_added
varchar(255) 整理 utf8_bin NOT NULL, 主键(id
) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCRMENT=1
错误发生于:2009-09-08 17:41:35 线路号:35 错误代码:1050 - 表“ads”已存在
查询: 创建表
广告
(id
bigint(20) NOT NULL auto_increment,city_id
int(11) NOT NULL,类型
文本整理utf8_bin NOT NULL,town
文本整理 utf8_bin NOT NULL,地址
文本整理utf8_bin NOT NULL,价格
文本整理utf8_bin NOT NULL,info
文本整理 utf8_bin NOT NULL,link
文本整理 utf8_bin NOT NULL,hasImage
int(11) NOT NULL,语言
varchar(2) 整理 utf8_bin NOT NULL,time_added
varchar(255) 整理 utf8_bin NOT NULL, 主键(id
) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCRMENT=1
错误发生于:2009-09-08 17:42:07 线路号:35 错误代码:1050 - 表“ads”已存在
查询: 1 斯坦福大学 6700 http://www.orkut.co.in 。 。 .
I have a .sql file and I want to load it into MySQL database. I don't know from which database (MySQL or MS-SQL) it was created.
Now, I am trying to import that file into MySQL database. It is showing errors while importing and executing that file.
Q1. So, my question is whether the .sql file generated from MySQL and MS-SQL are different?
Note: I am using SQLYog software (graphical interface for MySQL) for importing the file.
Here is the ERROR:
Query:
CREATE TABLEads
(id
bigint(20) NOT NULL auto_increment,city_id
int(11) NOT NULL,type
text collate utf8_bin NOT NULL,town
text collate utf8_bin NOT NULL,address
text collate utf8_bin NOT NULL,price
text collate utf8_bin NOT NULL,info
text collate utf8_bin NOT NULL,link
text collate utf8_bin NOT NULL,hasImage
int(11) NOT NULL,language
varchar(2) collate utf8_bin NOT NULL,time_added
varchar(255) collate utf8_bin NOT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1
Error occured at:2009-09-08 17:41:01
Line no.:35
Error Code: 1050 - Table 'ads' already exists
Query:
CREATE TABLEads
(id
bigint(20) NOT NULL auto_increment,city_id
int(11) NOT NULL,type
text collate utf8_bin NOT NULL,town
text collate utf8_bin NOT NULL,address
text collate utf8_bin NOT NULL,price
text collate utf8_bin NOT NULL,info
text collate utf8_bin NOT NULL,link
text collate utf8_bin NOT NULL,hasImage
int(11) NOT NULL,language
varchar(2) collate utf8_bin NOT NULL,time_added
varchar(255) collate utf8_bin NOT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1
Error occured at:2009-09-08 17:41:21
Line no.:35
Error Code: 1050 - Table 'ads' already exists
Query:
CREATE TABLEads
(id
bigint(20) NOT NULL auto_increment,city_id
int(11) NOT NULL,type
text collate utf8_bin NOT NULL,town
text collate utf8_bin NOT NULL,address
text collate utf8_bin NOT NULL,price
text collate utf8_bin NOT NULL,info
text collate utf8_bin NOT NULL,link
text collate utf8_bin NOT NULL,hasImage
int(11) NOT NULL,language
varchar(2) collate utf8_bin NOT NULL,time_added
varchar(255) collate utf8_bin NOT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1
Error occured at:2009-09-08 17:41:35
Line no.:35
Error Code: 1050 - Table 'ads' already exists
Query:
CREATE TABLEads
(id
bigint(20) NOT NULL auto_increment,city_id
int(11) NOT NULL,type
text collate utf8_bin NOT NULL,town
text collate utf8_bin NOT NULL,address
text collate utf8_bin NOT NULL,price
text collate utf8_bin NOT NULL,info
text collate utf8_bin NOT NULL,link
text collate utf8_bin NOT NULL,hasImage
int(11) NOT NULL,language
varchar(2) collate utf8_bin NOT NULL,time_added
varchar(255) collate utf8_bin NOT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1
Error occured at:2009-09-08 17:42:07
Line no.:35
Error Code: 1050 - Table 'ads' already exists
Query:
1 Stanford University 6700 http://www.orkut.co.in
.
.
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
文件扩展名“.sql”本质上是没有意义的:它只是让您知道该文件是什么。它只是一个包含 SQL 的纯文本文件,您可以在记事本中打开它。因此,没有特殊的“mysql”或“sql server”扩展。
您遇到的错误
“表'ads'已存在”
是因为您尝试创建数据库中已存在的表。 (您阅读错误了吗?)您有几个选择:将 SQL 更改为:
将 SQL 更改为:
首先清除 DB 中的所有表。
The file extension ".sql" is essentially meaningless: it's just there so that you know what the file is. It will just be a plain text file containing SQL, which you can open in Notepad. Therefore, there's no special "mysql" or "sql server" extensions.
The errors you're getting there
"Table 'ads' already exists"
are because you're trying to create a table which already exists in the database. (Did you read the error?) You have a few options:Change the SQL to this:
Change the SQL to this:
Clear out all the tables in the DB first.
不幸的是,MySQL 和 Microsoft SQL Server 确实实现了不同的 SQL 方言。那么,你的问题的答案:
是“是的,完全有可能”。但是,您显示的具体错误似乎完全是由于第 35 行上的“创建表”语句一遍又一遍地执行而引起的,并且不能依赖于此类方言差异,因此原因必须是其他的(例如我不熟悉的“SQLYog”程序期望作为其输入的错误或细微的格式差异)。
MySQL and Microsoft SQL Server do, unfortunately, implement different dialects of SQL. So, the answer to your question :
is "yes, quite possiby". However, the specific error you're showing appears to be due strictly to a "Create table" statement on line 35 being executed over and over and over again, and that can't depend on such dialect differences, so the causes have to be other ones (such as bugs or subtle format differences in what that "SQLYog" program, which I'm not familiar with, expects as its input).
这取决于哪个软件导出此文件。还要检查文件的标头是哪个软件执行的,并分析语法以确定该文件所属的位置。另请注意,SQL 是 microsoft sql server。
It depends on which software exported this file. Also check in the file's header which software did it and analyze the syntax to determine where this file belongs to. Note also that SQL is microsoft sql server.
是的。 SQL 因数据库而异。虽然大多数数据库都支持一个 SQL 标准,但每个数据库都有大量、超出标准规定的不兼容的非标准特性和功能。
还有许多可用的迁移文档:
MSSQL => MySQL:
http://dev.mysql.com/tech-resources/文章/migration-from-microsoft.html
MySQL => SQL:
http://technet.microsoft.com/en-us/library/cc966396。 在您的 CREATE TABLE 语句中,
MSSQL 不支持两个明显的内容,它们会立即跳出:
这些都是 MySQL 特定的语句。
Yes. SQL varies greatly from database to database. While there is a SQL standard which most databases support much of, every database has numerous, incompatible nonstandard features and functions above and beyond that specified by the standard.
There are also many migration docs avaiable:
MSSQL => MySQL:
http://dev.mysql.com/tech-resources/articles/migrating-from-microsoft.html
MySQL => MSSQL:
http://technet.microsoft.com/en-us/library/cc966396.aspx
There are two obvious things in your CREATE TABLE statement that MSSQL doesn't support which jump out immediately:
Those are both MySQL-specific statements.
看起来您的脚本被执行了多次(因为每次发生错误的行号都是相同的)。该错误还表明您正在尝试定义一个已经存在的表,该表可能是该脚本第一次运行时存在的。您可能想要查看脚本的运行方式,以了解为什么它可能会执行多次。
SQL 本身对于 MySQL 来说看起来不错。它不能与 SQL Server 一起运行。
It looks like your script is being executed multiple times (as the line number where the error occurs is the same each time). The error also indicates that you're trying to define a table that already exists, which may be from the first time this script ran. You may want to look into how the script is being run to see why it may be executing multiple times.
The SQL itself looks fine for MySQL. It wouldn't run with SQL Server.