MySql常用语句总结更新

it2025-12-15  25

1、Mysql修改字段的默认值:

  alter table tablename alter column drop default; (若本身存在默认值,则先删除)  alter table tablename alter column set default 0;(若本身不存在则可以直接设定)

2、修改字段的备注:

  alter table dq_permission_group_permission modify column trial_type tinyint(1) comment '备注内容';

3、查询表内某字段重复值的数量:

  select mobile,count(*) as sumcount from user group by mobile having sumcount>1; (先用手机号分组,再用having来过滤大于1的,查出来的就是重复记录)

4、修改字段的长度:

  alter table pre_common_attachments modify column user_id int(50);

5、查看表内索引:

  show indexex from table;

  show keys from table;

 

转载于:https://www.cnblogs.com/javallh/p/11193114.html

相关资源:MySQL常用SQL语句总结包含复杂SQL查询
最新回复(0)