-- 声明使用数据库use 数据库;go -- 添加主键(primary key)约束-- 基本语法-- 判断主键约束是否存在,如果存在则删除,不存在则添加if exists(select * from sysobjects where name=主键名) alter table 表明 drop constraint 主键名;go alter table 表明 add constraint 主键名 primary key(列名) use SapDBT;go-- 实际例子 if exists(se