Home  >  Article  >  Database  >  InnoDB 中foreign key使用注意事项

InnoDB 中foreign key使用注意事项

WBOY
WBOYOriginal
2016-06-07 17:27:551180browse

在 sel statement 中的inserts,deletes,updates 很多行的时候,fk 会一行一行检查。 innodb是设置 shared row_level locks 在父表

Innodb foreign key 和 sql  standards的区别:

在 sel statement 中的inserts,deletes,updates 很多行的时候,fk 会一行一行检查。 innodb是设置 shared row_level locks 在父表或者子表上,MySQL CHECK 会立即检查是否有符合的行,,并不会推迟到事务提交的时候,在innodb上建立fk的条件:

1、innodb允许关联到一个index或者一组 columns(第一个column 必须是index)

2、innodb不支持在用户自定义的分区表上建立fk

3、innodb允许fk关联到一个non-unique key .

关联的所涉及到的动作:

1、set default MySQL SERVER 支持,但Innodb不支持。

2、如果子表中对应父表的多条记录,如果constraint type 为restrict,那么innodb是不允许删除

父表当中的这几条记录的。

3、innodb进行级联操作时,使用depth-first 算法,通过行记录的索引进行查找

4、ON UPDATE CASCADE or ON UPDATE SET NULL 不能进行self-referential

可以在 INFORMATION_SCHEMA.KEY_COLUMN_USAGE 中查看 innodb key的具体情况。也可以通过show

engine innodb status 来 进行查看 fk 的错误。

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn