What MySQL returns when we remove all the columns from a table by using ALTER TABLE command with DROP keyword?


Eventually, we cannot remove all the columns from a table by using ALTER TABLE command with DROP keyword. In this case, MySQL will return an error message. It is demonstrated with the help of the following example

Suppose in table ‘Employee’ we have two columns ‘name’ and ‘id’, now if we will use ALTER TABLE to remove both the columns then MySQL returns an error as follows

mysql> ALTER TABLE employee drop column name, drop column id;
ERROR 1090 (42000): You can't delete all columns with ALTER TABLE; use DROP TABLE instead

Updated on: 29-Jan-2020

74 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements