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

后端 未结 9 1089
栀梦
栀梦 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:54

    It looks like there is a bug report for this at MySQL located here:

    MySQL Bug 55296

    In the end, I guess they upgraded their server and it fixed the issue. From reading it, I'm not sure though. They did have some workarounds like putting in constraint names/changing them. If you think this is the same, I would request that the bug is reopened.

    At one point, they mention the types didn't match and workbench was responding with the wrong error (it should have been an errno 150, or errno 121). You can see the causes for those errors here: MySQL Foreign Key Errors and Errno 150

    0 讨论(0)
  • 2021-01-07 18:55

    I had a similar problem and in the end it was a problem of Integrity Constraint. The Foreign Key column was referencing a foreign column that didnt exist.

    Try run the following to test whether this is the case:

    select r.customization_set_guid, c.customization_set_guid
    from Registration r
    right join CustomizationSet c
    on 
    r.customization_set_guid = c.customization_set_guid
    where isnull(c.customization_set_guid);
    
    0 讨论(0)
  • 2021-01-07 19:02

    So a team member figured this out. The one table was set with the type utf8_general, and another was set to the type default. I didn't think this was an issue, since the default is utf8_general, but apparently mysql just looks at the type names and not the underlying type.

    0 讨论(0)
提交回复
热议问题