我收到MySQL的错误,这是我见过的最无用的错误消息:
ERROR 1064 (42000): 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 'NOT NULL,
PRIMARY KEY (userID, tweetID),
FOREIGN KEY (userID) REFERENCES User(' at line 4
很好,请查看手册...> _ _>
这是SQL源代码;我相信熟悉SQL的人会非常简单,但我是个新手。对我来说一切都很好。
我真的希望有一个比“我的错误是什么”更加完善的问题,但是错误信息如此模糊,而且我的经验很少,我几乎迷失了。
CREATE TABLE User (
username VARCHAR(20) NOT NULL,
userID INTEGER NOT NULL,
fullName VARCHAR(100),
passwordHash VARCHAR(256) NOT NULL,
email VARCHAR(256) NOT NULL,
imageURL VARCHAR(200),
facebookURL VARCHAR(200),
tagline VARCHAR(140),
memberSince TIMESTAMP NOT NULL,
PRIMARY KEY (userID)
);
CREATE TABLE Tweet (
tweetID INTEGER NOT NULL,
userID INTEGER NOT NULL,
content VARCHAR(140) NOT NULL,
TIMESTAMP NOT NULL,
PRIMARY KEY (tweetID),
FOREIGN KEY (userID) REFERENCES User(userID)
);
CREATE TABLE HashTag (
tweetID INTEGER NOT NULL,
content VARCHAR(140) NOT NULL,
PRIMARY KEY (content),
FOREIGN KEY (tweetID) REFERENCES Tweet(tweetID)
);
CREATE TABLE Follows (
follower INTEGER NOT NULL,
followee INTEGER NOT NULL,
PRIMARY KEY (follower, followee),
FOREIGN KEY (follower) REFERENCES User(userID),
FOREIGN KEY (followee) REFERENCES User(userID)
);
CREATE TABLE Retweets (
tweetID INTEGER NOT NULL,
userID INTEGER NOT NULL,
TIMESTAMP NOT NULL,
PRIMARY KEY (userID, tweetID),
FOREIGN KEY (userID) REFERENCES User(userID),
FOREIGN KEY (tweetID) REFERENCES Tweet(tweetID)
);
CREATE TABLE Mentions (
tweetID INTEGER NOT NULL,
userID INTEGER NOT NULL,
PRIMARY KEY (tweetID, userID),
FOREIGN KEY (tweetID) REFERENCES Tweet(tweetID),
FOREIGN KEY (userID) REFERENCES User(userID)
);
CREATE TABLE Favorites (
tweetID INTEGER NOT NULL,
userID INTEGER NOT NULL,
PRIMARY KEY (tweetID, userID),
FOREIGN KEY (tweetID) REFERENCES Tweet(tweetID),
FOREIGN KEY (userID) REFERENCES User(userID)
);
CREATE TABLE CanSee (
tweetID INTEGER NOT NULL,
userID INTEGER NOT NULL,
PRIMARY KEY (tweetID, userID),
FOREIGN KEY (tweetID) REFERENCES Tweet(tweetID),
FOREIGN KEY (userID) REFERENCES User(userID)
);
CREATE TABLE Message (
messageID INTEGER NOT NULL,
senderID INTEGER NOT NULL,
receiverID INTEGER NOT NULL,
content VARCHAR(140) NOT NULL,
TIMESTAMP NOT NULL,
PRIMARY KEY (messageID),
FOREIGN KEY (senderID) REFERENCES User(userID),
FOREIGN KEY (receiverID) REFERENCES User(userID)
);
答案 0 :(得分:3)
当它显示“NEAR __ ”时,它说的是在该点之前发生的事情触发了错误。
在这种情况下,这就是单词TIMESTAMP
。您列出了该列的TIMESTAMP
类型,但从未为其命名。也许这应该是modified_on TIMESTAMP
(或者那种效果)。