How to drop unique in MySQL?

前端 未结 10 733
[愿得一人]
[愿得一人] 2020-12-07 11:20
Create Table: CREATE TABLE `fuinfo` (
  `fid` int(10) unsigned NOT NULL,
  `name` varchar(40) NOT NULL,
  `email` varchar(128) NOT NULL,
  UNIQUE KEY `email` (`email         


        
相关标签:
10条回答
  • 2020-12-07 11:24

    Simply you can use the following SQL Script to delete the index in MySQL:

    alter table fuinfo drop index email;
    
    0 讨论(0)
  • 2020-12-07 11:24

    Use below query :

    ALTER TABLE `table_name` DROP INDEX key_name;
    

    If you don't know the key_name then first try below query, you can get key_name.

    SHOW CREATE TABLE table_name
    

    OR

    SHOW INDEX FROM table_name;
    

    If you want to remove/drop primary key from mysql table, Use below query for that

    ALTER TABLE `products` DROP INDEX `PRIMARY`;
    

    Code Taken from: http://chandreshrana.blogspot.in/2015/10/how-to-remove-unique-key-from-mysql.html

    0 讨论(0)
  • 2020-12-07 11:27

    This may help others

    alter table fuinfo drop index fuinfo_email_unique
    
    0 讨论(0)
  • 2020-12-07 11:30

    Try it to remove uique of a column:

    ALTER TABLE  `0_ms_labdip_details` DROP INDEX column_tcx
    

    Run this code in phpmyadmin and remove unique of column

    0 讨论(0)
  • 2020-12-07 11:31

    mysql> DROP INDEX email ON fuinfo;

    where email is the unique key (rather than the column name). You find the name of the unique key by

    mysql> SHOW CREATE TABLE fuinfo;
    

    here you see the name of the unique key, which could be email_2, for example. So...

    mysql> DROP INDEX email_2 ON fuinfo;
    
    mysql> DESCRIBE fuinfo;
    

    This should show that the index is removed

    0 讨论(0)
  • 2020-12-07 11:41

    DROP INDEX column_name ON table_name

    Select the database and query form the sql tab.This removes the index of the particular column. It worked for me in PHP MyADMIN

    0 讨论(0)
提交回复
热议问题