mysql新增、修改表字段

1.添加表字段: alter table table_name add column_name 类型(长度) [not] null;
  alter table user add address varchar(255) not null;
 
2.修改表字段:alter table table_name change old_name new_name 类型(长度) [not] null;
  alter table user change address ip_address varchar(100);
  
  如果不需要修改字段名,可以用modify:
      alter table table_name modify column_name 类型(长度) [not] null;
     
3.删除表字段:alter table table_name drop column_name;
  alter table user drop address; 

猜你喜欢

转载自blog.csdn.net/qq_28379809/article/details/94614044