Drop muli-column unique key without dropping foreign key?

后端 未结 1 1387
抹茶落季
抹茶落季 2020-12-21 10:48

I am trying to delete a multi-column unique key from a table that also has a foreign key. I keep getting \'errno 150\', unless I delete the foreign key first.

For e

相关标签:
1条回答
  • 2020-12-21 11:41

    a FOREIGN KEY REFERENCES, require a key,
    the only key that can be used is t_unique_key, thats why you can't remove it.
    so add another matching key first, and then remove the old key, in your case the othertable_id field

    ALTER TABLE `testtable`
    ADD KEY (othertable_id),
    DROP KEY `tt_unique_key`;
    
    0 讨论(0)
提交回复
热议问题