sql DROP CONSTRAINT UNIQUE不起作用 [英] sql DROP CONSTRAINT UNIQUE not working
本文介绍了sql DROP CONSTRAINT UNIQUE不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到了下表:
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
上具有唯一索引.
where column unsub_date
is unique
. Now I want to drop that uniqueness, because I need to have a unique index on unsub_date + store_id
.
我在网上找到了建议,但失败了:
I found suggestions on the net, but is failing:
ALTER TABLE `unsub_counts` DROP CONSTRAINT `unsub_date`
给我:您的SQL语法有误;检查与您的MySQL服务器版本相对应的手册以获取正确的语法,以在第1行的'CONSTRAINT unsub_date
'附近使用
gives me: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONSTRAINT unsub_date
' at line 1
这与MyISAM有关吗?还有其他建议吗?
Is this related to MyISAM? Any other suggestions?
推荐答案
对约束名称使用drop index
:
ALTER TABLE unsub_counts DROP INDEX uc_unsub_date;
或者只是:
drop index uc_unsub_date on unsub_counts;
这篇关于sql DROP CONSTRAINT UNIQUE不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文