mysql 数据结构_mysql数据结构操作

删除列

alter table table-name drop col-name;

增加列(单列)

alter table table-name add col-name col-type comment 'xxx';

增加列(多列)

alter table table-name add col-name col-type comment 'xxx', add col-name col-type(col-length) comment 'xxx';

增加表字段并指明字段放置为第一列

alter table table-name add col-name col-type COMMENT 'sss' FIRST;

增加表字段并指明字段放置为特定列后面

alter table table-name add col-name col-type after col-name-1;

使用MODIFY修改字段类型

alter table table-name modify column col-name col-type;

使用CHANGE修改字段类型

alter table table-name change col-name col-name col-type;

使用CHANGE修改字段名称

alter table table-name change old-col-name new-col-name col-type;

修改列类型、长度

alter table table-name change old-col-name new-col-name new-col-type;

查看表中列属性

show columns from table-name;

修改表名

rename table old-table-name to new-table-name;

为字段设置NULL和DEFAULT

alter table table-name modify col-name col-type not null default 100;

修改字段的默认值

alter table table-name alter col-name set default 10000;

字段删除默认值

alter table table-name alter col-name drop default;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值