MySQL默认值为0、某字段数据自动加1

分两种情况,一种是此表中并没数据,一种是表中已存在数据。

针对第一种:

alter table 表名 alter column 字段 set default 0;

针对第二种情况:

update tablename set 字段=0alter table 表名 alter column 字段 set default 0;

Mysql中如何实现某字段数据自动加1

update BBD set cs=cs+1 where ID like id;

猜你喜欢

转载自blog.csdn.net/gy99csdn/article/details/114496228