【发布时间】:2012-12-01 11:45:00
【问题描述】:
我得到了下表:
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 列是unique。现在我想放弃这种唯一性,因为我需要在 unsub_date + store_id 上有一个唯一索引。
我在网上找到了建议,但失败了:
ALTER TABLE `unsub_counts` DROP CONSTRAINT `unsub_date`
给我:你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“CONSTRAINT unsub_date”附近使用正确的语法
这与 MyISAM 有关吗?还有其他建议吗?
【问题讨论】:
-
我不使用 MySQL,但看起来你没有为一个约束名传递一个约束名,而是一个列名。
-
FWIW 我在 Google 上搜索并发现 codeghar.wordpress.com/2008/03/28/… 建议删除伴随索引
标签: mysql unique-constraint sql-drop