--------------更改一个主键的列的类型的步骤------------------------------------
例如:修改表GBTerminal.F97列xh类型为smallint
--
删除默认值
alter
table
GBTerminal
.
F97
drop
constraint
DF_F97_xh
go
--
删除
check
alter
table
GBTerminal
.
F97
drop
constraint
[CK_f97_xh]
go
--
删除主键
alter
table
GBTerminal
.
F97
drop
constraint
PK_F97
go
--
更改
xh
列类型为
smallint
alter
table
GBTerminal
.
F97
alter
column
xh
int
NOT
NULL
--xh
列加默认值
alter
table
GBTerminal
.
F97
add
constraint
DF_F97_xh
default
(
0
)
for
xh
--xh
列加
check
约束
alter
table
[GBTerminal]
.
[F97]
add
constraint
[CK_f97_xh]
CHECK
((
[xh]
<=(
1024
)))
--
添加主键
PK_F97
alter
table
GBTerminal
.
F97
add
constraint
PK_F97
primary
key
(
tid
,
xh
)