SQL Server-表结构的操作
1.修改表的字段的数据类型
alter table [File_Info] alter column Upload_Request_ID nvarchar(14) not null
2.添加表的字段并赋予默认值
ALTER TABLE [File_Info] ADD Upload_Result NVARCHAR(50) NOT NULL DEFAULT ('')
3.修改表的字段名
--Exec sp_rename '表名.旧字段名','新字段名','Column' Exec sp_rename '[File_Info].Upload_Result','Failure_Type','Column'
4.添加主键约束
alter table [Upload_Request] add constraint [PK_Upload_Request] primary key CLUSTERED ( [Request_ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 20) ON [PRIMARY]
5.删除表中的列
--有约束的要删除约束 alter table [File_Info] drop column Failure_Reason,Failure_Type