mysql 不能建表问题
操作过程:
<!-- lang: sql -->
CREATE TABLE `xxx` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`channelId` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK_23xrrhie63xc8f7h3m7pedk03` (`channelId`),
CONSTRAINT `FK_23xrrhie63xc8f7h3m7pedk03` FOREIGN KEY (`channelId`) REFERENCES
`t_channel` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
drop table xxx;
create table xxx (id int);
错误信息
Can't create table 'xxx.xxx' (errno: 150)
错误原因
由于存在外键索引,外键索引一直存在所以导致同名表建不成功,必须要先删除外键,删除key,最后才能删除表