本文主要内容mysql 列常用命令:
查看表的列的属性 describe table_name column_name
show all column property查看所有列的属性
修改表的列属性 alter table modify
rename column重命名列
添加列(同时添加索引)、删除列
修改列的默认值
很多时候我们需要查看列的详细详细,例如:
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_infoadd mal_report int default 0comment '恶意举报的次数', add index(mal_report);
删除字段 : alter table <表名> drop <列名>
alter table tablename alter column drop default; #(若本身存在默认值,则先删除)alter table tablename alter column set default 't5';# (若本身不存在则可以直接设定)
转载务必注明出处,尊重别人的劳动成果。
以上就是mysql列column常用命令的使用总结的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号