mysql修改某个字段的值_SQL 语句 以某一个字段为条件 修改某一个字段的值
展开全部update table set col2=case when col1 条件1 then 值1 when col1 条件2 then 值2;或者分为几句修改update table set col2=值1 where col1 条件1update table set col2=值2 where col1 条件2扩展资料:SQL修改字段属性总636f70793231313335323631
展开全部
update table set col2=case when col1 条件1 then 值1 when col1 条件2 then 值2;
或者分为几句修改
update table set col2=值1 where col1 条件1
update table set col2=值2 where col1 条件2
扩展资料:
SQL修改字段属性总636f70793231313335323631343130323136353331333366306561结
1、修改表中字段类型 可以修改列的类型,是否为空)
Alter table [表名] alter column [列名] 类型
2、向表中添加字段
Alter table [表名] add [列名] 类型
3、删除字段
Alter table [表名] drop column [列名]
4、添加主键
Alter table [表名] add constraint [ 约束名] primary key( [列名])
5、添加唯一约束
Alter table [表名] add constraint [ 约束名] unique([列名])
6、添加表中某列的默认值
Alter table [表名] add constraint [约束名] default(默认值) for [列名]
7、添加约束
Alter table [表名] add constraint [约束名] check (内容)
8、添加外键约束
Alter table [表名] add constraint [约束名] foreign key(列名) referencese 另一表名(列名)
9、删除约束
Alter table [表名] add constraint [约束名]
10、重命名表
exec sp_rename ‘[原表名]’,’[新表名]’
11、重命名列名
exec sp_rename ‘[表名].[列名]’,’[表名].[新列名]’

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐
所有评论(0)