请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

最后一个表格 创建有问题

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回答

翔仔 2018-02-05 19:58:16

同学好,这样贴代码是不好看出来的,具体执行的时候应该会报语法错误,同学可以对比一下我这边的创建语句,执行是没有问题的,除非同学对应的外键表没有创建:)

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;


0 回复 有任何疑惑可以回复我~
提问者 qq_一缕阳光_31 2018-02-05 19:57:03

提醒是编译错误 

 

0 回复 有任何疑惑可以回复我~
  • 翔仔 #1
    它有个near字样,就是那附近错了,我贴我这边试了下
     shop_category_id int(11) defalut null,
    
      shop_desc varchar(2000) defalut null,
    写错字了。。。不是defalut是default
    PS:建议同学这类问题一定要细心自己解决,对你以后会很有帮助,因为这是入门编程必备的技能:)
    回复 有任何疑惑可以回复我~ 2018-02-05 20:01:19
  • 提问者 qq_一缕阳光_31 回复 翔仔 #2
    谢谢 找到了
    回复 有任何疑惑可以回复我~ 2018-02-05 20:12:24

相似问题

登录后可查看更多问答,登录/注册

问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号