0

This is more of a meta-question than I need actual help with but I could not find information about it elsewhere. Today, I tried to delete two tables from a database and upon trying I get the error message that a "foreign key constraint fail" has occurred. No problem, just delete the foreign key as well. So my query looked like the following:

ALTER TABLE Database.mytable
DROP FOREIGN KEY abc_ibfk_1;
ALTER TABLE Database.mytable
DROP COLUMN abc;

I get another error message that says "Error Code: 1025. Error on rename of './Database/#sql-461_somerandomnumbers' to './Database/mytable' (errno: 150)"

I figure I would use the built-in right-click, drop column in the edit table so I use that and realise it uses a "drop index" as well. So I change my code to look exactly like Workbench would do itself:

ALTER TABLE Database.mytable
DROP FOREIGN KEY abc_ibfk_1;
ALTER TABLE Database.mytable
DROP COLUMN abc, DROP INDEX abc;

Now, this is exactly as Workbench would do it, only that when I type it myself it will not execute (above error message) but when I allow Workbench to execute the query it works fine.


So, my question is why is Workbench able to execute the drop query when I can't copy/paste it?

2
  • Please show the table schemas?
    – hjpotter92
    Mar 20, 2013 at 9:58
  • Not sure what you mean with table schemas here, please explain. Mar 20, 2013 at 13:49

1 Answer 1

2

Probably your manually exectued query is (wrongly) augmented, e.g. the automatic LIMIT clause is added. After running that query look in the output area (Action Output). It contains the exact query that was sent to the server. Does it contain anything unusual? Alternatively use the admin section to look at the general log (if enabled) to see what query was sent.

1
  • 7 years later, but yes, it looks like that the built-in clauses were different between the workbench settings and the manually executed query. Thank you for this! Apr 27, 2020 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.