SQL常用语句
时间:2021-07-01 10:21:17
帮助过:34人阅读
查询表主键
EXEC sp_pkeys
@table_name=‘Plat_CommAttrSelect‘
--删除表主键
Declare @Pk varChar(
100);
Select @Pk=Name
from sysobjects
where Parent_Obj
=OBJECT_ID(
‘Plat_CommAttrSelect‘)
and xtype
=‘PK‘;
if @Pk is not null
exec(
‘Alter table Plat_CommAttrSelect Drop ‘+ @Pk)
--添加表主键
alter table Plat_CommAttrSelect
add constraint Plat_CommAttrSelect_PK
primary key(ID)
SQL常用语句
标签:-- null parent bsp cts 添加 constrain 语句 select