About foreign key on mysql

I'm migrating an old Sybase database to MySQL and I have to create foreign keys. Now, since Sybase exports its data, I've tried to use its query as it is on MySQL:

ALTER TABLE Mosaico.fornit_col
ADD FOREIGN KEY fkey_fco_fornit_maz ( fco_idformaz ) 
REFERENCES Mosaico.fornit_maz ( fma_id );
--
ALTER TABLE Mosaico.fornit_col
ADD FOREIGN KEY fkey_fco_mater_col ( fco_idmatcol ) 
REFERENCES Mosaico.mater_col ( mco_id );
--

and seems to works good. If I execute them on MySQL Admin Console, the queries work, but on Workbench, the second one gives this error:

ALTER TABLE Mosaico.fornit_col ADD FOREIGN KEY fkey_fco_mater_col ( fco_idmatcol )  REFERENCES Mosaico.mater_col ( mco_id ) Error Code: 1050. Table '.\mosaico\fornit_col' already exists

What's the problem?

Answers


Check out the bug report here:

MySQL Bug 55296

In the end, the people with the problem upgraded their server and it fixed the issue. From reading it, I'm not sure that there isn't a bug in there somewhere. They did have some workarounds like putting in constraint names/changing them. Try some of their fixes. If you think this is the same, and you can repeat the error, 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


Need Your Help

IIS8 http to https redirect stuck in a loop

redirect iis https

I have used so many forums and officiall IIS, ASP.Net an Microsoft Website examples on how to enable a simple http to https redirect on IIS8.5 but all I get no matter what is a loop error.

How do you remove the space inserted automatically in Ajax control toolkit tab panel control

asp.net ajax asp.net-ajax ajaxcontroltoolkit

The Ajax control toolkit tab panel automatically inserts a space by all four corners of the body. For example, go to http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/Tabs/Tabs.aspx and look at the