我正在尝试创建这些表,但我遇到了这个错误
错误代码:1005。无法创建表
estadisticas
。tbl008_phase_competition
(错误:150“外键 约束不正确形成“)
当我尝试创建tbl008_phase_competition ...
时create table if not exists `tbl015_seasons` (
`id` smallint(4) unsigned not null auto_increment,
`id_competition` smallint(2) unsigned not null,
`description` varchar(100) not null,
primary key(`id`),
foreign key (`id_competition`) references `tbl001_competition` (`id`)
)ENGINE = InnoDB;
create table if not exists `tbl012_phase` (
`id` smallint(4) unsigned not null auto_increment,
`name` varchar(100) not null,
primary key (`id`)
)ENGINE = InnoDB;
create table if not exists `tbl008_phase_competition` (
`id_season` smallint(4) unsigned not null,
`id_phase` smallint(4) unsigned not null,
`year` int unsigned not null,
primary key (`id_season`, `id_phase`),
foreign key (`id_season`) references `tbl015_seasons` (`id`),
foreign key (`id_phase`) references `tbl012_phase` (`id`)
)ENGINE = InnoDB;
我做错了什么?
答案 0 :(得分:0)
请不要在此表中声明主键并检查:
if(Session["count"] != null)
count = (int)Session["count"];