Delete a column from an existing MySQL table

Contributor Icon Contributed by qmchenry  
Tag Icon Tagged: MySQL  

The SQL command in this recipe removes a column and the column’s data from an existing MySQL table.


To delete the column col_stuff from the table table_things, use the following SQL command:

ALTER TABLE 'table_things' DROP 'col_stuff'

 

26 Comments -


  1. Thennarasu said on November 1, 2008

    Ya it works…

  2. kiran said on December 7, 2008

    helpful in coding.thank u.

  3. Dan said on January 3, 2009

    try myNet.Office
    at: http://www.NetthruOffice.com

  4. Mercy said on January 7, 2009

    Thank u. It is useful

  5. mysql said on January 20, 2009

    use it without ( ‘ )…

  6. steve said on February 13, 2009

    yep:

    ALTER TABLE table_things DROP col_stuff

  7. Neelesh said on February 24, 2009

    If we want to check whether that column exit, if exist only then delete the column so that our script does not hamper.

  8. jaswath said on April 16, 2009

    thanks it solved problem

  9. vol said on April 21, 2009

    ALTER TABLE table_things DROP col_stuff;

  10. A said on June 15, 2009

    ALTER TABLE room DROP COLUMN y;

  11. dennis said on December 11, 2009

    ALTER TABLE `article` DROP column `homepage`;

    Need to use key word column with my version of mysql. 5.1.41-1

  12. Anonymous said on March 12, 2010

    Exactly what I needed. Thanks.

  13. vishnu said on June 3, 2010

    yes…….Thanks for

  14. DID said on June 24, 2010

    It Dosn`t work in my machine

  15. Aishwarya said on July 7, 2010

    Thanks for ur valuable information

  16. Sss said on July 30, 2010

    love u

  17. Rahuljain Iips said on August 25, 2010

    Gud One

  18. Test said on October 1, 2010

    its working

  19. Anonym said on December 18, 2010

    Thanks so much!

  20. Abcdasdasdasd said on February 10, 2011

    Exactly what I needed. Thanks.

  21. sam said on February 25, 2011

    thanks

  22. Arun mohapatra said on March 19, 2011

    Thans a lot dear….

  23. Kili said on April 1, 2011

    poda…………..

  24. Mail said on April 29, 2011

    thanks works

  25. Pawankjajara said on June 30, 2011

    Awesome Query, works fine !

  26. Karthikeyan said on October 9, 2011

    Thank you so much dude. Good Work.

 

RSS feed for comments on this post. TrackBack URL

Leave a comment -