版权声明:本文为博主原创文章,未经博主允许不得转载。 https://cloud.tencent.com/developer/article/1338359
本文主要内容mysql 列常用命令:
describe table_name column_name
describe table_name column_name
很多时候我们需要查看列的详细详细,例如:
describe springdemo.blog title;
show fields from springdemo.blog;
查看所有列
修改表的列属性 alter table <表名> modify <列> <数据类型>
修改表的字段名 alter table <表名> change<旧列名> <新列名> <数据类型>
注意:数据在数据库中的存储和数据类型有很大的关系,故而不要随便改数据类型 alter table springdemo.blog change title title_new nvarchar(60) comment ‘修改啦’;
alter table springdemo.tb_ms_audit_user_info
add mal_report int default 0
comment '恶意举报的次数', add index(mal_report);
删除字段 : alter table <表名> drop <列名>
alter table tablename alter column drop default;
#(若本身存在默认值,则先删除)
alter table tablename alter column set default 't5';
# (若本身不存在则可以直接设定)
转载务必注明出处,尊重别人的劳动成果。