2011-04-24 53 views
1

我試圖導入表在我的數據庫執行這個查詢:爲什麼這個導入不起作用?

CREATE TABLE /*!32312 IF NOT EXISTS*/ "to_import" (
    "id" int(11) unsigned NOT NULL auto_increment, 
    "reference" int(11) unsigned NOT NULL, 
    "trackid" int(11) unsigned NOT NULL, 
    "side_pos1" char(2) character set latin1 NOT NULL, 
    "side1" varchar(255) character set latin1 NOT NULL, 
    "pos1" char(2) character set latin1 NOT NULL, 
    "hh1" char(2) character set latin1 NOT NULL, 
    "mm1" char(2) character set latin1 NOT NULL, 
    "ss1" char(2) character set latin1 NOT NULL, 
    "atl1" varchar(255) character set latin1 NOT NULL, 
    "side_pos2" char(2) character set latin1 NOT NULL, 
    "side2" varchar(255) character set latin1 NOT NULL, 
    "pos2" char(2) character set latin1 NOT NULL, 
    "hh2" char(2) character set latin1 NOT NULL, 
    "mm2" char(2) character set latin1 NOT NULL, 
    "ss2" char(2) character set latin1 NOT NULL, 
    "atl2" varchar(255) character set latin1 NOT NULL, 
    "date" datetime NOT NULL, 
    PRIMARY KEY ("id") 
) AUTO_INCREMENT=1311; 



# 
# Dumping data for table 'to_import' 
# 

LOCK TABLES "to_import" WRITE; 
/*!40000 ALTER TABLE "to_import" DISABLE KEYS;*/ 
REPLACE INTO "to_import" ("id", "reference", "trackid", "side_pos1", "side1", "pos1", "hh1", "mm1", "ss1", "atl1", "side_pos2", "side2", "pos2", "hh2", "mm2", "ss2", "atl2", "date") VALUES 
    ('1','0','550','0','Single Side','0','??','??','??','Noizefucker - Tons Of Bluesteel - Special Forces','0','Single Side','0','??','??','??','Noizefucker - Tons Of Bluesteel - Special Forces','2010-06-24 18:54:59'); 

... another replacement, like other 1200 line 


REPLACE INTO "to_import" ("id", "reference", "trackid", "side_pos1", "side1", "pos1", "hh1", "mm1", "ss1", "atl1", "side_pos2", "side2", "pos2", "hh2", "mm2", "ss2", "atl2", "date") VALUES 
    ('1310','0','463','#','','20','00','41','00','Ingler - Trek','#','','20','00','41','00','Ingler - Trek','2011-04-02 00:30:02'); 
/*!40000 ALTER TABLE "to_import" ENABLE KEYS;*/ 
UNLOCK TABLES; 
/*!40101 SET [email protected]_SQL_MODE;*/ 
/*!40014 SET [email protected]_FOREIGN_KEY_CHECKS;*/ 

,但我得到這個錯誤:

#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 '"to_import" (
"id" int(11) unsigned NOT NULL auto_increment, 
"reference" i' at line 1 

是什麼意思?嘗試在本地和它的作品完美...

+0

測試它:將 「to_import」 要'to_import' – 2011-04-24 19:53:13

+0

仍然不工作:'近「 「ID」 INT( 11)unsigned NOT NULL auto_increment, 「reference」int(11)unsigned N'at 2' – markzzz 2011-04-24 19:57:40

+0

表名和字段名必須在前後有'and'不正確 – 2011-04-24 19:58:38

回答

3

刪除雙引號。請不要引用表和列或使用反引號(`)。

0

字段名稱使用反引號分隔,而不是雙引號。

CREATE TABLE /*!32312 IF NOT EXISTS*/ `to_import` (
    `id` int(11) unsigned NOT NULL auto_increment, 
    `reference` int(11) unsigned NOT NULL, 

1

這是你的有效的SQL文件:

CREATE TABLE `to_import` (
    `id` int(11) unsigned NOT NULL auto_increment, 
    `reference` int(11) unsigned NOT NULL, 
    `trackid` int(11) unsigned NOT NULL, 
    `side_pos1` char(2) character set latin1 NOT NULL, 
    `side1` varchar(255) character set latin1 NOT NULL, 
    `pos1` char(2) character set latin1 NOT NULL, 
    `hh1` char(2) character set latin1 NOT NULL, 
    `mm1` char(2) character set latin1 NOT NULL, 
    `ss1` char(2) character set latin1 NOT NULL, 
    `atl1` varchar(255) character set latin1 NOT NULL, 
    `side_pos2` char(2) character set latin1 NOT NULL, 
    `side2` varchar(255) character set latin1 NOT NULL, 
    `pos2` char(2) character set latin1 NOT NULL, 
    `hh2` char(2) character set latin1 NOT NULL, 
    `mm2` char(2) character set latin1 NOT NULL, 
    `ss2` char(2) character set latin1 NOT NULL, 
    `atl2` varchar(255) character set latin1 NOT NULL, 
    `date` datetime NOT NULL, 
    PRIMARY KEY (`id`) 
) AUTO_INCREMENT=1311; 



# 
# Dumping data for table 'to_import' 
# 

LOCK TABLES `to_import` WRITE; 
/*!40000 ALTER TABLE `to_import` DISABLE KEYS;*/ 
REPLACE INTO `to_import` (`id`, `reference`, `trackid`, `side_pos1`, `side1`, `pos1`, `hh1`, `mm1`, `ss1`, `atl1`, `side_pos2`, `side2`, `pos2`, `hh2`, `mm2`, `ss2`, `atl2`, `date`) VALUES 
    ('1','0','550','0','Single Side','0','??','??','??','Noizefucker - Tons Of Bluesteel - Special Forces','0','Single Side','0','??','??','??','Noizefucker - Tons Of Bluesteel - Special Forces','2010-06-24 18:54:59');