展开全部
删除外键约束的表,首先要删除外键关联,然后才可以删除表。
如:
1、创建表62616964757a686964616fe78988e69d8331333337616439author :CREATE TABLE [dbo].[author]
([ID] [bigint] NOT NULL PRIMARY KEY,
[AuthorName] [char] (10) NULL,
[address] [char] (480) NULL,
[introduction] [ntext] NULL)
2、创建myBBS表:CREATE TABLE [dbo].[myBBS] (
[ID] [bigint] IDENTITY (1, 1) NOT NULL,
[authorId] [bigint] NOT NULL,
[Title] [char] (40) NULL,
[Date_of_Created] [datetime] NULL,
[Abstract] [char] (480) NULL,
[Content] [ntext] NULL)
3、创建外键关系:alter table dbo.mybbs add constraint FK_mybbs_author
foreign key (authorId)
references dbo.author([id]) ON UPDATE CASCADE ON DELETE CASCADE
4、在删除表前,要删除外键,语法如下:alter table dbo.mybbs drop constraint FK_mybbs_author
5、然后再删除表:drop table [dbo].[myBBS]