Eric Jensen <[EMAIL PROTECTED]> wrote on 07/20/2005 02:00:26 PM:

> I have a field that was set as a unique key when created via:
> UNIQUE KEY `username` (`username`)
> 
> I no longer want it unique, but can't see a way with ALTER TABLE to
> remove it.  It isn't the Primary Key or an index.  The describe looks
> like this:
> 
> +----------+-------------+------+-----+---------+-------+
> | Field    | Type        | Null | Key | Default | Extra |
> +----------+-------------+------+-----+---------+-------+
> | username | varchar(25) |      | UNI |         |       |
> +----------+-------------+------+-----+---------+-------+
> 
> Anything I can do short of dumping the table, droping it, then
> re-inserting everything?
> 
> Eric
> 
> 

You have two options:

DROP INDEX (http://dev.mysql.com/doc/mysql/en/drop-index.html)
or
ALTER TABLE DROP INDEX (
http://dev.mysql.com/doc/mysql/en/alter-table.html)

In both commands you will need to provide the name of the key. You can get 
the name of the index from the SHOW CREATE TABLE xxx\G output (where xxx 
is the name of your table). With MySQL, "KEY" is a synonym for "INDEX".

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine


Reply via email to