Are MySQL Foreign Key Auto-Generated Names Deterministic?

When constraints are created, they are given names that look something like this: "FK5E6B788655A1514E."

I am wondering if name generation is deterministic or random. I noticed that the two separate databases that I used, the same schemas, ended up with the same FK names.

Does it make sense when creating a script update from one version of a schema to another to use these constraint names?

+3
source share
2 answers

I have been thinking about this for a long time, and today I came across your post after some of my own research. Hope that what I found helps you.

http://dev.mysql.com/doc/refman/5.5/en/innodb-adaptive-hash.html:

InnoDB , . InnoDB -, . innodb_adaptive_hash_index --skip-innodb_adaptive_hash_index .

:

, , .

adaptive_hash_index : http://dev.mysql.com/doc/refman/5.5/en/glossary.html#glos_adaptive_hash_index

:

- InnoDB index, B-. MySQL - , B-tree, . ; B- .

, : http://dev.mysql.com/doc/refman/5.5/en/index-btree-hash.html

, , , db , , / script.

+3

, . . , MySQL , , , .

, , ?

create table foo (
  i int, 
  constraint `i_is_unique` unique key (i)
);
+1

Source: https://habr.com/ru/post/1718324/


All Articles