schema.spi.CommandAcceptanceException: Error executing DDL "alter table idm_role_users add constraint FKbbb0hf3h6de22q346hty2916d foreign key (users_id) references idm_user (id)"

 

某一个表中已经存在数据;此时不能拥修改表约束;

 

 

 

 

 

 

CREATE TABLE IF NOT EXISTS `student`(
`id` INT(11) AUTO_INCREMENT,
`name` VARCHAR(32),
`age` int(11),
`t_id` int(11),
PRIMARY KEY ( `id` )
)ENGINE=InnoDB DEFAULT CHARSET=utf8;

 


CREATE TABLE IF NOT EXISTS `teacher`(
`id` INT(11) AUTO_INCREMENT,
`name` VARCHAR(32),
`age` int(11),
`t_id` int(11),
PRIMARY KEY ( `id` )
)ENGINE=InnoDB DEFAULT CHARSET=utf8;

 


insert into teacher values(1,'zs',19,1);

 

-- ------------------

 

alter table student add constraint fff_k1 foreign key (t_id) references teacher (id);

 

相关文章:

  • 2021-11-03
  • 2021-11-02
  • 2022-12-23
  • 2022-12-23
  • 2021-04-26
  • 2021-04-27
  • 2021-05-26
  • 2021-09-10
猜你喜欢
  • 2021-08-27
  • 2022-12-23
  • 2021-05-03
  • 2021-07-12
  • 2021-11-05
  • 2022-12-23
相关资源
相似解决方案