Linux, FreeBSD, Juniper, Cisco / Network security articles and troubleshooting guides
https://forum.ivorde.com/

Mysql drop (remove) unique key
https://forum.ivorde.com/mysql-drop-remove-unique-key-t19661.html
Page 1 of 1

Author:  mandrei99 [ Wed Jan 14, 2015 7:53 pm ]
Post subject:  Mysql drop (remove) unique key

To remove a mysql unique key, aka index it first needs to be checked.

How to check mysql unique indexes existing on a table:
Code:
mysql> SHOW INDEXES FROM my_table; 
+----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table    | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| my_table |          0 | id       |            1 | id          | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
+----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

Drop unique key (DROP INDEX `id` on my_table;):
Code:
mysql> DROP INDEX `id` on my_table;
Query OK, 0 rows affected (0.29 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> SHOW INDEXES FROM my_table;               
Empty set (0.00 sec)


Please make sure you have backups before running any drop/truncate commands in mysql.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/