修改以及设计好的表

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;

 

posted @ 2015-05-13 15:21  hongdada  阅读(415)  评论(0编辑  收藏  举报