我們不支持InnoDB數據庫。因此,在從5.0遷移到MySQL 5.5之前,我希望將所有InnoDB表更改爲MyISAM,但其中很多都有外鍵約束。set foreign_key_checks = 0不起作用MySQL 5.0
因此,我想在會話級別上禁用它,執行set foreign_key_checks=0
但仍然獲得相同的外鍵錯誤。
任何建議都會有很大的幫助。
mysql> SET foreign_key_checks = 0;
Query OK, 0 rows affected (0.00 sec)
mysql> use sn;
Database changed
mysql> alter table facility engine='MyISAM';
ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails
令人驚訝:
mysql> SHOW Variables WHERE Variable_name='foreign_key_checks';
Empty set (0.00 sec)
mysql> SET foreign_key_checks = 0;
Query OK, 0 rows affected (0.00 sec)
mysql> SHOW Variables WHERE Variable_name='foreign_key_checks';
Empty set (0.00 sec)
的MySQL 5.0 documentation顯示變量確實存在。
Here is the table structure of `facility` table:
| facility | CREATE TABLE `facility` (
`FacilityId` bigint(20) NOT NULL auto_increment,
`FacilityName` varchar(45) default NULL,
`ViewerId` bigint(20) default NULL,
`MessageTemplate` varchar(256) default NULL,
`RecApp` varchar(60) default NULL,
`RecFacility` varchar(60) default NULL,
`SendApp` varchar(60) default NULL,
`SendFacility` varchar(60) default NULL,
`MirthChannelEnable` int(1) NOT NULL default '0',
`CompletenessCriteria` int(2) NOT NULL,
`RetryLimit` int(2) NOT NULL default '3',
`WatchDelay` int(11) NOT NULL,
`RetryDelay` int(11) NOT NULL,
`AckTimeOut` int(11) NOT NULL,
`KeepConOpen` int(1) NOT NULL default '0',
`SendTimeout` int(11) NOT NULL,
`EncryptURL` int(1) NOT NULL default '0',
`Host` varchar(15) NOT NULL,
`Port` int(11) NOT NULL,
`CreationDate` timestamp NOT NULL default CURRENT_TIMESTAMP,
`Description` varchar(256) default NULL,
`EventLogOffset` int(11) NOT NULL default '0',
PRIMARY KEY (`FacilityId`),
KEY `Fk_Fac_ViewerId_idx` (`ViewerId`),
CONSTRAINT `Fk_Fac_ViewerId` FOREIGN KEY (`ViewerId`) REFERENCES `viewer` (`ViewerId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
顯示錶結構 –
@MuhammadMuazzam感謝您的詢問,補充。不適用於其他表格,因爲有限制,所以可能不是表格特定的問題。 – kingsmasher1