最后一个表格 创建有问题
来源:2-3 实体类设计与表创建B
qq_一缕阳光_31
2018-02-05
create table tb_shop(
shop_id int(10) not null auto_increment,
owner_id int(10) not null comment '店铺创建人',
shop_name varchar(256) not null,
area_id int(5) default null,
shop_category_id int(11) defalut null,
shop_desc varchar(2000) defalut null,
shop_addr varchar(200) default null,
phone varchar(128) default null,
shop_img varchar(1024) default null,
priority int(3) default null,
create_time datetime default null,
last_edit_time datetime default null,
enable_status int(2) not null default 0,
advice varchar(255) default null,
primary key (shop_id),
constraint fk_shop_area foreign key (area_id)
references tb_area (area_id),
constraint fk_shop_profile foreign key (owner_id)
references tb_person_info (user_id),
constraint fk_shop_shopcate foreign key
(shop_category_id) references tb_shop_category
(shop_category_id)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
怎么都是通不过 看不到哪里出问题了
2回答
-
同学好,这样贴代码是不好看出来的,具体执行的时候应该会报语法错误,同学可以对比一下我这边的创建语句,执行是没有问题的,除非同学对应的外键表没有创建:)
CREATE TABLE `tb_shop` ( `shop_id` int(10) NOT NULL AUTO_INCREMENT, `owner_id` int(10) NOT NULL COMMENT '店铺创建人', `area_id` int(5) DEFAULT NULL, `shop_category_id` int(11) DEFAULT NULL, `shop_name` varchar(256) NOT NULL, `shop_desc` varchar(1024) DEFAULT NULL, `shop_addr` varchar(200) DEFAULT NULL, `phone` varchar(128) DEFAULT NULL, `shop_img` varchar(1024) DEFAULT NULL, `priority` int(3) DEFAULT '0', `create_time` datetime DEFAULT NULL, `last_edit_time` datetime DEFAULT NULL, `enable_status` int(2) NOT NULL DEFAULT '0', `advice` varchar(255) DEFAULT NULL, PRIMARY KEY (`shop_id`), KEY `fk_shop_area` (`area_id`), KEY `fk_shop_profile` (`owner_id`), KEY `fk_shop_shopcate` (`shop_category_id`), CONSTRAINT `fk_shop_area` FOREIGN KEY (`area_id`) REFERENCES `tb_area` (`area_id`), CONSTRAINT `fk_shop_profile` FOREIGN KEY (`owner_id`) REFERENCES `tb_person_info` (`user_id`), CONSTRAINT `fk_shop_shopcate` FOREIGN KEY (`shop_category_id`) REFERENCES `tb_shop_category` (`shop_category_id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
012018-02-05 -
qq_一缕阳光_31
提问者
2018-02-05
提醒是编译错误
022018-02-05
相似问题