I have a MySQL table with foreign key constraints, eg.
CREATE TABLE `yiingles_version` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`package_id` int(11) NOT NULL,
`version` varchar(64) NOT NULL DEFAULT '',
`distUrl` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `package_id` (`package_id`),
CONSTRAINT `yiingles_version_ibfk_1`
FOREIGN KEY (`package_id`) REFERENCES `yiingles_package` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
How can I get programmatically the values for ON DELETE and ON UPDATE, in this case CASCADE?
I’ve seen this question and also took a look at MySQL’s information_schema database, but did not find a way to get the values mentioned above.
Have a look at the
information_schema.referential_constraintstable. Specifically, theUPDATE_RULEandDELETE_RULEcolumns.