您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

MySQL命令行删除表中的一个字段_MySQL

2025/5/6 6:35:25发布19次查看
先看看删除之前的表结构:
mysql> select * from test; +------+--------+----------------------------------+------------+------------+------------+------------+ | t_id | t_name | t_password | t_birth | birth | birth1 | birth2 | +------+--------+----------------------------------+------------+------------+------------+------------+ | 1 | name1 | 12345678901234567890123456789012 | null | 1990-01-01 | 0000-00-00 | 2013-01-01 | | 2 | name2 | 12345678901234567890123456789012 | 2013-01-01 | null | 0000-00-00 | 2013-01-01 | +------+--------+----------------------------------+------------+------------+------------+------------+ 2 rows in set (0.00 sec)
执行删除命令,使用drop关键字。
基本的语法为:alter table
<表名> drop column <字段名>;
具体的命令如下:
mysql> alter table test drop column birth1; query ok, 0 rows affected (0.13 sec) records: 0 duplicates: 0 warnings: 0
看看删除后的结果,是不是已经没有birth1字段了?
mysql> select * from test; +------+--------+----------------------------------+------------+------------+------------+ | t_id | t_name | t_password | t_birth | birth | birth2 | +------+--------+----------------------------------+------------+------------+------------+ | 1 | name1 | 12345678901234567890123456789012 | null | 1990-01-01 | 2013-01-01 | | 2 | name2 | 12345678901234567890123456789012 | 2013-01-01 | null | 2013-01-01 | +------+--------+----------------------------------+------------+------------+------------+ 2 rows in set (0.00 sec)
以上就是mysql命令行删除表中的一个字段_mysql的内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product