0

我在从 SQLite3 导入转储时遇到问题,我通过脚本运行该转储以消除大部分冲突,但仍然存在一些冲突。

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

这似乎不是一个引用问题,一些挂逗号等。

第 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);
...
4

2 回答 2

1

MySQL中没有Month数据类型。相反,Integer请为month列使用 an。

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)
);
于 2013-07-10T02:24:34.557 回答
1

Month 不是合法的数据类型。将其更改为 int 或 smallint 即 month int

于 2013-07-10T02:26:39.727 回答