简体   繁体   中英

MariaDB 10.0 renames foreign keys on dump insert

State: Two exact database setups with MariaDb 10.0

One is full the other empty waiting for the dump to insert.

Foreign key constraint exist on a table:

ALTER TABLE `rel_account_account` ADD CONSTRAINT `FK_Account` FOREIGN KEY (`InAccountID`) REFERENCES `t_account` (`ID`) ON DELETE RESTRICT ON UPDATE CASCADE;

If I dump the database by

mysqldump -uroot -p --default-character-set=utf8 livedb -r live.sql

and restore it on the other system by

mysql -uroot -p --default-character-set=utf8 livedb
mysql> SOURCE live.sql

Afterwards the foreign keys are renamed to a specific schema:

<tablename>_ifbk<index>

that means the FK:

FK_Account

has been renamed automatically to:

rel_account_account_ifbk_1

I did not find anything about such a possibility in the docs, so i ask this here. Is this a configurable feature, because if its done automatically i would assume that it could be very critical?

Any ideas?

EDIT: Please see answer.

ok, seems i overwrote the dump before inserting it with another one created from NAVICAT MySql tool.

but this one, which should theoretically be the same, did not create the statements as shown by SHOW CREATE TABLE. (Thanks to @Michael Berkowski for the hint!)

I discovered that there is an option under advanced to use statements from SHOW CREATE TABLE, which does export the FK constraints with their names.

So the first dump did not set the FK names, therefor mariadb created it own key names for them, which is technically correct.

So it was a simple homemade problem, with a little technical salt.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM