如何删除MySQL中的唯一值?

发布于 2024-08-07 04:51:29 字数 299 浏览 15 评论 0原文

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

我想将唯一密钥放在电子邮件上,如何操作?

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

I want to drop the unique key on email,how?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

浅唱ヾ落雨殇 2024-08-14 04:51:29

只需使用以下 SQL 脚本即可删除 MySQL 中的索引:

alter table fuinfo drop index email;

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

alter table fuinfo drop index email;
枯寂 2024-08-14 04:51:29

有一种更好的方法不需要您更改表:

mysql> DROP INDEX email ON fuinfo;

其中电子邮件是唯一键(索引)的名称。

您也可以像这样将其返回:

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

其中 IDEX 后面的电子邮件是索引的名称,并且它不是可选的。您可以使用 KEY 代替 INDEX。

还可以创建(删除)多列唯一的不确定性,如下所示:

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

如果您没有指定多列索引的名称,则可以像这样删除它:

mysql> DROP INDEX email ON fuinfo;

其中电子邮件是列名称。

There is a better way which don't need you to alter the table:

mysql> DROP INDEX email ON fuinfo;

where email is the name of unique key (index).

You can also bring it back like that:

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

where email after IDEX is the name of the index and it's not optional. You can use KEY instead of INDEX.

Also it's possible to create (remove) multicolumn unique indecies like that:

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

If you didn't specify the name of multicolumn index you can remove it like that:

mysql> DROP INDEX email ON fuinfo;

where email is the column name.

谎言月老 2024-08-14 04:51:29

mysql>在 fuinfo 上删除索引电子邮件;

其中 email 是唯一键(而不是列名称)。您可以在此处看到唯一键的名称

mysql> SHOW CREATE TABLE fuinfo;

,例如,可以是 email_2,找到唯一键的名称。所以...

mysql> DROP INDEX email_2 ON fuinfo;

mysql> DESCRIBE fuinfo;

这应该表明索引已被删除

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

夢归不見 2024-08-14 04:51:29

使用下面的查询:

ALTER TABLE `table_name` DROP INDEX key_name;

如果您不知道 key_name 那么首先尝试下面的查询,您可以获得 key_name。

SHOW CREATE TABLE table_name

或者

SHOW INDEX FROM table_name;

如果您想从 mysql 表中删除/删除主键,请使用以下查询

ALTER TABLE `products` DROP INDEX `PRIMARY`;

获取该代码: http://chandreshrana.blogspot.in/2015/10/how-to-remove-unique-key-from-mysql.html

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

时光与爱终年不遇 2024-08-14 04:51:29

DROP INDEX column_name ON table_name

从 sql 选项卡中选择数据库和查询。这将删除特定列的索引。它在 PHP MyADMIN 中对我有用

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

仲春光 2024-08-14 04:51:29

这可能会帮助其他人

alter table fuinfo drop index fuinfo_email_unique

This may help others

alter table fuinfo drop index fuinfo_email_unique
把昨日还给我 2024-08-14 04:51:29

对于 MySQL 5.7.11

第 1 步:首先获取唯一键

使用此查询获取它:

1.1) SHOW CREATE TABLE User;

最后,它会是这样的:

.....

.....

UNIQUE KEY UK_8bv559q1gobqoulqpitq0gvr6 (phoneNum)

.....

....

步骤-2:通过此查询删除唯一键。

更改表用户删除索引 UK_8bv559q1gobqoulqpitq0gvr6;

步骤3:查看表信息,通过查询:

DESC User;

这应该表明索引已被删除,

仅此而已。

For MySQL 5.7.11

Step-1: First get the Unique Key

Use this query to get it:

1.1) SHOW CREATE TABLE User;

In the last, it will be like this:

.....

.....

UNIQUE KEY UK_8bv559q1gobqoulqpitq0gvr6 (phoneNum)

.....

....

Step-2: Remove the Unique key by this query.

ALTER TABLE User DROP INDEX UK_8bv559q1gobqoulqpitq0gvr6;

Step-3: Check the table info, by this query:

DESC User;

This should show that the index is removed

Thats All.

微暖i 2024-08-14 04:51:29
ALTER TABLE 0_value_addition_setup  DROP  INDEX   value_code
ALTER TABLE 0_value_addition_setup  DROP  INDEX   value_code
阳光的暖冬 2024-08-14 04:51:29

尝试删除列的唯一性:

ALTER TABLE  `0_ms_labdip_details` DROP INDEX column_tcx

在 phpmyadmin 中运行此代码并删除列的唯一性

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

公布 2024-08-14 04:51:29
 ALTER TABLE [table name] DROP KEY [key name];

这会起作用。

 ALTER TABLE [table name] DROP KEY [key name];

this will work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文