如何从MySQL表中删除唯一性约束?

时间:2011-04-05 15:31:05

标签: mysql

我通过以下方式在MySQL数据库中创建了一个表:

CREATE TABLE `newsubscriptions_orderspecification` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `display_name` varchar(256) NOT NULL,
    `sub_def_id` integer UNSIGNED NOT NULL,
    `source_code_id` integer UNSIGNED NOT NULL,
    `order_code_id` integer UNSIGNED NOT NULL,
    `rate` numeric(5, 2) NOT NULL,
    `type` varchar(4) NOT NULL,
    `region` varchar(4) NOT NULL,
    `term` varchar(4) NOT NULL,
    `buyer_type` varchar(4) NOT NULL,
    `is_active` bool NOT NULL,
    UNIQUE (`sub_def_id`, `buyer_type`, `rate`, `is_active`)
)
;

如何删除唯一性约束?

1 个答案:

答案 0 :(得分:12)

使用它:

ALTER TABLE  `newsubscriptions_orderspecification` DROP INDEX  `sub_def_id`