mssql2000对列的一些操作

表名:AlterAtion 列名:ZXBK 约束名:DF_AlterAtion_ZXBK

----添加一列

alter table AlterAtion  add ZXBK varchar(20)

----删除一列

alter table AlterAtion  drop column ZXBK

----修改一列(当改列有约束条件时,先删约束)

Alter table AlterAtion alter cloumn ZZBM nvarchar(50) null

----重命名一列

exec sp_rename AlterAtion.ZXBK ,'ZXBK 1','Column'

----删除改列的约束

select b.name from syscolumns a,sysobjects b where a.id=object_id(‘AlterAtion’) and b.id=a.cdefault and a.name='ZXBK' and b.name like 'DF%' --删除约束

alter table AlterAtion drop constraint DF_AlterAtion_ZXBK

----添加一个约束

alter table AlterAtion add constraint DF_AlterAtion_ZXBK default('1') for ZXBK

原文地址:https://www.cnblogs.com/leqoqo/p/1837001.html