1. Computing
You can remove an entire column from a MySQL database by using the drop column command. This also removes all data from the column when it is removed.
Comments
March 22, 2007 at 8:20 am
(1) ashok says:

give the example to drop column

November 26, 2007 at 4:44 pm
(2) evolutionxbox says:

It doens’t work…

I wrote:
ALTER TABLE T1 DROP DOB;

My tables is called T1 and my column is DOB for Date Of Birth.

I get:
ERROR: parser: parse error at or near “;”

I am using SSH Secure Shell 3.2.9, what is going on?

July 9, 2009 at 1:41 am
(3) suraj says:

You just have to use

alter table t1 drop column dob

July 20, 2009 at 12:43 am
(4) Phani says:

How to delete more than one field from table

November 7, 2009 at 11:52 pm
(5) arjun reddy says:

how to drop a column which is a foreign key.

May 12, 2010 at 11:48 am
(6) Sanket Patel says:

Hi All,
You can delete multiple columns by this query :

ALTER TABLE tablename
Drop (column1,column2,column3);

May 26, 2010 at 11:51 pm
(7) Vinodraj says:

@: (6) Sanket Patel says:
ALTER TABLE tablename
Drop (column1,column2,column3);
I guess the above query is not working in mysql

July 15, 2010 at 1:14 am
(8) chandrakanth shenoy says:

ALTER TABLE tablename
Drop (column1,column2,column3);
this wont work in mysql

September 27, 2010 at 12:37 pm
(9) Rajendra says:

This will Work 100 % – alter table TABLENAME drop column COLUMNNAME

November 9, 2010 at 4:26 am
(10) pinky says:

the alter table command is not working proper for deleting a column

November 9, 2010 at 6:23 am
(11) sudhakar says:

hi guys try this !

ALTER TABLE tablename Drop (column1,column2,column3);

the above command does not work.

just give like this., its work properly

ALTER TABLE table-name
DROP `column1`,
DROP `column2`,
DROP `column3`);

November 9, 2010 at 6:37 am
(12) sudhakar says:

hi guys try this !

ALTER TABLE tablename Drop (column1,column2,column3);

the above command does not work.

just give like this., its work properly

ALTER TABLE `tablename`
DROP `column1`,
DROP `column2`,
DROP `column3`;

December 22, 2010 at 2:16 am
(13) blubird says:

simple——
alter table drop column ;
alter table drop column ;
…..
this will definitely work

March 15, 2011 at 3:49 pm
(14) swapna says:

to delete more than one column u can use this command:

alter table table-name
drop column_name,
drop column_name;

May 25, 2011 at 2:43 am
(15) Roshan says:

its very helpfull to me!!!!

June 13, 2011 at 5:35 am
(16) Aaditya says:

This will work definately for MySql.

Alter table drop ;

July 4, 2011 at 2:15 am
(17) kaushik says:

it will definitely work..just try it
ALTER TABLE drop column COLUMNNAME

for more query contact on : 09024806881

July 6, 2011 at 1:22 am
(18) vamsy says:

Suppose if i want to remove the column from a table having primary and foreign key relation..
How can I remove the column having primary and foreign key related one

July 16, 2011 at 7:18 am
(19) kkrrish says:

its nice to learn new concepts.

October 30, 2011 at 9:46 pm
(20) mallikarjuna says:

hey first remove the table on which the foreign key constraint is applied and then remove the parent table

there is an another option of cascading if the table is removed
with out considering the foreign key constratint…

December 22, 2011 at 2:49 am
(21) saurav dash says:

1st delete all the data in that column…or you won’t be able to delete the column.once u have deleted all the data from that column u go for the comman
alter table TABLENAME drop column COLUMNNAME ;

June 12, 2012 at 6:57 am
(22) balamurugan says:

Hi there,
alter table TABLENAME drop column COLUMNNAME
is the only command we can use in mysql to drop single column at a time

September 26, 2012 at 6:45 am
(23) suryakant soni says:

alter table student2 drop column contact;
IT WILL WORK PAKKE ME

October 20, 2012 at 10:42 pm
(24) gary says:

It seems likely you have a foreign key constraint. Do “SHOW CREATE TABLE TableName” and near the end of the output the display will probably be similar to

“CONSTRAINT `Instructor` FOREIGN KEY (`Instructor`) REFERENCES `AnotherTable` (`Name`),CONSTRAINT `YourOffendingColumn` FOREIGN KEY (`IndexName`) REFERENCES `TableName` (`Name`),”

You must eliminate or appease the foreign key constraint before it will let you delete that column.

March 6, 2013 at 1:29 pm
(25) Sanket says:

It didn’t work…

i wrote,
alter table winner_doubles drop column com_id;

ERROR 1025(HY000): Error on rename of’.\sportsclub\#sql-7ec_c’ to ‘.\sportsclub\winner_doubles’ (errno: 150)

I got this error.. help me out..

June 26, 2013 at 6:00 am
(26) M L Siva Reddy says:

@Sanket:

Remove the column keyword, just use:

alter table winner_doubles drop com_id;

October 13, 2013 at 3:04 am
(27) Venugopal says:

There shouldn’t be any FOREIGN KEY linked the column that you intend to delete.

April 6, 2014 at 8:54 am
(28) ravindar reddy says:

alter table tablename drop coloumnname;

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

©2014 About.com. All rights reserved.