mysql建表语句以及添加外键报1215错误

来源:互联网 发布:聚合数据 股票接口 编辑:程序博客网 时间:2024/05/17 21:48

其中外键错误解决办法:

保证外建的主表字段和子表字段类型和长度要一致



SET foreign_key_checks=0;
drop table if exists feedrice;

/*==============================================================*/
/* Table: FeedRice                                              */
/*==============================================================*/
create table feedrice
(
   ID                   int not null auto_increment,
   ORG_ID               smallint(6),
   OCCUR_DATE           date,
   BUILD_NUM            smallint,
   FEED                 int,
   RICE                 int,
   CREATE_DT            datetime,
   UPDATE_DT            datetime,
   primary key (ID)
);

alter table feedrice add constraint FK_Reference_154 foreign key (ORG_ID)
      references organize (ID) on delete restrict on update restrict;

SET foreign_key_checks=1;



0 0
原创粉丝点击