我從所有的參考表和主表
alter table test.PAYMENT drop foreign key PAYMENT_ibfk_1;
alter table test.ORDER_DETAILS drop foreign key ordr_dets_ibfk_1;
alter table test.TRANSACTION drop foreign key transaction_ibfk_1;
下降外鍵再後來改變了所有表和更改字符集
alter table test.PAYMENT CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
alter table test.TRANSACTION CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
alter table test.ORDER_DETAILS CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
然後再應用於外鍵
alter table niclient.PAYMENT add foreign key PAYMENT_ibfk_1 (paymentTransId) references `TRANSACTION` (`transId`) ON DELETE CASCADE;
alter table niclient.ORDER_DETAILS add foreign key ordr_dets_ibfk_1 (ordrDetTransId) REFERENCES `TRANSACTION` (`transId`) ON DELETE CASCADE;
alter table niclient.TRANSACTION add foreign key transaction_ibfk_1 (transCompId) REFERENCES `COMPANY_DETAILS` (`compId`) ON DELETE CASCADE;
解決它
它完美地工作得很好:-)
SET FOREIGN_KEY_CHECKS = 0;完全適用於我的MySQL 5.6.19b,InnoDB表,從latin1轉換爲utf8,utf8_unicode_ci –
@Vajk這很可能是因爲版本的差異,因爲我在MySQL-5.5.25上做了這個。感謝您提到它在MySQL-5.6中的工作 –