Can't Drop foreign key in MySQL

后端 未结 7 639
粉色の甜心
粉色の甜心 2020-12-04 19:37

I have had a 1 to many relationship between course and instructor, which I wanted to drop. When I tried to drop the instructorID in course table it told me that. I couldn\'t

相关标签:
7条回答
  • 2020-12-04 20:37

    If any of you still not able to DROP the table. Try this. You can able to see all the details by running this

    SELECT
        TABLE_NAME,
        COLUMN_NAME,
        CONSTRAINT_NAME,
        REFERENCED_TABLE_NAME,
        REFERENCED_COLUMN_NAME
    FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
    WHERE REFERENCED_TABLE_NAME = 'ReferenceTableName'; <-- change only this
    

    If you want to see just the constrains

    SELECT
        CONSTRAINT_NAME
    FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
    WHERE REFERENCED_TABLE_NAME = 'ReferenceTableName';
    
    0 讨论(0)
提交回复
热议问题