Cómo soltar único en MySQL?


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`),
  UNIQUE KEY `fid` (`fid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8

Quiero soltar la clave única en email, ¿cómo?

Author: Midhun MP, 2009-10-14

10 answers

Simplemente puede usar el siguiente script SQL para eliminar el índice en MySQL:

alter table fuinfo drop index email;
 248
Author: Wael Dalloul,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-12-03 07:08:24

Hay una mejor manera que no necesita alterar la tabla:

mysql> DROP INDEX email ON fuinfo;

Donde email es el nombre de la clave única (índice).

También puedes traerlo de vuelta así:

mysql> CREATE UNIQUE INDEX email ON fuinfo(email);

Donde el correo electrónico después de IDEX es el nombre del índice y no es opcional. Puede usar CLAVE en lugar de ÍNDICE.

También es posible crear (eliminar) indecisas únicas multicolumnas como esa:

mysql> CREATE UNIQUE INDEX email_fid ON fuinfo(email, fid);
mysql> DROP INDEX email_fid ON fuinfo;

Si no especificó el nombre del índice multicolumn puede eliminarlo como que:

mysql> DROP INDEX email ON fuinfo;

Donde email es el nombre de la columna.

 57
Author: arty,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-10-28 10:31:26

Mysql> SOLTAR EL ÍNDICE DE correo ELECTRÓNICO EN fuinfo;

Donde email es la clave única (en lugar del nombre de la columna). El nombre de la clave única se encuentra en

mysql> SHOW CREATE TABLE fuinfo;

Aquí verá el nombre de la clave única, que podría ser email_2, por ejemplo. Tan...

mysql> DROP INDEX email_2 ON fuinfo;

mysql> DESCRIBE fuinfo;

Esto debería mostrar que el índice se elimina

 9
Author: gavin,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-08-02 13:35:26

DROP INDEX column_name ON table_name

Seleccione la base de datos y consulte la pestaña sql.Esto elimina el índice de la columna en particular. Me funcionó en PHP MyAdmin

 4
Author: Lina Gom,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-03-18 11:44:27

Utilice la siguiente consulta:

ALTER TABLE `table_name` DROP INDEX key_name;

Si no conoce el key_name, primero intente debajo de la consulta, puede obtener key_name.

SHOW CREATE TABLE table_name

O

SHOW INDEX FROM table_name;

Si desea eliminar / soltar la clave primaria de la tabla mysql, Use la siguiente consulta para eso

ALTER TABLE `products` DROP INDEX `PRIMARY`;

Código Tomado de: http://chandreshrana.blogspot.in/2015/10/how-to-remove-unique-key-from-mysql.html

 4
Author: Chandresh,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-06-06 06:19:00

Esto puede ayudar a otros

alter table fuinfo drop index fuinfo_email_unique
 2
Author: shuvrow,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-03-15 10:04:37

ALTER TABLE 0_value_addition_setup  DROP  INDEX   value_code
 1
Author: radhason power,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-10-04 10:45:06

Intente eliminar uique de una columna:

ALTER TABLE  `0_ms_labdip_details` DROP INDEX column_tcx

Ejecute este código en phpmyadmin y elimine único de la columna

 1
Author: Radhason,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-03-29 09:57:30

Para MySQL 5.7.11

Paso-1: Primero obtenga la Clave única

Use esta consulta para obtenerla:

1.1) SHOW CREATE TABLE User;

En el último, será así:

.....

.....

CLAVE ÚNICAUK_8bv559q1gobqoulqpitq0gvr6 (phoneNum)

.....

....

Paso-2: Elimine la clave única mediante esta consulta.

ALTER TABLE User DROP INDEX UK_8bv559q1gobqoulqpitq0gvr6;

Paso-3: Compruebe la información de la tabla, mediante esta consulta:

DESC Usuario;

Esto debería mostrar que el índice se elimina

Eso Es Todo.

 1
Author: ArunDhwaj IIITH,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-15 17:10:02
 ALTER TABLE [table name] DROP KEY [key name];

Esto funcionará.

 0
Author: Curtis H,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-12-28 17:19:22