Almost all the information I need about the database I can find in information_schema
This time I needed to read the details of all foreign keys in the database with a single request . I found everything in the info_schema.key_Column_usage file, but could not find constraints like on delete, on update
I could do show create table for all individual tables. But is there a way to get this data through some sort of select query like this?
SELECT CONSTRAINT_NAME, TABLE_NAME,COLUMN_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME FROM information_schema.`KEY_COLUMN_USAGE` WHERE table_schema = 'mydbname' AND referenced_column_name IS NOT NULL
It does this job well, but simply skips such restrictions as on delete, on update . How can I get these values โโso that I can get all the information about foreign keys in one request?
source share