hibernate CommandAcceptanceException: Error executing DDL


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);

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM