create table tb_user
(user_id
int(100) not null auto_increment,user_name
varchar(200) not null default'',user_password
varchar(1000)not null,user_phone
varchar(1000),user_type
int(10)not null,user_email
varchar(2000) not null,user_img
varchar(2000) default null,create_time
datetime default null,last_edit_time
datetime default null,
primary key(user_id
)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
create table tb_lost
(lost_id
int(100)not null auto_increment,lost_type
varchar(2000) not null,lost_place
varchar(2000)not null,lost_user_id
int(100)not null,lost_user_name
varchar(2000)not null,lost_phone
varchar(1000) not null,lost_time
varchar(2000) not null,take_time
varchar(2000) not null,lost_img
varchar(2000) not null,
primary key(lost_id
),
constraint fk_lostuser_id
foreign key(lost_user_id
) references tb_user
(user_id
)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
create table tb_pick
(pick_id
int(100)not null auto_increment,pick_type
varchar(2000) not null,pick_place
varchar(2000)not null,pick_user_id
int(100)not null,pick_user_name
varchar(2000)not null,pick_phone
varchar(1000) not null,pick_time
varchar(2000) not null,take_time
varchar(2000) not null,pick_img
varchar(2000) not null,
primary key(pick_id
),
constraint fk_pcikuser_id
foreign key(pick_user_id
) references tb_user
(user_id
)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
create table ly_info
(ly_info_id
int(100)not null auto_increment,ly_user_id
int(100)not null,ly_txt
varchar(2000)not null,ly_time
varchar(2000)not null,
primary key(ly_info_id
),
constraint fk_ly_id
foreign key(ly_user_id
) referencestb_user
(user_id
)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
create table hf_info
(hf_id
int(100)not null auto_increment,hf_info_id
int(100)not null,hf_user_id
int(100)not null,hf_txt
varchar(2000)not null,hf_time
varchar(2000)not null,
primary key(hf_info_id
),
constraint hf_info_id
foreign key(ly_info_id
)referencesly_info
(hf_info_id
),
constraintfk_hf_id
foreign key(hf_user_id
)referencestb_user
(hf_user_id
)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
create table gg_info
(gg_id
int(100)not null auto_increment,gg_txt
varchar(2000)not null,gg_time
datetime not null,
primary key(gg_id
)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
第四张表的约束外键约束有问题,为什么
应该是第五张表吧。hf_info 你外键是user表,,user表没有hf_user_id这个字段。。
create table hf_info
(
hf_id int(100)not null auto_increment,
hf_info_id int(100)not null,
hf_user_id int(100)not null,
hf_txt varchar(2000)not null,
hf_time varchar(2000)not null,
primary key(hf_info_id),
constraint hf_info_id foreign key(ly_info_id) references ly_info(hf_info_id),
constraint fk_hf_id foreign key(hf_user_id) references tb_user(hf_user_id)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
[Err] 1072 - Key column 'ly_info_id' doesn't exist in table
实际跑一下,明显看到的错误
打错那里已经改了,但是我这里显示第四张表的外键约束不能建立
user表没有hf_user_id这个字段
第五张表,表中缺少字段。
显示ly_info_id键列不能建