用sql脚本建五个表,总提示出错!请高人修改!
/*blog基本信息表*/
CREATE TABLE blog(
id int(11) NOT NULL auto_increment,
username varchar(20) NOT NULL,
password varchar(20) NOT NULL,
subject varchar(100) NOT NULL,
email varchar(50) NOT NULL,
image varchar(100) NOT NULL,
visitcount int(11) NULL,
PRIMARY KEY (id)
)ENGINE=MyISAM DEFAULT CHARSET=gbk;
/*文章分类基本信息表*/
CREATE TABLE sort(
id int(11) NOT NULL auto_increment,
name varchar (40) NOT NULL,
blogid int(11) NOT NULL
REFERENCES blog(id) ON DELETE CASCADE,
PRIMARY KEY (id)
)ENGINE=MyISAM DEFAULT CHARSET=gbk;
/*文章基本信息表*/
CREATE TABLE article(
id int(11) NOT NULL auto_increment,
title varchar (20) NOT NULL,
content TEXT NULL,
pubtime DATETIME NOT NULL,
blogid int(11) NOT NULL
REFERENCES blog(id) ON DELETE CASCADE,
sortid int(11) NULL
REFERENCES sort(id) ON DELETE CASCADE,
PRIMARY KEY (id)
)ENGINE=MyISAM DEFAULT CHARSET=gbk;
/*评论基本信息表*/
CREATE TABLE feedback(
id int(11) NOT NULL auto_increment,
uname varchar (20) NOT NULL,
content TEXT(5000) NULL,
pubtime DATETIME NOT NULL,
articleid int(11) NOT NULL
REFERENCES article(id) ON DELETE CASCADE,
PRIMARY KEY (id)
)ENGINE=MyISAM DEFAULT CHARSET=gbk;
/*友情连接基本信息表*/
CREATE TABLE links(
id int(11) NOT NULL auto_increment,
name varchar (40) NOT NULL,
url varchar (100) NOT NULL,
blogid int(11) NOT NULL
REFERENCES blog(id) ON DELETE CASCADE,
PRIMARY KEY (id)
)ENGINE=MyISAM DEFAULT CHARSET=gbk;
/*
其中blogid与blog表的id相关联,
sortid与sort表的id相关联,
articleid与article表的id相关联。
*/
------解决方案--------------------报错在哪?
------解决方案--------------------/*blog基本信息表*/
CREATE TABLE blog(
id int(11) NOT NULL auto_increment,
usernamevarchar(20)NOT NULL,
passwordvarchar(20)NOT NULL,
subjectvarchar(100)NOT NULL,
emailvarchar(50)NOT NULL,
imagevarchar(100)NOT NULL,
visitcountint(11)NULL,
PRIMARY KEY(id)
)ENGINE=MyISAM DEFAULT CHARSET=gbk;
字段名和字段类型之间都没有空格?
------解决方案--------------------脚本该空格的地方未空格,包括字段名与字段类型之间、外键Reference与字段名之间等等!
------解决方案--------------------错误太多了,主要是因为没有适当的空格导致的,所以要小心!
/*blog基本信息表*/
CREATE TABLE blog(
id int(11) NOT NULL auto_increment,
username varchar(20) NOT NULL,
password varchar(20) NOT NULL,
subject varchar(100) NOT NULL,
email varchar(50) NOT NULL,
image varchar(100) NOT NULL,
visitcount int(11) NULL,
PRIMARY KEY(id)