Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove a uniqueness constraint from a MySQL table?

Tags:

mysql

I created a table in a MySQL database via the following:

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`)
)
;

How can I remove the uniqueness constraint?

like image 608
mipadi Avatar asked Apr 05 '11 15:04

mipadi


People also ask

How do I change the unique key in MySQL?

Sometimes we want to add a unique key to the column of an existing table; then, this statement is used to add the unique key for that column. Following are the syntax of the ALTER TABLE statement to add a unique key: ALTER TABLE table_name ADD CONSTRAINT constraint_name UNIQUE(column_list);

Can we remove foreign key constraint in MySQL?

You can drop a foreign key constraint using the following ALTER TABLE syntax: ALTER TABLE tbl_name DROP FOREIGN KEY fk_symbol; If the FOREIGN KEY clause defined a CONSTRAINT name when you created the constraint, you can refer to that name to drop the foreign key constraint.

How do you change a unique constraint?

To modify a unique constraintIn the Object Explorer, right-click the table containing the unique constraint and select Design. On the Table Designer menu, click Indexes/Keys.... In the Indexes/Keys dialog box, under Selected Primary/Unique Key or Index, select the constraint you wish to edit.


1 Answers

use this:

ALTER TABLE  `newsubscriptions_orderspecification` DROP INDEX  `sub_def_id`
like image 166
Nanne Avatar answered Sep 20 '22 11:09

Nanne