How to remove unique key from mysql table

后端 未结 7 1967
旧巷少年郎
旧巷少年郎 2021-01-30 08:34

I need to remove a unique key from my mysql table. How can remove that using mysql query.

I tried this but it is not working

alter table tbl_quiz_attempt         


        
7条回答
  •  一个人的身影
    2021-01-30 08:56

    First you need to know the exact name of the INDEX (Unique key in this case) to delete or update it.
    INDEX names are usually same as column names. In case of more than one INDEX applied on a column, MySQL automatically suffixes numbering to the column names to create unique INDEX names.

    For example if 2 indexes are applied on a column named customer_id

    1. The first index will be named as customer_id itself.
    2. The second index will be names as customer_id_2 and so on.

    To know the name of the index you want to delete or update

    SHOW INDEX FROM 
    

    as suggested by @Amr

    To delete an index

    ALTER TABLE  DROP INDEX ;
    

提交回复
热议问题