MySQL Big FK标识符

1 php mysql foreign-keys restriction foreign-key-relationship

我正在尝试创建一个fk,但MySQL不允许它...

Identifier name 'foobarbaz_FK_CATALOG_PRODUCT_ENTITY_WEEE_DISCOUNT_PRODUCT_ENTITY' is too long [ CREATE TABLE `foobarbaz_weee_discount` (   `entity_id` int(10) unsigned NOT NULL DEFAULT '0',   `website_id` smallint(5) unsigned NOT NULL DEFAULT '0',   `customer_group_id` smallint(5) unsigned NOT NULL,   `value` decimal(12,4) NOT NULL DEFAULT '0.0000',   KEY `foobarbaz_FK_CATALOG_PRODUCT_ENTITY_WEEE_DISCOUNT_WEBSITE` (`website_id`),   KEY `foobarbaz_FK_CATALOG_PRODUCT_ENTITY_WEEE_DISCOUNT_PRODUCT_ENTITY` (`entity_id`),   KEY `foobarbaz_FK_CATALOG_PRODUCT_ENTITY_WEEE_DISCOUNT_GROUP` (`customer_group_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ]
Run Code Online (Sandbox Code Playgroud)

有没有办法添加大fks?谢谢.

irc*_*ell 6

不,它被硬编码到MySQL中,请参阅文档(在页面底部).但它与FK的名称无关.这是索引的名称太长(最多64个字符):

`Identifier`                  `Maximum Length (characters)`
Database                      64
Table                         64
Column                        64
Index                         64
Constraint                    64
Stored Procedure or Function  64
Trigger                       64
View                          64
Alias                         256 (see exception following table)
Compound Statement Label      16
Run Code Online (Sandbox Code Playgroud)