SQLite 到 MySQL 奇怪的错误 #1064
我正在将 SQLite 数据库转换为 MySQL,以便可以将其导入 PHPMyAdmin。 这应该很简单。我将其导出到转储,更改了自动增量并将所有双引号更改为反引号。生成的文件的开头如下所示:
DROP TABLE IF EXISTS `chars`;
CREATE TABLE chars(
charid INTEGER PRIMARY KEY AUTO_INCREMENT,
character TEXT
);
INSERT INTO `chars` VALUES(3,'a');
INSERT INTO `chars` VALUES(4,'b');
... 当尝试导入 PHPMyAdmin 时,它会抛出此错误。
<前><代码>错误 SQL查询: 创建表字符( Charid 整数主键自动增量, 字符文本 ); MySQL 说道: #1064 - 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在“字符 TEXT”附近使用的正确语法 )' 在第 3 行
缩进线后是否有太多空格?我将“format”选项保留为“SQL”,将 SQL 兼容模式保留为 NONE,并勾选“不要对零值使用 AUTO_INCRMENT”。 它将在 django Web 应用程序中使用。
I'm converting a SQLite database to MySQL so I can import it to PHPMyAdmin.
This should be straightforward. I exported it to a dump, changed the autoincrements and changed all double quotes to backticks. This is what the start of the resulting file looks like:
DROP TABLE IF EXISTS `chars`;
CREATE TABLE chars(
charid INTEGER PRIMARY KEY AUTO_INCREMENT,
character TEXT
);
INSERT INTO `chars` VALUES(3,'a');
INSERT INTO `chars` VALUES(4,'b');
...
When trying to import to PHPMyAdmin it throws this error.
Error SQL query: CREATE TABLE chars( charid INTEGER PRIMARY KEY AUTO_INCREMENT , CHARACTER TEXT ); MySQL said: #1064 - 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 'character TEXT )' at line 3
Is there too much space after the indented line? I left the "format" option as "SQL", left SQL compatibility mode as NONE and left "Do not use AUTO_INCREMENT for zero values" ticked.
Its going to be used in a django web app.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CHARACTER
是mySQL 中的保留字。我敢打赌这就是原因。使用不同的列名称(首选),或使用反引号:
CHARACTER
is a reserved word in mySQL. I'm betting that is the reason.Use either a different column name (preferred), or use backticks: