• 首页
  • 前端技术
  • 编程语言
  • 人工智能
  • 运维知识
  • 资源下载
  • 常用小工具
  • 技术问答

sql 基本操作

2021-06-24

SQL code
------------------------------列操作----------------------------------- --添加列 ALTER TABLE t ADD Mycolumn int identity(1,1)||not null default(0) --删除列 alter table t drop column Mycolumn --修改列 alter table t alter column Mycolumn varchar(20) not null --将表中的数据改为为小数 update t set groups=cast(groups as DECIMAL(10,3)) --将表字段的类型更改小数 alter table t alter column Yourcolumn DECIMAL(10,3)) ------------------------------约束操作---------------------------------- --加约束(默认值) Alter table t Add constraint C_Mycolumn default(30) for Mycolumn --加约束(check条件) alter table dbo.t add constraint ck_t check ('字段'<>'字段') alter table t with nocheck add constraint t_sex check([name] in(N'男',N'女')) --加约束(主键) alter table t add constraint t_id primary key(id) --删除约束 alter table t drop constraint [DF_t_Mycolumn] --加列加约束(默认值) alter table t add Mycolumn int CONSTRAINT [DF_t_Mycolumn] not null default(0)

相关文章:

猜你喜欢
相关资源
相似解决方案
热门标签
Java Python linux javascript Mysql C# Docker 算法 前端 SpringBoot Redis Vue spring 设计模式 .net core .net kubernetes c++ 数据库 数据结构 大数据 js 机器学习 微服务 Android Go 程序员 面试 JVM ASP.net core 云原生 人工智能 后端 PHP git CSS golang k8s Nginx Django mybatis 深度学习 多线程 React 架构 devops 爬虫 云计算 Spring Boot LeetCode
By © 2026 likecs 版权所有,
本站所有数据收集于网络如有侵犯到您的权益请联系 进行下架处理1。
粤ICP备22038628号Powered By WordPress