How to drop unique key or index from a table ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • santhanalakshmi
    New Member
    • May 2009
    • 147

    How to drop unique key or index from a table ?

    Hi,

    By mistakenly,i added three UNIQUE index on a single column.Out of three,i removed one UNIQUE index from a table.Now,i want to remove remaining unique index from a table.

    Code:
         mysql> show index from uniqueindex;
    +-------------+------------+----------+--------------+-------------+-----------+
    -------------+----------+--------+------+------------+---------+
    | Table       | Non_unique | Key_name | Seq_in_index | Column_name | Collation |
     Cardinality | Sub_part | Packed | Null | Index_type | Comment |
    +-------------+------------+----------+--------------+-------------+-----------+
    -------------+----------+--------+------+------------+---------+
    | uniqueindex |          0 | id_2     |            1 | id          | A         |
               3 |     NULL | NULL   |      | BTREE      |         |
    | uniqueindex |          0 | id_3     |            1 | id          | A         |
               3 |     NULL | NULL   |      | BTREE      |         |
    +-------------+------------+----------+--------------+-------------+-----------+
    -------------+----------+--------+------+------------+---------+
    2 rows in set (0.00 sec)


    Now, I want to remove this unique key as shown above...

    Next,i am running this query.....why it shows me as a PRIMARY KEY in the key field ?


    Code:
    mysql> desc uniqueindex;
    +---------------+-------------+------+-----+---------+-------+
    | Field         | Type        | Null | Key | Default | Extra |
    +---------------+-------------+------+-----+---------+-------+
    | id            | int(11)     | NO   | PRI | 0       |       |
    | name          | varchar(50) | YES  |     |         |       |
    | place         | varchar(50) | YES  |     | NULL    |       |
    | qualification | varchar(50) | YES  |     | NULL    |       |
    +---------------+-------------+------+-----+---------+-------+
    4 rows in set (0.01 sec)



    Thanks in advance
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Can't you use

    DROP INDEX index_name ON tbl_name

    ?

    The key field is showing keys you have set up on the table, so id is the primary key of the table uniqueindex.

    Comment

    Working...