The following statement, ALTER TABLE DROP COLUMN, when used in MySQL, removes a whole column we specify in the query.
Syntax
ALTER TABLE table_name DROP COLUMN column_name;
Let us see in the real-time example.
For a real-time example, we are going to use the crypto_price_list table.
MySQL Drop Column Example
Dropping Year Column
ALTER TABLE crypto_price_list DROP COLUMN Year;
We can see that the requested column 'Year' has been dropped entirely along with its contained pieces of information. We can remove multiple columns using this syntax too.
ALTER TABLE table_name
DROP COLUMN column_name_1,
DROP COLUMN column_name_2,
...;
- Log in to post comments