博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
修改以及设计好的表
阅读量:6941 次
发布时间:2019-06-27

本文共 1139 字,大约阅读时间需要 3 分钟。

1.修改表字段

use EntranceVista;alter table Ry_Stay_Info alter column wza nvarchar(50) alter table Ry_Stay_Info alter column wzb nvarchar(50)

2.添加主键

添加主键之前先要让该字段不能为空

use EveryTouch;alter table FP_TB_Department alter column ID int not null alter table FP_TB_Department add constraint PK_DEPARTMENT primary key (ID)

3.添加自增长

如果一个列已经有主键,要先删除主键,再删除字段,再添加

alter table FP_TB_Department drop constraint PK_DEPARTMENT   alter table FP_TB_Department drop column ID  alter table FP_TB_Department add ID int identity(1,1) constraint PK_DEPARTMENT primary key (ID)

 4.修改默认值

alter table BBS_VoteDetail_TB add default newid() for VoteDetailID

删除默认值

alter table Service_TeacherInfo drop Constraint DF__tmp_ms_xx__Appro__737017C0

 

alter table ChannelBargainSecond drop Constraint DF__ChannelBa__Updat__15FB0545  alter table ChannelBargainSecond drop column UpdateTime

 

 5.添加字段

alter table [CJGreenWay].[dbo].[T_OrderApprove] add [State] int null

 

alter table ChannelBargainSecond add UpdateTime datetime null default getdate();  alter table ChannelBargainSecond add IsDelete int not null default 0;  alter table ChannelBargainSecond add CreateUser nvarchar(20)  null;

 

转载地址:http://scfnl.baihongyu.com/

你可能感兴趣的文章
菜鸟要做架构师(三)——单元测试的七种境界
查看>>
Replication的犄角旮旯(七)-- 一个DDL引发的血案(下)(聊聊logreader的延迟)
查看>>
类在编写过程中的一些注意事项
查看>>
怎样解决栈溢出
查看>>
iTextSharp带中文转换出来的PDF文档显示乱码
查看>>
分享改进 完全定制自己的代码生成器
查看>>
object-c 获得目录(包括子目录)下所有文件和文件夹路径
查看>>
nginx自定义模块编写-实时统计模块--转载
查看>>
【leetcode】 search Insert Position(middle)
查看>>
我爱免费之FreeFileSync文件夹同步软件
查看>>
lufylegend:图片的加载和显示
查看>>
献给所有从事IT行业拥有梦想的英语渣们
查看>>
Linux命令-更新系统时间和硬件时间
查看>>
音频AAC编码浅析
查看>>
linux系统时间和硬件时钟问题(date和hwclock)
查看>>
你用过这种奇葩的C#注释吗?如何看待
查看>>
memcache安装
查看>>
我的第一个DMZ方案实践
查看>>
HTML5--Video
查看>>
UVM中的regmodel建模(三)
查看>>