Dropping Unique constraint from MySQL table
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
How can I drop the "Unique Key Constraint" on a column of a MySQL table using phpMyAdmin?
mysql
add a comment |
How can I drop the "Unique Key Constraint" on a column of a MySQL table using phpMyAdmin?
mysql
Look at forums.mysql.com/read.php?98,70887,70974#msg-70974
– James Black
Aug 15 '10 at 14:13
add a comment |
How can I drop the "Unique Key Constraint" on a column of a MySQL table using phpMyAdmin?
mysql
How can I drop the "Unique Key Constraint" on a column of a MySQL table using phpMyAdmin?
mysql
mysql
edited Mar 18 '13 at 20:17
Peter O.
21k96069
21k96069
asked Aug 15 '10 at 14:07
Ankur MukherjeeAnkur Mukherjee
1,62442234
1,62442234
Look at forums.mysql.com/read.php?98,70887,70974#msg-70974
– James Black
Aug 15 '10 at 14:13
add a comment |
Look at forums.mysql.com/read.php?98,70887,70974#msg-70974
– James Black
Aug 15 '10 at 14:13
Look at forums.mysql.com/read.php?98,70887,70974#msg-70974
– James Black
Aug 15 '10 at 14:13
Look at forums.mysql.com/read.php?98,70887,70974#msg-70974
– James Black
Aug 15 '10 at 14:13
add a comment |
9 Answers
9
active
oldest
votes
A unique constraint is also an index.
First use SHOW INDEX FROM tbl_name to find out the name of the index. The name of the index is stored in the column called key_name in the results of that query.
Then you can use DROP INDEX:
DROP INDEX index_name ON tbl_name
or the ALTER TABLE syntax:
ALTER TABLE tbl_name DROP INDEX index_name
1
Sorry sir i had tried it before raising the question ,but its not working
– Ankur Mukherjee
Aug 15 '10 at 14:26
@Ankur Mukherjee: I forgot to mention: You have to change tbl_name and index_name to the name of your actual table and the name of the actual index, respectively. You can see the names in MySQL Query Browser. You can also doSHOW CREATE TABLE tbl_name.
– Mark Byers
Aug 15 '10 at 14:33
1
Sir I know that very well and i had tried that only
– Ankur Mukherjee
Aug 15 '10 at 14:34
1
@Ankur Mukherjee: The way I have suggested is in my opinion the best way to do it.
– Mark Byers
Aug 15 '10 at 15:33
1
I read somewhere in the question using phpMyAdmin... The answer provided by @systemovich should be marked as the accepted one.
– Pere
Sep 16 '14 at 14:16
|
show 9 more comments
You can DROP a unique constraint from a table using phpMyAdmin as requested as shown in the table below. A unique constraint has been placed on the Wingspan field. The name of the constraint is the same as the field name, in this instance.

34
It is important to note that the indexes section is collapsed by default, and is expanded by a small, subtle link in 12px font where the section is in the screenshot. But thanks to you, I found it. Bless your face. +1
– Jack
May 25 '13 at 17:39
I just removed 25 indexes...
– CousinCocaine
Sep 29 '15 at 19:46
add a comment |
The indexes capable of placing a unique key constraint on a table are PRIMARY and UNIQUE indexes.
To remove the unique key constraint on a column but keep the index, you could remove and recreate the index with type INDEX.
Note that it is a good idea for all tables to have an index marked PRIMARY.
1
Upvoted because @thomasrutter has touched on the fact that removing a unique constraint may adversely affect query performance - and this can be mitigated by replacing theUNIQUEindex with a regularINDEX.
– Alex
Apr 18 '14 at 16:17
add a comment |
For WAMP 3.0 :
Click Structure
Below Add 1 Column you will see '- Indexes'
Click -Indexes and drop whichever index you want.
add a comment |
If you want to remove unique constraints from mysql database table, use alter table with drop index.
Example:
create table unique_constraints(unid int,activity_name varchar(100),CONSTRAINT activty_uqniue UNIQUE(activity_name),primary key (unid));
alter table unique_constraints drop index activty_uqniue;
Where activty_uqniue is UNIQUE constraint for activity_name column.
add a comment |
To add UNIQUE constraint using phpmyadmin, go to the structure of that table and find below and click that,

To remove the UNIQUE constraint, same way, go to the structure and scroll down till Indexes Tab and find below and click drop,

Hope this works.
Enjoy ;)
this solution was exactly what i was looking for.
– Aryeh Beitz
Dec 30 '18 at 12:29
add a comment |
while dropping unique key we use index
ALTER TABLE tbl
DROP INDEX unique_address;
add a comment |
1.First delete table
2.go to sql
CREATE TABLE service( --tablename
`serviceid` int(11) NOT NULL,--coloums
`customerid` varchar(20) DEFAULT NULL,--coloums
`dos` varchar(30) NOT NULL,--coloums
`productname` varchar(150) NOT NULL,--coloums
`modelnumber` bigint(12) NOT NULL,--coloums
`serialnumber` bigint(20) NOT NULL,--coloums
`serviceby` varchar(20) DEFAULT NULL--coloums
)
--INSERT VALUES
INSERT INTO `service` (`serviceid`, `customerid`, `dos`, `productname`, `modelnumber`, `serialnumber`, `serviceby`) VALUES
(1, '1', '12/10/2018', 'mouse', 1234555, 234234324, '9999'),
(2, '09', '12/10/2018', 'vhbgj', 79746385, 18923984, '9999'),
(3, '23', '12/10/2018', 'mouse', 123455534, 11111123, '9999'),
(4, '23', '12/10/2018', 'mouse', 12345, 84848, '9999'),
(5, '546456', '12/10/2018', 'ughg', 772882, 457283, '9999'),
(6, '23', '12/10/2018', 'keyboard', 7878787878, 22222, '1'),
(7, '23', '12/10/2018', 'java', 11, 98908, '9999'),
(8, '128', '12/10/2018', 'mouse', 9912280626, 111111, '9999'),
(9, '23', '15/10/2018', 'hg', 29829354, 4564564646, '9999'),
(10, '12', '15/10/2018', '2', 5256, 888888, '9999');
--before droping table
ALTER TABLE `service`
ADD PRIMARY KEY (`serviceid`),
ADD unique`modelnumber` (`modelnumber`),
ADD unique`serialnumber` (`serialnumber`),
ADD unique`modelnumber_2` (`modelnumber`);
--after droping table
ALTER TABLE `service`
ADD PRIMARY KEY (`serviceid`),
ADD modelnumber` (`modelnumber`),
ADD serialnumber` (`serialnumber`),
ADD modelnumber_2` (`modelnumber`);
add a comment |
my table name is buyers which has a unique constraint column emp_id now iam going to drop the emp_id
step 1: exec sp_helpindex buyers, see the image file
step 2: copy the index address

step3: alter table buyers drop constraint [UQ__buyers__1299A860D9793F2E]
alter table buyers
drop column emp_id
note:
Blockquote
instead of buyers change it to your table name :)
Blockquote
thats all column name emp_id with constraints is dropped!
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f3487691%2fdropping-unique-constraint-from-mysql-table%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
9 Answers
9
active
oldest
votes
9 Answers
9
active
oldest
votes
active
oldest
votes
active
oldest
votes
A unique constraint is also an index.
First use SHOW INDEX FROM tbl_name to find out the name of the index. The name of the index is stored in the column called key_name in the results of that query.
Then you can use DROP INDEX:
DROP INDEX index_name ON tbl_name
or the ALTER TABLE syntax:
ALTER TABLE tbl_name DROP INDEX index_name
1
Sorry sir i had tried it before raising the question ,but its not working
– Ankur Mukherjee
Aug 15 '10 at 14:26
@Ankur Mukherjee: I forgot to mention: You have to change tbl_name and index_name to the name of your actual table and the name of the actual index, respectively. You can see the names in MySQL Query Browser. You can also doSHOW CREATE TABLE tbl_name.
– Mark Byers
Aug 15 '10 at 14:33
1
Sir I know that very well and i had tried that only
– Ankur Mukherjee
Aug 15 '10 at 14:34
1
@Ankur Mukherjee: The way I have suggested is in my opinion the best way to do it.
– Mark Byers
Aug 15 '10 at 15:33
1
I read somewhere in the question using phpMyAdmin... The answer provided by @systemovich should be marked as the accepted one.
– Pere
Sep 16 '14 at 14:16
|
show 9 more comments
A unique constraint is also an index.
First use SHOW INDEX FROM tbl_name to find out the name of the index. The name of the index is stored in the column called key_name in the results of that query.
Then you can use DROP INDEX:
DROP INDEX index_name ON tbl_name
or the ALTER TABLE syntax:
ALTER TABLE tbl_name DROP INDEX index_name
1
Sorry sir i had tried it before raising the question ,but its not working
– Ankur Mukherjee
Aug 15 '10 at 14:26
@Ankur Mukherjee: I forgot to mention: You have to change tbl_name and index_name to the name of your actual table and the name of the actual index, respectively. You can see the names in MySQL Query Browser. You can also doSHOW CREATE TABLE tbl_name.
– Mark Byers
Aug 15 '10 at 14:33
1
Sir I know that very well and i had tried that only
– Ankur Mukherjee
Aug 15 '10 at 14:34
1
@Ankur Mukherjee: The way I have suggested is in my opinion the best way to do it.
– Mark Byers
Aug 15 '10 at 15:33
1
I read somewhere in the question using phpMyAdmin... The answer provided by @systemovich should be marked as the accepted one.
– Pere
Sep 16 '14 at 14:16
|
show 9 more comments
A unique constraint is also an index.
First use SHOW INDEX FROM tbl_name to find out the name of the index. The name of the index is stored in the column called key_name in the results of that query.
Then you can use DROP INDEX:
DROP INDEX index_name ON tbl_name
or the ALTER TABLE syntax:
ALTER TABLE tbl_name DROP INDEX index_name
A unique constraint is also an index.
First use SHOW INDEX FROM tbl_name to find out the name of the index. The name of the index is stored in the column called key_name in the results of that query.
Then you can use DROP INDEX:
DROP INDEX index_name ON tbl_name
or the ALTER TABLE syntax:
ALTER TABLE tbl_name DROP INDEX index_name
edited Aug 15 '10 at 15:05
answered Aug 15 '10 at 14:15
Mark ByersMark Byers
600k12913711349
600k12913711349
1
Sorry sir i had tried it before raising the question ,but its not working
– Ankur Mukherjee
Aug 15 '10 at 14:26
@Ankur Mukherjee: I forgot to mention: You have to change tbl_name and index_name to the name of your actual table and the name of the actual index, respectively. You can see the names in MySQL Query Browser. You can also doSHOW CREATE TABLE tbl_name.
– Mark Byers
Aug 15 '10 at 14:33
1
Sir I know that very well and i had tried that only
– Ankur Mukherjee
Aug 15 '10 at 14:34
1
@Ankur Mukherjee: The way I have suggested is in my opinion the best way to do it.
– Mark Byers
Aug 15 '10 at 15:33
1
I read somewhere in the question using phpMyAdmin... The answer provided by @systemovich should be marked as the accepted one.
– Pere
Sep 16 '14 at 14:16
|
show 9 more comments
1
Sorry sir i had tried it before raising the question ,but its not working
– Ankur Mukherjee
Aug 15 '10 at 14:26
@Ankur Mukherjee: I forgot to mention: You have to change tbl_name and index_name to the name of your actual table and the name of the actual index, respectively. You can see the names in MySQL Query Browser. You can also doSHOW CREATE TABLE tbl_name.
– Mark Byers
Aug 15 '10 at 14:33
1
Sir I know that very well and i had tried that only
– Ankur Mukherjee
Aug 15 '10 at 14:34
1
@Ankur Mukherjee: The way I have suggested is in my opinion the best way to do it.
– Mark Byers
Aug 15 '10 at 15:33
1
I read somewhere in the question using phpMyAdmin... The answer provided by @systemovich should be marked as the accepted one.
– Pere
Sep 16 '14 at 14:16
1
1
Sorry sir i had tried it before raising the question ,but its not working
– Ankur Mukherjee
Aug 15 '10 at 14:26
Sorry sir i had tried it before raising the question ,but its not working
– Ankur Mukherjee
Aug 15 '10 at 14:26
@Ankur Mukherjee: I forgot to mention: You have to change tbl_name and index_name to the name of your actual table and the name of the actual index, respectively. You can see the names in MySQL Query Browser. You can also do
SHOW CREATE TABLE tbl_name.– Mark Byers
Aug 15 '10 at 14:33
@Ankur Mukherjee: I forgot to mention: You have to change tbl_name and index_name to the name of your actual table and the name of the actual index, respectively. You can see the names in MySQL Query Browser. You can also do
SHOW CREATE TABLE tbl_name.– Mark Byers
Aug 15 '10 at 14:33
1
1
Sir I know that very well and i had tried that only
– Ankur Mukherjee
Aug 15 '10 at 14:34
Sir I know that very well and i had tried that only
– Ankur Mukherjee
Aug 15 '10 at 14:34
1
1
@Ankur Mukherjee: The way I have suggested is in my opinion the best way to do it.
– Mark Byers
Aug 15 '10 at 15:33
@Ankur Mukherjee: The way I have suggested is in my opinion the best way to do it.
– Mark Byers
Aug 15 '10 at 15:33
1
1
I read somewhere in the question using phpMyAdmin... The answer provided by @systemovich should be marked as the accepted one.
– Pere
Sep 16 '14 at 14:16
I read somewhere in the question using phpMyAdmin... The answer provided by @systemovich should be marked as the accepted one.
– Pere
Sep 16 '14 at 14:16
|
show 9 more comments
You can DROP a unique constraint from a table using phpMyAdmin as requested as shown in the table below. A unique constraint has been placed on the Wingspan field. The name of the constraint is the same as the field name, in this instance.

34
It is important to note that the indexes section is collapsed by default, and is expanded by a small, subtle link in 12px font where the section is in the screenshot. But thanks to you, I found it. Bless your face. +1
– Jack
May 25 '13 at 17:39
I just removed 25 indexes...
– CousinCocaine
Sep 29 '15 at 19:46
add a comment |
You can DROP a unique constraint from a table using phpMyAdmin as requested as shown in the table below. A unique constraint has been placed on the Wingspan field. The name of the constraint is the same as the field name, in this instance.

34
It is important to note that the indexes section is collapsed by default, and is expanded by a small, subtle link in 12px font where the section is in the screenshot. But thanks to you, I found it. Bless your face. +1
– Jack
May 25 '13 at 17:39
I just removed 25 indexes...
– CousinCocaine
Sep 29 '15 at 19:46
add a comment |
You can DROP a unique constraint from a table using phpMyAdmin as requested as shown in the table below. A unique constraint has been placed on the Wingspan field. The name of the constraint is the same as the field name, in this instance.

You can DROP a unique constraint from a table using phpMyAdmin as requested as shown in the table below. A unique constraint has been placed on the Wingspan field. The name of the constraint is the same as the field name, in this instance.

answered Oct 6 '10 at 17:42
systemovichsystemovich
3,98573570
3,98573570
34
It is important to note that the indexes section is collapsed by default, and is expanded by a small, subtle link in 12px font where the section is in the screenshot. But thanks to you, I found it. Bless your face. +1
– Jack
May 25 '13 at 17:39
I just removed 25 indexes...
– CousinCocaine
Sep 29 '15 at 19:46
add a comment |
34
It is important to note that the indexes section is collapsed by default, and is expanded by a small, subtle link in 12px font where the section is in the screenshot. But thanks to you, I found it. Bless your face. +1
– Jack
May 25 '13 at 17:39
I just removed 25 indexes...
– CousinCocaine
Sep 29 '15 at 19:46
34
34
It is important to note that the indexes section is collapsed by default, and is expanded by a small, subtle link in 12px font where the section is in the screenshot. But thanks to you, I found it. Bless your face. +1
– Jack
May 25 '13 at 17:39
It is important to note that the indexes section is collapsed by default, and is expanded by a small, subtle link in 12px font where the section is in the screenshot. But thanks to you, I found it. Bless your face. +1
– Jack
May 25 '13 at 17:39
I just removed 25 indexes...
– CousinCocaine
Sep 29 '15 at 19:46
I just removed 25 indexes...
– CousinCocaine
Sep 29 '15 at 19:46
add a comment |
The indexes capable of placing a unique key constraint on a table are PRIMARY and UNIQUE indexes.
To remove the unique key constraint on a column but keep the index, you could remove and recreate the index with type INDEX.
Note that it is a good idea for all tables to have an index marked PRIMARY.
1
Upvoted because @thomasrutter has touched on the fact that removing a unique constraint may adversely affect query performance - and this can be mitigated by replacing theUNIQUEindex with a regularINDEX.
– Alex
Apr 18 '14 at 16:17
add a comment |
The indexes capable of placing a unique key constraint on a table are PRIMARY and UNIQUE indexes.
To remove the unique key constraint on a column but keep the index, you could remove and recreate the index with type INDEX.
Note that it is a good idea for all tables to have an index marked PRIMARY.
1
Upvoted because @thomasrutter has touched on the fact that removing a unique constraint may adversely affect query performance - and this can be mitigated by replacing theUNIQUEindex with a regularINDEX.
– Alex
Apr 18 '14 at 16:17
add a comment |
The indexes capable of placing a unique key constraint on a table are PRIMARY and UNIQUE indexes.
To remove the unique key constraint on a column but keep the index, you could remove and recreate the index with type INDEX.
Note that it is a good idea for all tables to have an index marked PRIMARY.
The indexes capable of placing a unique key constraint on a table are PRIMARY and UNIQUE indexes.
To remove the unique key constraint on a column but keep the index, you could remove and recreate the index with type INDEX.
Note that it is a good idea for all tables to have an index marked PRIMARY.
answered Aug 15 '10 at 14:28
thomasrutterthomasrutter
90.8k21125148
90.8k21125148
1
Upvoted because @thomasrutter has touched on the fact that removing a unique constraint may adversely affect query performance - and this can be mitigated by replacing theUNIQUEindex with a regularINDEX.
– Alex
Apr 18 '14 at 16:17
add a comment |
1
Upvoted because @thomasrutter has touched on the fact that removing a unique constraint may adversely affect query performance - and this can be mitigated by replacing theUNIQUEindex with a regularINDEX.
– Alex
Apr 18 '14 at 16:17
1
1
Upvoted because @thomasrutter has touched on the fact that removing a unique constraint may adversely affect query performance - and this can be mitigated by replacing the
UNIQUE index with a regular INDEX.– Alex
Apr 18 '14 at 16:17
Upvoted because @thomasrutter has touched on the fact that removing a unique constraint may adversely affect query performance - and this can be mitigated by replacing the
UNIQUE index with a regular INDEX.– Alex
Apr 18 '14 at 16:17
add a comment |
For WAMP 3.0 :
Click Structure
Below Add 1 Column you will see '- Indexes'
Click -Indexes and drop whichever index you want.
add a comment |
For WAMP 3.0 :
Click Structure
Below Add 1 Column you will see '- Indexes'
Click -Indexes and drop whichever index you want.
add a comment |
For WAMP 3.0 :
Click Structure
Below Add 1 Column you will see '- Indexes'
Click -Indexes and drop whichever index you want.
For WAMP 3.0 :
Click Structure
Below Add 1 Column you will see '- Indexes'
Click -Indexes and drop whichever index you want.
answered Sep 2 '17 at 19:39
Jeffry LouisJeffry Louis
111
111
add a comment |
add a comment |
If you want to remove unique constraints from mysql database table, use alter table with drop index.
Example:
create table unique_constraints(unid int,activity_name varchar(100),CONSTRAINT activty_uqniue UNIQUE(activity_name),primary key (unid));
alter table unique_constraints drop index activty_uqniue;
Where activty_uqniue is UNIQUE constraint for activity_name column.
add a comment |
If you want to remove unique constraints from mysql database table, use alter table with drop index.
Example:
create table unique_constraints(unid int,activity_name varchar(100),CONSTRAINT activty_uqniue UNIQUE(activity_name),primary key (unid));
alter table unique_constraints drop index activty_uqniue;
Where activty_uqniue is UNIQUE constraint for activity_name column.
add a comment |
If you want to remove unique constraints from mysql database table, use alter table with drop index.
Example:
create table unique_constraints(unid int,activity_name varchar(100),CONSTRAINT activty_uqniue UNIQUE(activity_name),primary key (unid));
alter table unique_constraints drop index activty_uqniue;
Where activty_uqniue is UNIQUE constraint for activity_name column.
If you want to remove unique constraints from mysql database table, use alter table with drop index.
Example:
create table unique_constraints(unid int,activity_name varchar(100),CONSTRAINT activty_uqniue UNIQUE(activity_name),primary key (unid));
alter table unique_constraints drop index activty_uqniue;
Where activty_uqniue is UNIQUE constraint for activity_name column.
answered Feb 2 '18 at 11:23
Manjunatha H CManjunatha H C
112
112
add a comment |
add a comment |
To add UNIQUE constraint using phpmyadmin, go to the structure of that table and find below and click that,

To remove the UNIQUE constraint, same way, go to the structure and scroll down till Indexes Tab and find below and click drop,

Hope this works.
Enjoy ;)
this solution was exactly what i was looking for.
– Aryeh Beitz
Dec 30 '18 at 12:29
add a comment |
To add UNIQUE constraint using phpmyadmin, go to the structure of that table and find below and click that,

To remove the UNIQUE constraint, same way, go to the structure and scroll down till Indexes Tab and find below and click drop,

Hope this works.
Enjoy ;)
this solution was exactly what i was looking for.
– Aryeh Beitz
Dec 30 '18 at 12:29
add a comment |
To add UNIQUE constraint using phpmyadmin, go to the structure of that table and find below and click that,

To remove the UNIQUE constraint, same way, go to the structure and scroll down till Indexes Tab and find below and click drop,

Hope this works.
Enjoy ;)
To add UNIQUE constraint using phpmyadmin, go to the structure of that table and find below and click that,

To remove the UNIQUE constraint, same way, go to the structure and scroll down till Indexes Tab and find below and click drop,

Hope this works.
Enjoy ;)
answered Aug 30 '18 at 8:19
Umesh PatilUmesh Patil
2,2021918
2,2021918
this solution was exactly what i was looking for.
– Aryeh Beitz
Dec 30 '18 at 12:29
add a comment |
this solution was exactly what i was looking for.
– Aryeh Beitz
Dec 30 '18 at 12:29
this solution was exactly what i was looking for.
– Aryeh Beitz
Dec 30 '18 at 12:29
this solution was exactly what i was looking for.
– Aryeh Beitz
Dec 30 '18 at 12:29
add a comment |
while dropping unique key we use index
ALTER TABLE tbl
DROP INDEX unique_address;
add a comment |
while dropping unique key we use index
ALTER TABLE tbl
DROP INDEX unique_address;
add a comment |
while dropping unique key we use index
ALTER TABLE tbl
DROP INDEX unique_address;
while dropping unique key we use index
ALTER TABLE tbl
DROP INDEX unique_address;
answered Feb 21 at 10:39
Hamza.SHamza.S
855314
855314
add a comment |
add a comment |
1.First delete table
2.go to sql
CREATE TABLE service( --tablename
`serviceid` int(11) NOT NULL,--coloums
`customerid` varchar(20) DEFAULT NULL,--coloums
`dos` varchar(30) NOT NULL,--coloums
`productname` varchar(150) NOT NULL,--coloums
`modelnumber` bigint(12) NOT NULL,--coloums
`serialnumber` bigint(20) NOT NULL,--coloums
`serviceby` varchar(20) DEFAULT NULL--coloums
)
--INSERT VALUES
INSERT INTO `service` (`serviceid`, `customerid`, `dos`, `productname`, `modelnumber`, `serialnumber`, `serviceby`) VALUES
(1, '1', '12/10/2018', 'mouse', 1234555, 234234324, '9999'),
(2, '09', '12/10/2018', 'vhbgj', 79746385, 18923984, '9999'),
(3, '23', '12/10/2018', 'mouse', 123455534, 11111123, '9999'),
(4, '23', '12/10/2018', 'mouse', 12345, 84848, '9999'),
(5, '546456', '12/10/2018', 'ughg', 772882, 457283, '9999'),
(6, '23', '12/10/2018', 'keyboard', 7878787878, 22222, '1'),
(7, '23', '12/10/2018', 'java', 11, 98908, '9999'),
(8, '128', '12/10/2018', 'mouse', 9912280626, 111111, '9999'),
(9, '23', '15/10/2018', 'hg', 29829354, 4564564646, '9999'),
(10, '12', '15/10/2018', '2', 5256, 888888, '9999');
--before droping table
ALTER TABLE `service`
ADD PRIMARY KEY (`serviceid`),
ADD unique`modelnumber` (`modelnumber`),
ADD unique`serialnumber` (`serialnumber`),
ADD unique`modelnumber_2` (`modelnumber`);
--after droping table
ALTER TABLE `service`
ADD PRIMARY KEY (`serviceid`),
ADD modelnumber` (`modelnumber`),
ADD serialnumber` (`serialnumber`),
ADD modelnumber_2` (`modelnumber`);
add a comment |
1.First delete table
2.go to sql
CREATE TABLE service( --tablename
`serviceid` int(11) NOT NULL,--coloums
`customerid` varchar(20) DEFAULT NULL,--coloums
`dos` varchar(30) NOT NULL,--coloums
`productname` varchar(150) NOT NULL,--coloums
`modelnumber` bigint(12) NOT NULL,--coloums
`serialnumber` bigint(20) NOT NULL,--coloums
`serviceby` varchar(20) DEFAULT NULL--coloums
)
--INSERT VALUES
INSERT INTO `service` (`serviceid`, `customerid`, `dos`, `productname`, `modelnumber`, `serialnumber`, `serviceby`) VALUES
(1, '1', '12/10/2018', 'mouse', 1234555, 234234324, '9999'),
(2, '09', '12/10/2018', 'vhbgj', 79746385, 18923984, '9999'),
(3, '23', '12/10/2018', 'mouse', 123455534, 11111123, '9999'),
(4, '23', '12/10/2018', 'mouse', 12345, 84848, '9999'),
(5, '546456', '12/10/2018', 'ughg', 772882, 457283, '9999'),
(6, '23', '12/10/2018', 'keyboard', 7878787878, 22222, '1'),
(7, '23', '12/10/2018', 'java', 11, 98908, '9999'),
(8, '128', '12/10/2018', 'mouse', 9912280626, 111111, '9999'),
(9, '23', '15/10/2018', 'hg', 29829354, 4564564646, '9999'),
(10, '12', '15/10/2018', '2', 5256, 888888, '9999');
--before droping table
ALTER TABLE `service`
ADD PRIMARY KEY (`serviceid`),
ADD unique`modelnumber` (`modelnumber`),
ADD unique`serialnumber` (`serialnumber`),
ADD unique`modelnumber_2` (`modelnumber`);
--after droping table
ALTER TABLE `service`
ADD PRIMARY KEY (`serviceid`),
ADD modelnumber` (`modelnumber`),
ADD serialnumber` (`serialnumber`),
ADD modelnumber_2` (`modelnumber`);
add a comment |
1.First delete table
2.go to sql
CREATE TABLE service( --tablename
`serviceid` int(11) NOT NULL,--coloums
`customerid` varchar(20) DEFAULT NULL,--coloums
`dos` varchar(30) NOT NULL,--coloums
`productname` varchar(150) NOT NULL,--coloums
`modelnumber` bigint(12) NOT NULL,--coloums
`serialnumber` bigint(20) NOT NULL,--coloums
`serviceby` varchar(20) DEFAULT NULL--coloums
)
--INSERT VALUES
INSERT INTO `service` (`serviceid`, `customerid`, `dos`, `productname`, `modelnumber`, `serialnumber`, `serviceby`) VALUES
(1, '1', '12/10/2018', 'mouse', 1234555, 234234324, '9999'),
(2, '09', '12/10/2018', 'vhbgj', 79746385, 18923984, '9999'),
(3, '23', '12/10/2018', 'mouse', 123455534, 11111123, '9999'),
(4, '23', '12/10/2018', 'mouse', 12345, 84848, '9999'),
(5, '546456', '12/10/2018', 'ughg', 772882, 457283, '9999'),
(6, '23', '12/10/2018', 'keyboard', 7878787878, 22222, '1'),
(7, '23', '12/10/2018', 'java', 11, 98908, '9999'),
(8, '128', '12/10/2018', 'mouse', 9912280626, 111111, '9999'),
(9, '23', '15/10/2018', 'hg', 29829354, 4564564646, '9999'),
(10, '12', '15/10/2018', '2', 5256, 888888, '9999');
--before droping table
ALTER TABLE `service`
ADD PRIMARY KEY (`serviceid`),
ADD unique`modelnumber` (`modelnumber`),
ADD unique`serialnumber` (`serialnumber`),
ADD unique`modelnumber_2` (`modelnumber`);
--after droping table
ALTER TABLE `service`
ADD PRIMARY KEY (`serviceid`),
ADD modelnumber` (`modelnumber`),
ADD serialnumber` (`serialnumber`),
ADD modelnumber_2` (`modelnumber`);
1.First delete table
2.go to sql
CREATE TABLE service( --tablename
`serviceid` int(11) NOT NULL,--coloums
`customerid` varchar(20) DEFAULT NULL,--coloums
`dos` varchar(30) NOT NULL,--coloums
`productname` varchar(150) NOT NULL,--coloums
`modelnumber` bigint(12) NOT NULL,--coloums
`serialnumber` bigint(20) NOT NULL,--coloums
`serviceby` varchar(20) DEFAULT NULL--coloums
)
--INSERT VALUES
INSERT INTO `service` (`serviceid`, `customerid`, `dos`, `productname`, `modelnumber`, `serialnumber`, `serviceby`) VALUES
(1, '1', '12/10/2018', 'mouse', 1234555, 234234324, '9999'),
(2, '09', '12/10/2018', 'vhbgj', 79746385, 18923984, '9999'),
(3, '23', '12/10/2018', 'mouse', 123455534, 11111123, '9999'),
(4, '23', '12/10/2018', 'mouse', 12345, 84848, '9999'),
(5, '546456', '12/10/2018', 'ughg', 772882, 457283, '9999'),
(6, '23', '12/10/2018', 'keyboard', 7878787878, 22222, '1'),
(7, '23', '12/10/2018', 'java', 11, 98908, '9999'),
(8, '128', '12/10/2018', 'mouse', 9912280626, 111111, '9999'),
(9, '23', '15/10/2018', 'hg', 29829354, 4564564646, '9999'),
(10, '12', '15/10/2018', '2', 5256, 888888, '9999');
--before droping table
ALTER TABLE `service`
ADD PRIMARY KEY (`serviceid`),
ADD unique`modelnumber` (`modelnumber`),
ADD unique`serialnumber` (`serialnumber`),
ADD unique`modelnumber_2` (`modelnumber`);
--after droping table
ALTER TABLE `service`
ADD PRIMARY KEY (`serviceid`),
ADD modelnumber` (`modelnumber`),
ADD serialnumber` (`serialnumber`),
ADD modelnumber_2` (`modelnumber`);
edited Oct 15 '18 at 13:14
Pancho
3,25011631
3,25011631
answered Oct 15 '18 at 12:36
ramram
1
1
add a comment |
add a comment |
my table name is buyers which has a unique constraint column emp_id now iam going to drop the emp_id
step 1: exec sp_helpindex buyers, see the image file
step 2: copy the index address

step3: alter table buyers drop constraint [UQ__buyers__1299A860D9793F2E]
alter table buyers
drop column emp_id
note:
Blockquote
instead of buyers change it to your table name :)
Blockquote
thats all column name emp_id with constraints is dropped!
add a comment |
my table name is buyers which has a unique constraint column emp_id now iam going to drop the emp_id
step 1: exec sp_helpindex buyers, see the image file
step 2: copy the index address

step3: alter table buyers drop constraint [UQ__buyers__1299A860D9793F2E]
alter table buyers
drop column emp_id
note:
Blockquote
instead of buyers change it to your table name :)
Blockquote
thats all column name emp_id with constraints is dropped!
add a comment |
my table name is buyers which has a unique constraint column emp_id now iam going to drop the emp_id
step 1: exec sp_helpindex buyers, see the image file
step 2: copy the index address

step3: alter table buyers drop constraint [UQ__buyers__1299A860D9793F2E]
alter table buyers
drop column emp_id
note:
Blockquote
instead of buyers change it to your table name :)
Blockquote
thats all column name emp_id with constraints is dropped!
my table name is buyers which has a unique constraint column emp_id now iam going to drop the emp_id
step 1: exec sp_helpindex buyers, see the image file
step 2: copy the index address

step3: alter table buyers drop constraint [UQ__buyers__1299A860D9793F2E]
alter table buyers
drop column emp_id
note:
Blockquote
instead of buyers change it to your table name :)
Blockquote
thats all column name emp_id with constraints is dropped!
edited Jan 4 at 8:08
s_t
3,69121133
3,69121133
answered Jan 4 at 7:30
vignesh .Bvignesh .B
42
42
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f3487691%2fdropping-unique-constraint-from-mysql-table%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Look at forums.mysql.com/read.php?98,70887,70974#msg-70974
– James Black
Aug 15 '10 at 14:13