v2 f2
4 A
5 B
6 C
7 D
f1 v1
A 4
B 5
C 6
D 7
1.根据数据库中已有表创建新表
select * into t2 from t1
2.根据t2表中的值更新t1表中的列的值
update t1 set t1.v1 = t2.v2 from t1,t2 where t1.f1 = t2.f2
3.更改列数据类型
alter table t2 alter column f2 int
4.更改列名
用存储过程
exec sp_rename 't1.f1','f_new','column'
5.删除某列
alter table t2 drop column f2
6.增加一列
alter table t2 add f2_new int
7.增加主键
alter table t1 add primary key(f1)
8.删除主键
先查看f1的主键名字
select * from sys.indexes where object_id = object_id('t1') and is_primary_key = 1
然后删除此主键
alter table t1 drop constraint 主键名