The command to delete a column in MySQL is ALTER TABLE. The syntax is ALTER TABLE table_name DROP COLUMN column_name. It can be used to delete non-primary key columns. The data in the column before deletion must be empty or NULL. After deletion, the data in the column will be Lost, for InnoDB tables, the table will be rebuilt after deleting the column.
Command to delete columns in MySQL
ALTER TABLE command is used to delete columns in MySQL tables Delete columns in . It looks like this:
<code class="sql">ALTER TABLE table_name DROP COLUMN column_name;</code>
Syntax:
Example:
To delete the "email" column from the table named "customers", use the following command:
<code class="sql">ALTER TABLE customers DROP COLUMN email;</code>
Note:
The above is the detailed content of Command to delete columns in mysql. For more information, please follow other related articles on the PHP Chinese website!