gpt4 book ai didi

mysql - sql DROP CONSTRAINT UNIQUE 不起作用

转载 作者:行者123 更新时间:2023-11-29 14:10:01 24 4
gpt4 key购买 nike

我得到了下表:

CREATE TABLE `unsub_counts` (
`count_id` int(11) NOT NULL AUTO_INCREMENT,
`unsub_date` date DEFAULT NULL,
`unsub_count` int(11) DEFAULT NULL,
`store_id` smallint(5) DEFAULT NULL,
PRIMARY KEY (`count_id`),
UNIQUE KEY `uc_unsub_date` (`unsub_date`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

其中 unsub_date 列是唯一。现在我想放弃这种唯一性,因为我需要在 unsub_date + store_id 上有一个唯一索引。

我在网上找到了建议,但失败了:

ALTER TABLE `unsub_counts` DROP CONSTRAINT `unsub_date`

给我:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行“CONSTRAINT unsub_date”附近使用的正确语法

这与MyISAM有关吗?还有其他建议吗?

最佳答案

使用带有约束名称的删除索引:

ALTER TABLE unsub_counts DROP INDEX uc_unsub_date;

或者只是:

drop index uc_unsub_date on unsub_counts;

关于mysql - sql DROP CONSTRAINT UNIQUE 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13659114/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com