--删除约束 ALTER TABLE CustomData DROP CONSTRAINT FK_CustomData_CustomFormatInfo GO --关闭递增插入属性 SET IDENTITY_INSERT OFF --打开递增插入属性 SET IDENTITY_INSERT ON --修改增加约束 ALTER TABLE [CustomFormatInfo] WITH NOCHECK ADD CONSTRAINT [PK_CustomFormatInfo] PRIMARY KEY CLUSTERED ( [CustomFormatID] ) ON [PRIMARY] GO --修改表增加外键约束 ALTER TABLE [CustomData] ADD CONSTRAINT [FK_CustomData_CustomFormatInfo] FOREIGN KEY ( [CustomFormatID] ) REFERENCES [CustomFormatInfo] ( [CustomFormatID] ) GO