createdatabasebbs;usebbs;createtablebbs_forum(forum_idintnotnull,forum_titlevarchar(100),form_desctext,form_themeNumint,forum_datetimetimestamp,primarykey(forum_id))ENGIN...
create database bbs;
use bbs;
create table bbs_forum(
forum_id int not null,
forum_title varchar(100),
form_desc text,
form_themeNum int,
forum_datetime timestamp,
primary key (forum_id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
create table bbs_user(
user_id int not null,
user_realname varchar(100),
user_phone varchar(20),
user_email varchar(100),
user_address varchar(100),
user_datetime timestamp,
primary key (user_id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
create table bbs_login(
user_id int not null,
user_name varchar(45) ,
user_password varchar(45),
foreign key(user_id) references bbs_user(user_id),
primary key (user_id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
create table bbs_role(
role_id int not null,
user_name varchar(45),
role_name varchar(45),
foreign key(user_name) references bbs_login(user_name),
primary key (role_id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
create table bbs_message(
msg_id int not null,
forum_id int not null,
msg_title varchar(100),
msg_content text,
user_id int not null,
msg_datetime timestamp,
foreign key(forum_id) references bbs_forum(forum_id),
foreign key(user_id) references bbs_user(user_id),
primary key(msg_id,forum_id,user_id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
create table bbs_theme(
theme_id int not null,
theme_title varchar(100),
theme_content text,
forum_id int not null,
user_id int not null,
theme_msgNum int,
theme_datetime timestamp,
theme_accessNum int,
theme_isLocked boolean,
theme_isTop boolean,
foreign key(forum_id) references bbs_forum(forum_id),
foreign key(user_id) references bbs_user(user_id),
primary key(theme_id,forum_id,user_id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
除了bbs_role其他表都建成功了,提示错误为:
错误代码 1005, SQL 状态HY000: Can't create table 'bbs.bbs_role' (errno: 150)
展开