【问题标题】:mdb-tools mySQL syntax errormdb-tools mySQL 语法错误
【发布时间】:2013-10-24 16:22:47
【问题描述】:

我有一个 .mdb 文件正在尝试导出到 mySQL 数据库。 使用mdb-schema Data.mdb | mysql -u root -p Database 我收到以下错误:

ERROR 1064 (42000) at line 11: 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 '[Attachments]
 (
    [ItemID]            Long Integer, 
    [Description]           Text (510), 
    [Pare' at line 1

mdb-schema 的代码输出(在管道实际上看起来像这样之前)

  1 -- ----------------------------------------------------------
  2 -- MDB Tools - A library for reading MS Access database files
  3 -- Copyright (C) 2000-2011 Brian Bruns and others.
  4 -- Files in libmdb are licensed under LGPL and the utilities under
  5 -- the GPL, see COPYING.LIB and COPYING files respectively.
  6 -- Check out http://mdbtools.sourceforge.net
  7 -- ----------------------------------------------------------
  8 
  9 -- That file uses encoding UTF-8
 10 
 11 CREATE TABLE [Attachments]
 12  (
 13         [ItemID]                        Long Integer,
 14         [Description]                   Text (510),
 15         [ParentItemID]                  Long Integer,
 16         [Path]                  Memo/Hyperlink (255),
 17         [AttachmentType]                        Long Integer,
 18         [Notes]                 Text (510),
 19         [Imported]                      Boolean NOT NULL
 20 );
 21

+ 其他一些表格

这实际上意味着语法错误出现在 cmets 之后的第一行?你能帮我解决这个问题吗?在跛脚的眼里,它看起来很有效。

提前致谢:)

【问题讨论】:

  • MySQL 是否将方括号识别为表/列名称的分隔符?我似乎记得 MySQL 为此使用了反引号 (`)。我还想知道 MySQL 将如何对“备忘录/超链接”作为列类型做出反应。 (不过,我已经有一段时间没有用 MySQL 做了太多工作了。)
  • 我相信你需要varchar,而不是Text
  • 将 [(.+)] 更改为 '$1' 并没有改变任何内容。第一行仍然出错。

标签: mysql ms-access mdbtools


【解决方案1】:

根据man mdb-schema,我们可以在数据库名称之后包含一个可选的backend 参数。当我尝试时

mdb-schema test.mdb mysql > output.txt

输出文件包含这个

-- ----------------------------------------------------------
-- MDB Tools - A library for reading MS Access database files
-- Copyright (C) 2000-2011 Brian Bruns and others.
-- Files in libmdb are licensed under LGPL and the utilities under
-- the GPL, see COPYING.LIB and COPYING files respectively.
-- Check out http://mdbtools.sourceforge.net
-- ----------------------------------------------------------

-- That file uses encoding UTF-8

CREATE TABLE `Contacts`
 (
    `ID`            int, 
    `LastName`          varchar (510), 
    `FirstName`         varchar (510), 
    `Notes`         text (255)
);

它看起来确实比问题中的示例更接近 MySQL 语法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-04
    • 2011-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多