首页 > 文章列表 > Mysql怎么删除数据库表中的某一列

Mysql怎么删除数据库表中的某一列

mysql
140 2023-04-19

删除数据库表中的某一列

删除某一字段的值

update table_name SET field_name = '';

删除某一列

ALTER TABLE table_name DROP COLUMN field_name;

Mysql删除列,添加列的sql语句

已有表actor,且包含列last_name

-- 删除列, 以下两种方式都可以
alter table actor drop  column last_name;
alter table actor drop last_name;
-- 添加列,必须指定列的类型
alter table actor add last_name varchar(10);