日期:2014-05-16  浏览次数:20766 次

建表的时候,报1005错误
建表语句如下:
CREATE   TABLE   `my_notes`.`notes`   (
    `id`   INTEGER   UNSIGNED   NOT   NULL   AUTO_INCREMENT,
    `username`   VARCHAR(16)   NOT   NULL,
    `post_time`   DATETIME   NOT   NULL,
    `title`   VARCHAR(32)   NOT   NULL,
    `content`   TINYTEXT   NOT   NULL,
    PRIMARY   KEY   (`id`),
    CONSTRAINT   `FK_notes_1`   FOREIGN   KEY   `FK_notes_1`   (`username`)
        REFERENCES   `users`   (`username`)
        ON   DELETE   CASCADE
        ON   UPDATE   CASCADE
)
ENGINE   =   InnoDB;

------解决方案--------------------
带FOREIGN KEY的表很麻烦,把users表结构贴上来
------解决方案--------------------
http://blog.csdn.net/yuandafeng/archive/2006/02/12/597535.aspx