Adding foreign key to existing table gives error 1050 table already exists

后端 未结 9 1195
栀梦
栀梦 2021-01-07 18:11

I\'ve a table CustomizationSet with the columns:

customization_set_guid (which is a non-nullable guid and also the primary key)
creator_account_guid
and a fe         


        
9条回答
  •  误落风尘
    2021-01-07 18:39

    When using MysqlWorkbench the error is misleading. My issue was that I was trying to add a foreign key constraint on table that already had rows and one of the rows was empty (did not meet the FK constraint. Instead of complaining that constraint will fail if applied, MysqlWorkbench reported that table exists.

    Removing the offending row fixed (or adding and constraint acceptable value to the field) solved the problem.

提交回复
热议问题