2013-10-24 34 views
0

我有一個.mdb文件我試圖導出到mySQL數據庫。 使用mdb-schema Data.mdb | mysql -u root -p Database 我收到以下錯誤:mdb-tools mySQL語法錯誤

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-架構的代碼輸出(前管道實際上看起來像)<>

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 

+其他一些表

哪有效意味着語法錯誤在註釋之後的第一行中?你能幫我解決這個問題嗎?通過跛腳的眼睛看起來有效。

感謝提前:)

+0

MySQL是否可以識別方括號作爲表/列名的分隔符?我似乎記得MySQL爲此使用了反引號(')。我也想知道MySQL如何對「備忘錄/超鏈接」作爲列類型作出反應。 (但是,我還沒有用MySQL做過很多工作。) –

+0

我相信你需要'varchar',而不是'Text'。 – Constablebrew

+0

將[(。+)]更改爲'$ 1'不會改變任何內容。第一行仍然有錯誤。 –

回答

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的句法。