mysql对属性的增删改

修改表 alter table

创建表db

 查看表

desc与describe 

desc table 

 查看建表语句show create table t1;

 

 修改表名 alter table t1 rename zcx_user;

 增加一个字段(属性)

alter table zcx_user add name varchar(10) not null;

增加一个字段age在name 后面

alter table zcx_user add column age tinyint unsigned after name;

 

 

 

 

 

 

 

 

 

 

 

删除一个字段

alter table zcx_user drop column id;

修改一个字段的名称和类型

alter table zcx_user rename birth132 to birthday;

 

修改名称和类型并改变位置

alter table zcx_user change birthday brith date after age;

-- ifnull(),if()

select if(3,4),if(0,'yes','no');

trunate zcx;

-- replace 如果值列表中有唯一值存在,则直接修改

 

 

总结:alter table zcx_user  change t1 int tinyint int after uid;

要改变一个字段位置必须改变数据类型,一些属性。其实改变字段位置没有实际上的意义。

posted @ 2022-02-17 16:17  一份人间烟火  阅读(93)  评论(0)    收藏  举报