How to put FK constraint on two tables in mysql with one table with InnoDB and other is MyISAM

StackOverflow https://stackoverflow.com/questions/15017660

  •  10-03-2022
  •  | 
  •  

문제

Reason: liquibase.exception.JDBCException:

Error executing SQL ALTER TABLE `User` ADD CONSTRAINT `fk_user_location` FOREIGN KEY (`location_id`) REFERENCES `Location`(`id`) ON DELETE CASCADE:
          Caused By: Error executing SQL ALTER TABLE `UserLocation` ADD CONSTRAINT `fk_user_location_location_id` FOREIGN KEY (`location_id`) REFERENCES `Location`(`id`) ON DELETE CASCADE:
          Caused By: Can't create table 'usiapp_db.#sql-399a_177a7' (errno: 150)
도움이 되었습니까?

해결책

You cannot. You have to convert your MyISAM table to InnoDB if you want create foreign keys to or from it:

ALTER TABLE MyIsamTable ENGINE=InnoDB;

You can do this dynamically, without taking down your database.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top