2013-05-02 54 views
-3

我收到從MySQL的錯誤,可能是我見過的最無用的錯誤消息:模糊的SQL錯誤......這裏發生了什麼事?

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

'TIMESTAMP NOT NULL,'你可能想要解決這個問題 – Ejaz 2013-05-02 16:19:39

回答

3

當它說:「近__」它說的是正確的事情之前觸發點的錯誤。

在這種情況下,這是字TIMESTAMP。您列出該列的TIMESTAMP類型,但從未給出名稱。也許這應該是modified_on TIMESTAMP(或者是這個效果)。

+0

啊,就是這樣。非常感謝!絕對讚賞。 – 2013-05-02 16:19:39