The sql statement to delete a field is "ALTER TABLE", and the specific syntax format is "ALTER TABLE
DROP
;"; among them, the "field name" designation needs to be from the table The name of the deleted field. The operating environment of this tutorial: windows7 system, mysql version 5.8, Dell G3 computer.
Deleting a field
Deleting a field is to remove a field in the data table from the table. The syntax format is as follows:
ALTER TABLE <表名> DROP <字段名>;Copy after loginAmong them, "Field name" refers to the name of the field that needs to be deleted from the table.
Example:
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)Copy after loginFor more programming-related knowledge, please visit: Programming Video! !
The above is the detailed content of What is the sql statement to delete a field?. For more information, please follow other related articles on the PHP Chinese website!
Related labels:source:php.cnPrevious article:Understand the basics of Mybatis Next article:What is used to implement the selection operation in the sql select statement?Statement of this WebsiteThe content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cnLatest Articles by Author
2023-04-26 17:59:18 2023-04-26 17:47:48 2023-04-26 17:41:42 2023-04-26 17:37:05 2023-04-26 17:31:25 2023-04-26 17:27:32 2023-04-25 19:57:58 2023-04-25 19:53:11 2023-04-25 19:49:11 2023-04-25 19:41:54Latest IssuesRegular expression to match words I have a script where I am trying to match new job names with existing job names in a data...From 2024-04-06 21:24:0401606MySQL gets data from multiple tables I have a eg_design table which contains the following columns: and eg_domains table which ...From 2024-04-06 18:42:4402479Group MySQL results by ID for looping over I have a table with flight data in mysql. I'm writing a php code that will group and displ...From 2024-04-06 17:27:5601406Related TopicsMore>