[英]Getting foreign key constraints from a MySQL table
I have a MySQL table with foreign key constraints, eg. 我有一个带有外键约束的MySQL表,例如。
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
? 如何以编程方式获取
ON DELETE
和ON UPDATE
的值,在本例中为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. 我已经看到了这个问题并且还看了一下MySQL的
information_schema
数据库,但没有找到获得上述值的方法。
Have a look at the information_schema.referential_constraints
table. 看一下
information_schema.referential_constraints
表。 Specifically, the UPDATE_RULE
and DELETE_RULE
columns. 具体来说,是
UPDATE_RULE
和DELETE_RULE
列。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.