DROP Deleting a table field is to remove a field in the data table from the table. You can use the "ALTER TABLE 722e3d59fd24604761db25f00f9b264f DROP d54a89d049b8798d0c1aea7f04693a4f;" statement; where, "Field name" refers to the name of the field that needs to be deleted from the table. The operating environment of this tutorial: windows7 system, Dell G3 computer, mysql8. mysql delete field Deleting a field is to remove a field in the data table from the table. The syntax format is as follows: where , "field name" refers to the name of the field that needs to be deleted from the table. Example: (Recommended tutorial: mysql video tutorial) Use ALTER TABLE to modify the structure of table tb_emp1, Delete col2 field For more programming-related knowledge, please visit:Programming Teaching! ! The above is the detailed content of How to delete table fields in mysql. For more information, please follow other related articles on the PHP Chinese website!How to delete table fields in mysql
ALTER TABLE <表名> DROP <字段名>;
mysql> DESC tb_emp1;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| col1 | int(11) | YES | | NULL | |
| id | int(11) | YES | | NULL | |
| name | varchar(30) | YES | | NULL | |
| col2 | int(11) | YES | | NULL | |
| deptId | int(11) | YES | | NULL | |
| salary | float | YES | | NULL | |
+--------+-------------+------+-----+---------+-------+
6 rows in set (0.00 sec)
mysql> ALTER TABLE tb_emp1
-> DROP col2;
Query OK, 0 rows affected (0.53 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> DESC tb_emp1;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| col1 | int(11) | YES | | NULL | |
| id | int(11) | YES | | NULL | |
| name | varchar(30) | YES | | NULL | |
| deptId | int(11) | YES | | NULL | |
| salary | float | YES | | NULL | |
+--------+-------------+------+-----+---------+-------+
5 rows in set (0.00 sec)