2013-07-10 72 views
0

我遇到了一個問題,從SQLite3導入轉儲時,我通過一個腳本去除了大部分衝突,但仍有一些仍然存在。從SQLite轉儲的CREATE TABLE語法(1064)中的錯誤

ERROR 1064 (42000) at line 558774: 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 'MONTH NOT NULL, 
    grade INTEGER, 
    school INTEGER REFERENCES school(id), 
    ' at line 4 

這似乎並沒有被a quoting issue,一些掛逗號等

558774號線是month線:

... 
INSERT INTO census_block VALUES(1234,-0.32,1.47,NULL,NULL); 
INSERT INTO census_block VALUES(5678,-0.43,-0.24,NULL,NULL); 
CREATE TABLE history(
    sid INTEGER NOT NULL REFERENCES student(sid), 
    year YEAR NOT NULL, 
    month MONTH NOT NULL, 
    grade INTEGER, 
    school INTEGER REFERENCES school(id), 
    assigned_school INTEGER REFERENCES school(id), 
    census_block INTEGER REFERENCES census_block(id) 
); 
INSERT INTO history VALUES(2319802,1991,9,9,1470,NULL,2468); 
INSERT INTO history VALUES(2319802,1992,5,9,1470,NULL,3692); 
... 

回答

1

沒有一個Month數據類型在MySQL 。相反,對month列使用Integer

CREATE TABLE history(
    sid INTEGER NOT NULL REFERENCES student(sid), 
    year YEAR NOT NULL, 
    month INTEGER NOT NULL, 
    grade INTEGER, 
    school INTEGER REFERENCES school(id), 
    assigned_school INTEGER REFERENCES school(id), 
    census_block INTEGER REFERENCES census_block(id) 
); 
1

月份不是合法的數據類型。將其更改爲int或smallint,即月份int