Information Schema INNODB_SYS_FOREIGN Table

The Information Schema INNODB_SYS_FOREIGN table contains information about InnoDB foreign keys.

The PROCESS privilege is required to view the table.

It has the following columns:

ColumnDescription
IDDatabase name and foreign key name.
FOR_NAMEDatabase and table name of the foreign key child.
REF_NAMEDatabase and table name of the foreign key parent.
N_COLSNumber of foreign key index columns.
TYPEBit flag providing information about the foreign key.

The TYPE column provides a bit flag with information about the foreign key. This information is OR'ed together to read:

Bit FlagDescription
1ON DELETE CASCADE
2ON UPDATE SET NULL
4ON UPDATE CASCADE
8ON UPDATE SET NULL
16ON DELETE NO ACTION
32ON UPDATE NO ACTION

Example

SELECT * FROM INNODB_SYS_FOREIGN\G
*************************** 1. row ***************************
      ID: mysql/innodb_index_stats_ibfk_1
FOR_NAME: mysql/innodb_index_stats
REF_NAME: mysql/innodb_table_stats
  N_COLS: 2
    TYPE: 0
...

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.