PHP, MySQL, Drupal, .htaccess, Robots.txt, Phponwebsites

19 Dec 2013

Delete column in mysql table

                       You created a table with number of columns. Sometimes you don't need to specific column. At the time, you can delete the column from mysql table. It is possible in mysql using by DROP mysql command. The following mysql query is used for this:
Mysql Query:
                         Alter table table_name drop column column_name


Consider the example:
 table1 is name of this table.

delete column in mysql table using DROP command


                          Suppose you've to delete the column 'Image'. The mysql query is:
                     Alter table table1 drop column Image

Now your table look like this:

drop column from mysql table

     Now the column name 'Image' is deleted from your mysql table.


Deleting the multiple column at the time in mysql:


                      You can delete multiple column at a time in mysql. The mysql query as follow as:
Mysql Query:
                          Alter table table1
                                    drop column Game_name,
                                    drop column Image

                          Now your output look like this:

Delete multiple column at a time in mysql table

                          Now you will get your mysql table with only column 'No'.

Related Post: